[RTT] Add a binder to the AIDL to enable cleanup
Pass a binder from the manager to the service to enable cleanup
on app death (using binder death listener).
Bug: 37443149
Test: verified using ResponderToolActivity test apk.
Change-Id: Ifb7797db812d4cb0b219e7cbd779bad323f2a4b4
diff --git a/wifi/java/android/net/wifi/IRttManager.aidl b/wifi/java/android/net/wifi/IRttManager.aidl
index 90f66c4..3831809 100644
--- a/wifi/java/android/net/wifi/IRttManager.aidl
+++ b/wifi/java/android/net/wifi/IRttManager.aidl
@@ -23,6 +23,6 @@
*/
interface IRttManager
{
- Messenger getMessenger();
+ Messenger getMessenger(in IBinder binder, out int[] key);
RttManager.RttCapabilities getRttCapabilities();
}
diff --git a/wifi/java/android/net/wifi/RttManager.java b/wifi/java/android/net/wifi/RttManager.java
index a4b3bf2a..ac5df05 100644
--- a/wifi/java/android/net/wifi/RttManager.java
+++ b/wifi/java/android/net/wifi/RttManager.java
@@ -6,6 +6,7 @@
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
+import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -1187,6 +1188,8 @@
CMD_OP_ENALBE_RESPONDER_SUCCEEDED = BASE + 7;
public static final int
CMD_OP_ENALBE_RESPONDER_FAILED = BASE + 8;
+ /** @hide */
+ public static final int CMD_OP_REG_BINDER = BASE + 9;
private static final int INVALID_KEY = 0;
@@ -1215,9 +1218,10 @@
mContext = context;
mService = service;
Messenger messenger = null;
+ int[] key = new int[1];
try {
Log.d(TAG, "Get the messenger from " + mService);
- messenger = mService.getMessenger();
+ messenger = mService.getMessenger(new Binder(), key);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -1233,6 +1237,7 @@
// We cannot use fullyConnectSync because it sends the FULL_CONNECTION message
// synchronously, which causes RttService to receive the wrong replyTo value.
mAsyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
+ mAsyncChannel.sendMessage(CMD_OP_REG_BINDER, key[0]);
}
private void validateChannel() {