Move getDataServicePackages to after clearCallingIdentity
getDataServicePackages invokes another API call through
CarrierConfigManager which tries to do another permission check. In
order to avoid a package-name/UID mismatch for the second permission
check, we need to clear the calling identity so the UID matches
com.android.phone.
Bug: 173515503
Test: atest CarrierConfigManagerTest
atest TelephonyLocationTests
atest SignalStrengthTest
atest <any CTS which calls TM#getServiceStateForSubscriber>
Change-Id: I9c627637289205cdc2b88a6f2276ea07f20d0c52
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 48b8fa5..e82ca75 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -7191,10 +7191,10 @@
return null;
}
+ final long identity = Binder.clearCallingIdentity();
+
boolean isCallingPackageDataService = phone.getDataServicePackages()
.contains(callingPackage);
-
- final long identity = Binder.clearCallingIdentity();
try {
// isActiveSubId requires READ_PHONE_STATE, which we already check for above
if (!mSubscriptionController.isActiveSubId(subId, callingPackage, callingFeatureId)) {