Clear and restore callingIdentity for getSubscriberId
to be able to call isActiveSubId with permission checks
Bug: 136062407
Test: ran failing cts test module CtsAppSecurityHostTestCases
Change-Id: I1b64b985aac1eccb489d2205da3b3bcaea3d2509
diff --git a/src/java/com/android/internal/telephony/PhoneSubInfoController.java b/src/java/com/android/internal/telephony/PhoneSubInfoController.java
index d655468..c5b7eda 100644
--- a/src/java/com/android/internal/telephony/PhoneSubInfoController.java
+++ b/src/java/com/android/internal/telephony/PhoneSubInfoController.java
@@ -126,7 +126,14 @@
public String getSubscriberIdForSubscriber(int subId, String callingPackage) {
String message = "getSubscriberId";
- if (SubscriptionController.getInstance().isActiveSubId(subId, callingPackage)) {
+ long identity = Binder.clearCallingIdentity();
+ boolean isActive;
+ try {
+ isActive = SubscriptionController.getInstance().isActiveSubId(subId, callingPackage);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ if (isActive) {
return callPhoneMethodForSubIdWithReadSubscriberIdentifiersCheck(subId, callingPackage,
message, (phone) -> phone.getSubscriberId());
} else {
@@ -134,7 +141,7 @@
mContext, subId, callingPackage, message)) {
return null;
}
- final long identity = Binder.clearCallingIdentity();
+ identity = Binder.clearCallingIdentity();
try {
return SubscriptionController.getInstance().getImsiPrivileged(subId);
} finally {