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

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

Merge "Move carrier privilege status checks to CarrierPrivilegesTracker." am:...

Merge "Move carrier privilege status checks to CarrierPrivilegesTracker." am: 7dee61c5 am: 638fbe7f

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2037466

Change-Id: Idb440fb9074ed3919d8b155270ea25133394c5f4
parents f258329d 638fbe7f
Loading
Loading
Loading
Loading
+58 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static android.telephony.TelephonyManager.SIM_STATE_UNKNOWN;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -48,6 +49,7 @@ import android.os.Registrant;
import android.os.RegistrantList;
import android.os.UserHandle;
import android.os.UserManager;
import android.telephony.Annotation.CarrierPrivilegeStatus;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -63,6 +65,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.uicc.UiccPort;
import com.android.internal.telephony.uicc.UiccProfile;
import com.android.internal.util.ArrayUtils;
import com.android.telephony.Rlog;

import java.io.FileDescriptor;
@@ -514,10 +517,13 @@ public class CarrierPrivilegesTracker extends Handler {
    }

    private void refreshInstalledPackageCache() {
        // Include DISABLED_UNTIL_USED components. This facilitates cases where a carrier app
        // is disabled by default, and some other component wants to enable it when it has
        // gained carrier privileges (as an indication that a matching SIM has been inserted).
        int flags =
                PackageManager.MATCH_DISABLED_COMPONENTS
                PackageManager.GET_SIGNING_CERTIFICATES
                        | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
                        | PackageManager.GET_SIGNING_CERTIFICATES;
                        | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS;
        List<PackageInfo> installedPackages =
                mPackageManager.getInstalledPackagesAsUser(
                        flags, UserHandle.SYSTEM.getIdentifier());
@@ -581,6 +587,11 @@ public class CarrierPrivilegesTracker extends Handler {
        } finally {
            mPrivilegedPackageInfoLock.readLock().unlock();
        }

        // Update set of enabled carrier apps now that the privilege rules may have changed.
        ActivityManager am = mContext.getSystemService(ActivityManager.class);
        CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(),
                mTelephonyManager, am.getCurrentUser(), mContext);
    }

    private PrivilegedPackageInfo getCurrentPrivilegedPackagesForAllUsers() {
@@ -730,7 +741,51 @@ public class CarrierPrivilegesTracker extends Handler {
            // best effort.
            refreshInstalledPackageCache();
        }

        maybeUpdatePrivilegedPackagesAndNotifyRegistrants();
    }

    /** Backing of {@link TelephonyManager#checkCarrierPrivilegesForPackage}. */
    public @CarrierPrivilegeStatus int getCarrierPrivilegeStatusForPackage(String packageName) {
        // TODO(b/205736323) consider if/how we want to account for the RULES_NOT_LOADED and
        // ERROR_LOADING_RULES constants. Technically those will never be returned today since those
        // results are only from the SIM rules, but the CC rules' result (which never has these
        // errors) always supersede them unless something goes super wrong when getting CC.
        mPrivilegedPackageInfoLock.readLock().lock();
        try {
            return mPrivilegedPackageInfo.mPackageNames.contains(packageName)
                    ? TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS
                    : TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
        } finally {
            mPrivilegedPackageInfoLock.readLock().unlock();
        }
    }

    /** Backing of {@link TelephonyManager#getPackagesWithCarrierPrivileges}. */
    public Set<String> getPackagesWithCarrierPrivileges() {
        mPrivilegedPackageInfoLock.readLock().lock();
        try {
            return Collections.unmodifiableSet(mPrivilegedPackageInfo.mPackageNames);
        } finally {
            mPrivilegedPackageInfoLock.readLock().unlock();
        }
    }

    /**
     * Backing of {@link TelephonyManager#hasCarrierPrivileges} and {@link
     * TelephonyManager#getCarrierPrivilegeStatus(int)}.
     */
    public @CarrierPrivilegeStatus int getCarrierPrivilegeStatusForUid(int uid) {
        // TODO(b/205736323) consider if/how we want to account for the RULES_NOT_LOADED and
        // ERROR_LOADING_RULES constants. Technically those will never be returned today since those
        // results are only from the SIM rules, but the CC rules' result (which never has these
        // errors) always supersede them unless something goes super wrong when getting CC.
        mPrivilegedPackageInfoLock.readLock().lock();
        try {
            return ArrayUtils.contains(mPrivilegedPackageInfo.mUids, uid)
                    ? TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS
                    : TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
        } finally {
            mPrivilegedPackageInfoLock.readLock().unlock();
        }
    }
}
+18 −6
Original line number Diff line number Diff line
@@ -365,8 +365,11 @@ public class UiccPort {

    /**
     * Exposes {@link UiccCarrierPrivilegeRules#getCarrierPrivilegeStatus}.
     * @deprecated Please use
     * {@link UiccProfile#getCarrierPrivilegeStatus(Signature, String)} instead.
     *
     * <p>TODO(b/205736323) remove this and downstream once fully moved to CarrierPrivilegesTracker
     *
     * @deprecated Please use {@link UiccProfile#getCarrierPrivilegeStatus(Signature, String)}
     *     instead.
     */
    @Deprecated
    public int getCarrierPrivilegeStatus(Signature signature, String packageName) {
@@ -379,8 +382,11 @@ public class UiccPort {

    /**
     * Exposes {@link UiccCarrierPrivilegeRules#getCarrierPrivilegeStatus}.
     * @deprecated Please use
     * {@link UiccProfile#getCarrierPrivilegeStatus(PackageManager, String)} instead.
     *
     * <p>TODO(b/205736323) remove this and downstream once fully moved to CarrierPrivilegesTracker
     *
     * @deprecated Please use {@link UiccProfile#getCarrierPrivilegeStatus(PackageManager, String)}
     *     instead.
     */
    @Deprecated
    public int getCarrierPrivilegeStatus(PackageManager packageManager, String packageName) {
@@ -393,6 +399,9 @@ public class UiccPort {

    /**
     * Exposes {@link UiccCarrierPrivilegeRules#getCarrierPrivilegeStatus}.
     *
     * <p>TODO(b/205736323) remove this and downstream once fully moved to CarrierPrivilegesTracker
     *
     * @deprecated Please use {@link UiccProfile#getCarrierPrivilegeStatus(PackageInfo)} instead.
     */
    @Deprecated
@@ -406,8 +415,11 @@ public class UiccPort {

    /**
     * Exposes {@link UiccCarrierPrivilegeRules#getCarrierPrivilegeStatusForCurrentTransaction}.
     * @deprecated Please use
     * {@link UiccProfile#getCarrierPrivilegeStatusForCurrentTransaction(PackageManager)} instead.
     *
     * <p>TODO(b/205736323) remove this and downstream once fully moved to CarrierPrivilegesTracker
     *
     * @deprecated Please use {@link
     *     UiccProfile#getCarrierPrivilegeStatusForCurrentTransaction(PackageManager)} instead.
     */
    @Deprecated
    public int getCarrierPrivilegeStatusForCurrentTransaction(PackageManager packageManager) {
+1 −0
Original line number Diff line number Diff line
@@ -1334,6 +1334,7 @@ public class UiccProfile extends IccCard {
    }

    private void onCarrierPrivilegesLoadedMessage() {
        // TODO(b/211796398): clean up logic below once all carrier privilege check migration done
        // Update set of enabled carrier apps now that the privilege rules may have changed.
        ActivityManager am = mContext.getSystemService(ActivityManager.class);
        CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(),
+46 −3
Original line number Diff line number Diff line
@@ -105,9 +105,9 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
    private static final int[] PRIVILEGED_UIDS = {UID_1, UID_2};

    private static final int PM_FLAGS =
            PackageManager.MATCH_DISABLED_COMPONENTS
            PackageManager.GET_SIGNING_CERTIFICATES
                    | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
                    | PackageManager.GET_SIGNING_CERTIFICATES;
                    | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS;

    @Mock private Signature mSignature;

@@ -257,6 +257,21 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        }
    }

    private void verifyCurrentState(Set<String> expectedPackageNames, int[] expectedUids) {
        assertEquals(
                expectedPackageNames, mCarrierPrivilegesTracker.getPackagesWithCarrierPrivileges());
        for (String packageName : expectedPackageNames) {
            assertEquals(
                    TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS,
                    mCarrierPrivilegesTracker.getCarrierPrivilegeStatusForPackage(packageName));
        }
        for (int uid : expectedUids) {
            assertEquals(
                    TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS,
                    mCarrierPrivilegesTracker.getCarrierPrivilegeStatusForUid(uid));
        }
    }

    private void verifyRegistrantUpdates(@Nullable int[] expectedUids, int expectedUidUpdates) {
        assertArrayEquals(expectedUids, mHandler.privilegedUids);
        assertEquals(expectedUidUpdates, mHandler.numUidUpdates);
@@ -291,8 +306,9 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
                mHandler, REGISTRANT_WHAT, null);
        mTestableLooper.processAllMessages();

        // No updates triggered, but the registrant gets an empty update.
        verifyCurrentState(Set.of(), new int[0]);
        verifyRegistrantUpdates(new int[0] /* expectedUids */, 1 /* expectedUidUpdates */);
        // No updates triggered, so TelephonyRegistry doesn't get any updates.
        verifyCarrierPrivilegesChangedUpdates(List.of());
    }

@@ -307,6 +323,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
                mHandler, REGISTRANT_WHAT, null);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS /* expectedUids */, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -316,6 +333,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        mCarrierPrivilegesTracker.unregisterCarrierPrivilegesListener(mHandler);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(null /* expectedUids */, 0 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(List.of());

@@ -323,6 +341,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendCarrierConfigChangedIntent(INVALID_SUBSCRIPTION_ID, PHONE_ID);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(), new int[0]);
        verifyRegistrantUpdates(null /* expectedUids */, 0 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(List.of(new Pair<>(Set.of(), new int[0])));
    }
@@ -340,6 +359,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendCarrierConfigChangedIntent(SUB_ID, PHONE_ID);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -353,6 +373,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendCarrierConfigChangedIntent(SUB_ID, PHONE_ID_INCORRECT);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(null /* expectedUids */, 0 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -366,6 +387,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendCarrierConfigChangedIntent(INVALID_SUBSCRIPTION_ID, PHONE_ID);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(), new int[0]);
        verifyRegistrantUpdates(new int[0] /* expectedUids */, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(
@@ -384,6 +406,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendCarrierConfigChangedIntent(SUB_ID, PHONE_ID);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(), new int[0]);
        verifyRegistrantUpdates(new int[0] /* expectedUids */, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(List.of(new Pair<>(Set.of(), new int[0])));
    }
@@ -403,6 +426,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendCarrierConfigChangedIntent(SUB_ID, PHONE_ID);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(PACKAGE_1), new int[] {UID_1});
        verifyRegistrantUpdates(new int[] {UID_1}, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(Set.of(PACKAGE_1), new int[] {UID_1})));
@@ -415,6 +439,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendCarrierConfigChangedIntent(SUB_ID, PHONE_ID);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 2 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -433,6 +458,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendSimCardStateChangedIntent(PHONE_ID, SIM_STATE_LOADED);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -451,6 +477,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendSimApplicationStateChangedIntent(PHONE_ID, SIM_STATE_LOADED);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -466,6 +493,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendSimCardStateChangedIntent(PHONE_ID, SIM_STATE_LOADED);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(), new int[0]);
        verifyRegistrantUpdates(new int[0], 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(
@@ -483,6 +511,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendSimCardStateChangedIntent(PHONE_ID_INCORRECT, SIM_STATE_LOADED);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(null /* expectedUids */, 0 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -496,6 +525,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendSimCardStateChangedIntent(PHONE_ID, SIM_STATE_NOT_READY);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(), new int[0]);
        verifyRegistrantUpdates(new int[0], 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(
@@ -518,6 +548,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendSimCardStateChangedIntent(PHONE_ID, SIM_STATE_LOADED);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(PACKAGE_1), new int[] {UID_1});
        verifyRegistrantUpdates(new int[] {UID_1}, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(Set.of(PACKAGE_1), new int[] {UID_1})));
@@ -531,6 +562,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendSimCardStateChangedIntent(PHONE_ID, SIM_STATE_LOADED);
        mTestableLooper.processAllMessages();

        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 2 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -547,6 +579,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendPackageChangedIntent(Intent.ACTION_PACKAGE_ADDED, PACKAGE_1);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(PACKAGE_1), new int[] {UID_1});
        verifyRegistrantUpdates(new int[] {UID_1}, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(Set.of(PACKAGE_1), new int[] {UID_1})));
@@ -566,6 +599,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendPackageChangedIntent(Intent.ACTION_PACKAGE_ADDED, PACKAGE_1);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(PACKAGE_1), PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(Set.of(PACKAGE_1), PRIVILEGED_UIDS)));
@@ -586,6 +620,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendPackageChangedIntent(Intent.ACTION_PACKAGE_REPLACED, PACKAGE_1);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(PACKAGE_1), PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(Set.of(PACKAGE_1), PRIVILEGED_UIDS)));
@@ -610,6 +645,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendPackageChangedIntent(Intent.ACTION_PACKAGE_ADDED, PACKAGE_1);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(PACKAGE_2), new int[] {UID_2});
        verifyRegistrantUpdates(new int[] {UID_2}, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(Set.of(PACKAGE_2), new int[] {UID_2})));
@@ -633,6 +669,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendPackageChangedIntent(Intent.ACTION_PACKAGE_ADDED, PACKAGE_1);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(PACKAGE_2), new int[] {UID_2});
        verifyRegistrantUpdates(new int[] {UID_2}, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(Set.of(PACKAGE_2), new int[] {UID_2})));
@@ -651,6 +688,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendPackageChangedIntent(Intent.ACTION_PACKAGE_REMOVED, PACKAGE_1);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(PACKAGE_2), new int[] {UID_2});
        verifyRegistrantUpdates(new int[] {UID_2}, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(Set.of(PACKAGE_2), new int[] {UID_2})));
@@ -665,6 +703,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        sendPackageChangedIntent(Intent.ACTION_PACKAGE_REMOVED, PACKAGE_1);
        mTestableLooper.processAllMessages();

        verifyCurrentState(Set.of(), new int[0]);
        verifyRegistrantUpdates(null /* expectedUidUpdates */, 0 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(List.of());
    }
@@ -679,6 +718,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        mTestableLooper.processAllMessages();

        // Expect no package will have privilege at last
        verifyCurrentState(Set.of(), new int[0]);
        verifyRegistrantUpdates(new int[0], 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(
@@ -690,6 +730,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        mTestableLooper.processAllMessages();

        // Expect all privileges from Carrier Config come back
        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 2 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));
@@ -705,6 +746,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        mTestableLooper.processAllMessages();

        // Expect only PACKAGE_3 will have privilege at last
        verifyCurrentState(Set.of(PACKAGE_3), new int[]{UID_3});
        verifyRegistrantUpdates(new int[]{UID_3}, 1 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(
@@ -717,6 +759,7 @@ public class CarrierPrivilegesTrackerTest extends TelephonyTest {
        mTestableLooper.processAllMessages();

        // Expect all privileges from UICC come back
        verifyCurrentState(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS);
        verifyRegistrantUpdates(PRIVILEGED_UIDS, 2 /* expectedUidUpdates */);
        verifyCarrierPrivilegesChangedUpdates(
                List.of(new Pair<>(PRIVILEGED_PACKAGES, PRIVILEGED_UIDS)));