diff options
| author | 2017-10-20 23:22:13 +0000 | |
|---|---|---|
| committer | 2017-10-20 23:22:13 +0000 | |
| commit | c336947da424097d24fc2c44ba18195627a82aeb (patch) | |
| tree | 19edd1c44d8140dd25ea9b7d903bc99fd915ba1e | |
| parent | 8138b8b3eddcf9585a75c036aa6a716270a507ee (diff) | |
| parent | b6c4bc311aa73ddeea7a1b435836af9eb6799f74 (diff) | |
Merge "Check success before registering DeathRecipient"
am: b6c4bc311a
Change-Id: Ie4a8f3ea3374d30a6a4dd9d22d9d48df0075c560
| -rw-r--r-- | telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java | 48 | ||||
| -rw-r--r-- | telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java | 38 |
2 files changed, 52 insertions, 34 deletions
diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java index c3b2c482049b..9ccdd56fd82d 100644 --- a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java +++ b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java @@ -118,14 +118,8 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { } final int uid = Binder.getCallingUid(); - callback.asBinder().linkToDeath(new DeathRecipient() { - @Override - public void binderDied() { - onAppCallbackDied(uid, subscriptionId); - } - }, 0); - return initialize(subscriptionId, new MbmsDownloadSessionCallback() { + int result = initialize(subscriptionId, new MbmsDownloadSessionCallback() { @Override public void onError(int errorCode, String message) { try { @@ -153,6 +147,17 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { } } }); + + if (result == MbmsErrors.SUCCESS) { + callback.asBinder().linkToDeath(new DeathRecipient() { + @Override + public void binderDied() { + onAppCallbackDied(uid, subscriptionId); + } + }, 0); + } + + return result; } /** @@ -251,17 +256,6 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { throw new NullPointerException("Callback must not be null"); } - DeathRecipient deathRecipient = new DeathRecipient() { - @Override - public void binderDied() { - onAppCallbackDied(uid, downloadRequest.getSubscriptionId()); - mDownloadCallbackBinderMap.remove(callback.asBinder()); - mDownloadCallbackDeathRecipients.remove(callback.asBinder()); - } - }; - mDownloadCallbackDeathRecipients.put(callback.asBinder(), deathRecipient); - callback.asBinder().linkToDeath(deathRecipient, 0); - DownloadStateCallback exposedCallback = new FilteredDownloadStateCallback(callback, flags) { @Override protected void onRemoteException(RemoteException e) { @@ -269,9 +263,23 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { } }; - mDownloadCallbackBinderMap.put(callback.asBinder(), exposedCallback); + int result = registerStateCallback(downloadRequest, exposedCallback); + + if (result == MbmsErrors.SUCCESS) { + DeathRecipient deathRecipient = new DeathRecipient() { + @Override + public void binderDied() { + onAppCallbackDied(uid, downloadRequest.getSubscriptionId()); + mDownloadCallbackBinderMap.remove(callback.asBinder()); + mDownloadCallbackDeathRecipients.remove(callback.asBinder()); + } + }; + mDownloadCallbackDeathRecipients.put(callback.asBinder(), deathRecipient); + callback.asBinder().linkToDeath(deathRecipient, 0); + mDownloadCallbackBinderMap.put(callback.asBinder(), exposedCallback); + } - return registerStateCallback(downloadRequest, exposedCallback); + return result; } /** diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java index 65b726dfb45d..a2381536ac0c 100644 --- a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java +++ b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java @@ -70,14 +70,8 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { } final int uid = Binder.getCallingUid(); - callback.asBinder().linkToDeath(new DeathRecipient() { - @Override - public void binderDied() { - onAppCallbackDied(uid, subscriptionId); - } - }, 0); - return initialize(new MbmsStreamingSessionCallback() { + int result = initialize(new MbmsStreamingSessionCallback() { @Override public void onError(final int errorCode, final String message) { try { @@ -105,6 +99,17 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { } } }, subscriptionId); + + if (result == MbmsErrors.SUCCESS) { + callback.asBinder().linkToDeath(new DeathRecipient() { + @Override + public void binderDied() { + onAppCallbackDied(uid, subscriptionId); + } + }, 0); + } + + return result; } @@ -161,14 +166,8 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { } final int uid = Binder.getCallingUid(); - callback.asBinder().linkToDeath(new DeathRecipient() { - @Override - public void binderDied() { - onAppCallbackDied(uid, subscriptionId); - } - }, 0); - return startStreaming(subscriptionId, serviceId, new StreamingServiceCallback() { + int result = startStreaming(subscriptionId, serviceId, new StreamingServiceCallback() { @Override public void onError(final int errorCode, final String message) { try { @@ -215,6 +214,17 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { } } }); + + if (result == MbmsErrors.SUCCESS) { + callback.asBinder().linkToDeath(new DeathRecipient() { + @Override + public void binderDied() { + onAppCallbackDied(uid, subscriptionId); + } + }, 0); + } + + return result; } /** |