Do not use hidden API Binder.withCleanCallingIdentity
Bug: 137202333
Test: make
Change-Id: Ibe55e2dbec88211f553d8414e2b101075ee9d781
Merged-In: I7e5e92762e7f9b82b221277ef7e39acdaa935fbf
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 15818ec..571be34 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2927,18 +2927,19 @@
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
throw new IllegalArgumentException("Invalid Subscription ID: " + subId);
}
- Binder.withCleanCallingIdentity(() -> {
- try {
- // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
- .removeRegistrationCallbackForSubscription(c, subId);
- } catch (ImsException e) {
- Log.i(LOG_TAG, "unregisterImsRegistrationCallback: " + subId
- + "is inactive, ignoring unregister.");
- // If the subscription is no longer active, just return, since the callback
- // will already have been removed internally.
- }
- });
+ final long token = Binder.clearCallingIdentity();
+ try {
+ // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
+ ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ .removeRegistrationCallbackForSubscription(c, subId);
+ } catch (ImsException e) {
+ Log.i(LOG_TAG, "unregisterImsRegistrationCallback: " + subId
+ + "is inactive, ignoring unregister.");
+ // If the subscription is no longer active, just return, since the callback
+ // will already have been removed internally.
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
/**
@@ -3032,22 +3033,23 @@
@Override
public void unregisterMmTelCapabilityCallback(int subId, IImsCapabilityCallback c) {
enforceReadPrivilegedPermission("unregisterMmTelCapabilityCallback");
-
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
throw new IllegalArgumentException("Invalid Subscription ID: " + subId);
}
- Binder.withCleanCallingIdentity(() -> {
- try {
- // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+
+ final long token = Binder.clearCallingIdentity();
+ try {
+ // TODO: Refactor to remove ImsManager dependence and query through ImsPhone.
+ ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
.removeCapabilitiesCallbackForSubscription(c, subId);
- } catch (ImsException e) {
- Log.i(LOG_TAG, "unregisterMmTelCapabilityCallback: " + subId
- + "is inactive, ignoring unregister.");
- // If the subscription is no longer active, just return, since the callback
- // will already have been removed internally.
- }
- });
+ } catch (ImsException e) {
+ Log.i(LOG_TAG, "unregisterMmTelCapabilityCallback: " + subId
+ + "is inactive, ignoring unregister.");
+ // If the subscription is no longer active, just return, since the callback
+ // will already have been removed internally.
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
@Override