summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl3
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pManager.java30
2 files changed, 29 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl b/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl
index 8b1cfaee8119..bfdd45d9f9b0 100644
--- a/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl
+++ b/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl
@@ -25,8 +25,9 @@ import android.os.Messenger;
*/
interface IWifiP2pManager
{
- Messenger getMessenger();
+ Messenger getMessenger(in IBinder binder);
Messenger getP2pStateMachineMessenger();
+ oneway void close(in IBinder binder);
void setMiracastMode(int mode);
void checkConfigureWifiDisplayPermission();
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index 95d0a79bb28b..7f085f71e99c 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -28,6 +28,7 @@ import android.net.wifi.p2p.nsd.WifiP2pServiceRequest;
import android.net.wifi.p2p.nsd.WifiP2pServiceResponse;
import android.net.wifi.p2p.nsd.WifiP2pUpnpServiceInfo;
import android.net.wifi.p2p.nsd.WifiP2pUpnpServiceResponse;
+import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -290,6 +291,7 @@ public class WifiP2pManager {
"android.net.wifi.p2p.CALLING_PACKAGE";
IWifiP2pManager mService;
+ private final Map<Channel, Binder> mBinders = new HashMap<>();
private static final int BASE = Protocol.BASE_WIFI_P2P_MANAGER;
@@ -889,7 +891,10 @@ public class WifiP2pManager {
* @return Channel instance that is necessary for performing any further p2p operations
*/
public Channel initialize(Context srcContext, Looper srcLooper, ChannelListener listener) {
- return initalizeChannel(srcContext, srcLooper, listener, getMessenger());
+ Binder binder = new Binder();
+ Channel channel = initalizeChannel(srcContext, srcLooper, listener, getMessenger(binder));
+ mBinders.put(channel, binder);
+ return channel;
}
/**
@@ -1385,12 +1390,14 @@ public class WifiP2pManager {
* Get a reference to WifiP2pService handler. This is used to establish
* an AsyncChannel communication with WifiService
*
+ * @param binder A binder for the service to associate with this client.
+ *
* @return Messenger pointing to the WifiP2pService handler
* @hide
*/
- public Messenger getMessenger() {
+ public Messenger getMessenger(Binder binder) {
try {
- return mService.getMessenger();
+ return mService.getMessenger(binder);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -1412,6 +1419,23 @@ public class WifiP2pManager {
}
/**
+ * Close the current P2P connection and clean-up any configuration requested by the
+ * current app. Takes same action as taken when the app dies.
+ *
+ * @param c is the channel created at {@link #initialize}
+ *
+ * @hide
+ */
+ public void close(Channel c) {
+ try {
+ mService.close(mBinders.get(c));
+ mBinders.remove(c);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Get a handover request message for use in WFA NFC Handover transfer.
* @hide
*/