Move carrier privilege intent resolution to CarrierPrivilegesTracker.
These methods now use CarrierPrivilegesTracker as the source of truth,
and the Uicc{Port,Profile,CarrierPrivilegeRules} redundancies have been
removed.
This implicitly adds a caching layer that should result in noticeable
performance increases. While the PackageManager queries are still
per-call, we now have a caching layer that allows instantly determining
whether a resolved component has privileges, and we don't have to
perform redundant PackageManager queries to get that status.
Bug: 211796398
Test: atest com.android.internal.telephony.CarrierPrivilegesTrackerTest
Test: atest android.telephony.cts.TelephonyManagerTest
Change-Id: Idc7c2c434b78c1af62e89ef3b9eb48e4fa540d16
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 4182af1..f0f7731 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -6902,16 +6902,15 @@
@Override
public List<String> getCarrierPackageNamesForIntentAndPhone(Intent intent, int phoneId) {
enforceReadPrivilegedPermission("getCarrierPackageNamesForIntentAndPhone");
- if (!SubscriptionManager.isValidPhoneId(phoneId)) {
- loge("phoneId " + phoneId + " is not valid.");
- return null;
+ Phone phone = PhoneFactory.getPhone(phoneId);
+ if (phone == null) {
+ return Collections.emptyList();
}
- UiccPort port = UiccController.getInstance().getUiccPort(phoneId);
- if (port == null) {
- loge("getCarrierPackageNamesForIntentAndPhone: No UICC");
- return null ;
+ CarrierPrivilegesTracker cpt = phone.getCarrierPrivilegesTracker();
+ if (cpt == null) {
+ return Collections.emptyList();
}
- return port.getCarrierPackageNamesForIntent(mApp.getPackageManager(), intent);
+ return cpt.getCarrierPackageNamesForIntent(intent);
}
@Override