diff options
| author | 2022-03-18 16:43:43 +0000 | |
|---|---|---|
| committer | 2022-03-18 16:43:43 +0000 | |
| commit | ff5b1369dd42979947e2b69009ef54520f90ef7e (patch) | |
| tree | b0c30a731efee298f3f969c3350f805e3fbd4a57 | |
| parent | 7f35502d83fac714e9a23c002b380c550829a1ba (diff) | |
| parent | 28b2ee8ec0314c1f77d92017de24c0d3df003aff (diff) | |
Merge "Optimize TM#getCarrierServicePackageName[ForLogicalSlot]" into tm-dev
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 26 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 11 |
2 files changed, 21 insertions, 16 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 3f430ab77df4..f3139a70eade 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -9815,15 +9815,7 @@ public class TelephonyManager { @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public @Nullable String getCarrierServicePackageName() { - // TODO(b/205736323) plumb this through to CarrierPrivilegesTracker, which will cache the - // 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; + return getCarrierServicePackageNameForLogicalSlot(getPhoneId()); } /** @@ -9840,13 +9832,15 @@ public class TelephonyManager { @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public @Nullable String getCarrierServicePackageNameForLogicalSlot(int logicalSlotIndex) { - // TODO(b/205736323) plumb this through to CarrierPrivilegesTracker, which will cache the - // value instead of re-querying every time. - List<String> carrierServicePackages = - getCarrierPackageNamesForIntentAndPhone( - new Intent(CarrierService.CARRIER_SERVICE_INTERFACE), logicalSlotIndex); - if (carrierServicePackages != null && !carrierServicePackages.isEmpty()) { - return carrierServicePackages.get(0); + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.getCarrierServicePackageNameForLogicalSlot(logicalSlotIndex); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "getCarrierServicePackageNameForLogicalSlot RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "getCarrierServicePackageNameForLogicalSlot NPE", ex); } return null; } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index a5e2c1f83939..e3ebb9a23950 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -2541,4 +2541,15 @@ interface ITelephony { * PhoneAccount#CAPABILITY_VOICE_CALLING_AVAILABLE. */ 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); } |