diff options
author | 2021-03-31 13:57:52 -0700 | |
---|---|---|
committer | 2021-03-31 14:45:27 -0700 | |
commit | 088550048864aa836e9411acc28ae8f8fed28a03 (patch) | |
tree | edc18c5c5721a917d30c143d335d90967330aa45 | |
parent | 9a7ad7fa85cf9c68238c8b33d3402424d0bf08d4 (diff) |
Calling linkToDeath on binder in NRI constructor
Any NRI constructor that can possibly have a binder should call
linkToDeath on that binder if present. Not doing so can result in a
no such element exception when that NRI is removed.
Bug: 184155022
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCasesLatestSdk
Change-Id: I90d594e43474483c554d0d315ff7abb6f678e093
-rw-r--r-- | services/core/java/com/android/server/ConnectivityService.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index e3ce7a31b97e..70c9fe7f3ac9 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -5542,12 +5542,7 @@ public class ConnectivityService extends IConnectivityManager.Stub incrementRequestCountOrThrow(this); mCallbackFlags = callbackFlags; mCallingAttributionTag = callingAttributionTag; - - try { - mBinder.linkToDeath(this, 0); - } catch (RemoteException e) { - binderDied(); - } + linkDeathRecipient(); } NetworkRequestInfo(@NonNull final NetworkRequestInfo nri, @@ -5585,6 +5580,7 @@ public class ConnectivityService extends IConnectivityManager.Stub incrementRequestCountOrThrow(this); mCallbackFlags = nri.mCallbackFlags; mCallingAttributionTag = nri.mCallingAttributionTag; + linkDeathRecipient(); } NetworkRequestInfo(int asUid, @NonNull final NetworkRequest r) { @@ -5613,8 +5609,18 @@ public class ConnectivityService extends IConnectivityManager.Stub return Collections.unmodifiableList(tempRequests); } + void linkDeathRecipient() { + if (null != mBinder) { + try { + mBinder.linkToDeath(this, 0); + } catch (RemoteException e) { + binderDied(); + } + } + } + void unlinkDeathRecipient() { - if (mBinder != null) { + if (null != mBinder) { mBinder.unlinkToDeath(this, 0); } } |