Optimize TM#getCarrierServicePackageName[ForLogicalSlot]
Instead of querying package manager every time which is quite expensive, the new implementation will improve the performance by query the cache in CarrierPrivilegesTracker. Bug: 217442920 Test: atest CarrierPrivilegesTrackerTest Change-Id: I29df8599bdfc84cab330fa7056a228997a4bac0f
This commit is contained in:
@@ -9815,15 +9815,7 @@ public class TelephonyManager {
|
|||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||||
public @Nullable String getCarrierServicePackageName() {
|
public @Nullable String getCarrierServicePackageName() {
|
||||||
// TODO(b/205736323) plumb this through to CarrierPrivilegesTracker, which will cache the
|
return getCarrierServicePackageNameForLogicalSlot(getPhoneId());
|
||||||
// value instead of re-querying every time.
|
|
||||||
List<String> carrierServicePackages =
|
|
||||||
getCarrierPackageNamesForIntent(
|
|
||||||
new Intent(CarrierService.CARRIER_SERVICE_INTERFACE));
|
|
||||||
if (carrierServicePackages != null && !carrierServicePackages.isEmpty()) {
|
|
||||||
return carrierServicePackages.get(0);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9840,13 +9832,15 @@ public class TelephonyManager {
|
|||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||||
public @Nullable String getCarrierServicePackageNameForLogicalSlot(int logicalSlotIndex) {
|
public @Nullable String getCarrierServicePackageNameForLogicalSlot(int logicalSlotIndex) {
|
||||||
// TODO(b/205736323) plumb this through to CarrierPrivilegesTracker, which will cache the
|
try {
|
||||||
// value instead of re-querying every time.
|
ITelephony telephony = getITelephony();
|
||||||
List<String> carrierServicePackages =
|
if (telephony != null) {
|
||||||
getCarrierPackageNamesForIntentAndPhone(
|
return telephony.getCarrierServicePackageNameForLogicalSlot(logicalSlotIndex);
|
||||||
new Intent(CarrierService.CARRIER_SERVICE_INTERFACE), logicalSlotIndex);
|
}
|
||||||
if (carrierServicePackages != null && !carrierServicePackages.isEmpty()) {
|
} catch (RemoteException ex) {
|
||||||
return carrierServicePackages.get(0);
|
Rlog.e(TAG, "getCarrierServicePackageNameForLogicalSlot RemoteException", ex);
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
Rlog.e(TAG, "getCarrierServicePackageNameForLogicalSlot NPE", ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2541,4 +2541,15 @@ interface ITelephony {
|
|||||||
* PhoneAccount#CAPABILITY_VOICE_CALLING_AVAILABLE.
|
* PhoneAccount#CAPABILITY_VOICE_CALLING_AVAILABLE.
|
||||||
*/
|
*/
|
||||||
void setVoiceServiceStateOverride(int subId, boolean hasService, String callingPackage);
|
void setVoiceServiceStateOverride(int subId, boolean hasService, String callingPackage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the package name that provides the {@link CarrierService} implementation for the
|
||||||
|
* specified {@code logicalSlotIndex}, or {@code null} if no package with carrier privileges
|
||||||
|
* declares one.
|
||||||
|
*
|
||||||
|
* @param logicalSlotIndex The slot index to fetch the {@link CarrierService} package for
|
||||||
|
* @return The system-selected package that provides the {@link CarrierService} implementation
|
||||||
|
* for the slot, or {@code null} if none is resolved
|
||||||
|
*/
|
||||||
|
String getCarrierServicePackageNameForLogicalSlot(int logicalSlotIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user