Merge "Resist SIM logical channel leaking when clients crash"
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 003b639..fdc1f1f 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -6788,6 +6788,10 @@
     @Override
     public int checkCarrierPrivilegesForPackageAnyPhone(String pkgName) {
         enforceReadPrivilegedPermission("checkCarrierPrivilegesForPackageAnyPhone");
+        return checkCarrierPrivilegesForPackageAnyPhoneWithPermission(pkgName);
+    }
+
+    private int checkCarrierPrivilegesForPackageAnyPhoneWithPermission(String pkgName) {
         if (TextUtils.isEmpty(pkgName)) {
             return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
         }
@@ -8683,7 +8687,7 @@
         } catch (SecurityException e) {
             // even without READ_PRIVILEGED_PHONE_STATE, we allow the call to continue if the caller
             // has carrier privileges on an active UICC
-            if (checkCarrierPrivilegesForPackageAnyPhone(callingPackage)
+            if (checkCarrierPrivilegesForPackageAnyPhoneWithPermission(callingPackage)
                         != TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
                 throw new SecurityException("Caller does not have permission.");
             }
@@ -8801,7 +8805,7 @@
         } catch (SecurityException e) {
             // even without READ_PRIVILEGED_PHONE_STATE, we allow the call to continue if the caller
             // has carrier privileges on an active UICC
-            if (checkCarrierPrivilegesForPackageAnyPhone(callingPackage)
+            if (checkCarrierPrivilegesForPackageAnyPhoneWithPermission(callingPackage)
                     == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
                 hasReadPermission = true;
             }