Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d81fc9d3 authored by Rambo Wang's avatar Rambo Wang Committed by Automerger Merge Worker
Browse files

Merge "Optimize TM#getCarrierServicePackageName[ForLogicalSlot]" am: 8ec6343d

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2039223

Change-Id: I5b54dc6e55469004fa53dc375e4dbf15ddb7c70c
parents 2e64dda5 8ec6343d
Loading
Loading
Loading
Loading
+10 −16
Original line number Original line Diff line number Diff line
@@ -9417,15 +9417,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;
    }
    }
    /**
    /**
@@ -9442,13 +9434,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;
    }
    }
+11 −0
Original line number Original line Diff line number Diff line
@@ -2545,4 +2545,15 @@ interface ITelephony {
     * registration technology specified, false if it is not required.
     * registration technology specified, false if it is not required.
     */
     */
    boolean isRcsProvisioningRequiredForCapability(int subId, int capability, int tech);
    boolean isRcsProvisioningRequiredForCapability(int subId, int capability, int tech);

    /**
     * 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);
}
}