diff options
author | Irfan Sheriff <isheriff@google.com> | 2013-03-28 17:29:14 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-03-28 17:29:14 +0000 |
commit | ce449d9ee521052bb6c24885a3599a19841eae5d (patch) | |
tree | d3e9952047158c3f0bd4d5f11d30776599ed190d /wifi | |
parent | 5acc8632a76da2b91af549c0cee938ed938a3f16 (diff) | |
parent | 8b485adffd7eaa7b7cab4c444b3d65097ef40a14 (diff) | |
download | frameworks_base-ce449d9ee521052bb6c24885a3599a19841eae5d.zip frameworks_base-ce449d9ee521052bb6c24885a3599a19841eae5d.tar.gz frameworks_base-ce449d9ee521052bb6c24885a3599a19841eae5d.tar.bz2 |
Merge "Add support for setMiracastMode" into jb-mr2-dev
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 10 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl | 1 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pManager.java | 15 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pService.java | 34 |
4 files changed, 56 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 32cd2f6..f637e89 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -793,4 +793,14 @@ public class WifiNative { public boolean p2pServDiscCancelReq(String id) { return doBooleanCommand("P2P_SERV_DISC_CANCEL_REQ " + id); } + + /* Set the current mode of miracast operation. + * 0 = disabled + * 1 = operating as source + * 2 = operating as sink + */ + public void setMiracastMode(int mode) { + // Note: optional feature on the driver. It is ok for this to fail. + doBooleanCommand("DRIVER MIRACAST " + mode); + } } diff --git a/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl b/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl index 381a450..1c9c40d 100644 --- a/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl +++ b/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl @@ -26,5 +26,6 @@ import android.os.Messenger; interface IWifiP2pManager { Messenger getMessenger(); + void setMiracastMode(int mode); } diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java index 2e80064..737ab91 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java @@ -1258,6 +1258,21 @@ public class WifiP2pManager { c.mAsyncChannel.sendMessage(REQUEST_PERSISTENT_GROUP_INFO, 0, c.putListener(listener)); } + /** @hide */ + public static final int MIRACAST_DISABLED = 0; + /** @hide */ + public static final int MIRACAST_SOURCE = 1; + /** @hide */ + public static final int MIRACAST_SINK = 2; + /** Internal use only @hide */ + public void setMiracastMode(int mode) { + try { + mService.setMiracastMode(mode); + } catch(RemoteException e) { + // ignore + } + } + /** * Get a reference to WifiP2pService handler. This is used to establish * an AsyncChannel communication with WifiService diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index e6a1df1..447ddb0 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java @@ -164,6 +164,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub { public static final int DISCONNECT_WIFI_REQUEST = BASE + 12; public static final int DISCONNECT_WIFI_RESPONSE = BASE + 13; + public static final int SET_MIRACAST_MODE = BASE + 14; + private final boolean mP2pSupported; private WifiP2pDevice mThisDevice = new WifiP2pDevice(); @@ -310,6 +312,12 @@ public class WifiP2pService extends IWifiP2pManager.Stub { "WifiP2pService"); } + private void enforceConnectivityInternalPermission() { + mContext.enforceCallingOrSelfPermission( + android.Manifest.permission.CONNECTIVITY_INTERNAL, + "WifiP2pService"); + } + /** * Get a reference to handler. This is used by a client to establish * an AsyncChannel communication with WifiP2pService @@ -320,6 +328,20 @@ public class WifiP2pService extends IWifiP2pManager.Stub { return new Messenger(mP2pStateMachine.getHandler()); } + /** This is used to provide information to drivers to optimize performance depending + * on the current mode of operation. + * 0 - disabled + * 1 - source operation + * 2 - sink operation + * + * As an example, the driver could reduce the channel dwell time during scanning + * when acting as a source or sink to minimize impact on miracast. + */ + public void setMiracastMode(int mode) { + enforceConnectivityInternalPermission(); + mP2pStateMachine.sendMessage(SET_MIRACAST_MODE, mode); + } + @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) @@ -572,6 +594,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { case DhcpStateMachine.CMD_POST_DHCP_ACTION: case DhcpStateMachine.CMD_ON_QUIT: case WifiMonitor.P2P_PROV_DISC_FAILURE_EVENT: + case SET_MIRACAST_MODE: break; case WifiStateMachine.CMD_ENABLE_P2P: // Enable is lazy and has no response @@ -878,7 +901,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { sendPeersChangedBroadcast(); } break; - case WifiP2pManager.ADD_LOCAL_SERVICE: + case WifiP2pManager.ADD_LOCAL_SERVICE: if (DBG) logd(getName() + " add service"); WifiP2pServiceInfo servInfo = (WifiP2pServiceInfo)message.obj; if (addLocalService(message.replyTo, servInfo)) { @@ -916,7 +939,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub { clearServiceRequests(message.replyTo); replyToMessage(message, WifiP2pManager.CLEAR_SERVICE_REQUESTS_SUCCEEDED); break; - case WifiMonitor.P2P_SERV_DISC_RESP_EVENT: + case WifiMonitor.P2P_SERV_DISC_RESP_EVENT: if (DBG) logd(getName() + " receive service response"); List<WifiP2pServiceResponse> sdRespList = (List<WifiP2pServiceResponse>) message.obj; @@ -927,13 +950,16 @@ public class WifiP2pService extends IWifiP2pManager.Stub { sendServiceResponse(resp); } break; - case WifiP2pManager.DELETE_PERSISTENT_GROUP: + case WifiP2pManager.DELETE_PERSISTENT_GROUP: if (DBG) logd(getName() + " delete persistent group"); mGroups.remove(message.arg1); replyToMessage(message, WifiP2pManager.DELETE_PERSISTENT_GROUP_SUCCEEDED); break; + case SET_MIRACAST_MODE: + mWifiNative.setMiracastMode(message.arg1); + break; default: - return NOT_HANDLED; + return NOT_HANDLED; } return HANDLED; } |