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

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

Merge "Fix race condition when TelephonyRegistry handles multi-SIM config...

Merge "Fix race condition when TelephonyRegistry handles multi-SIM config change" into tm-dev am: 0817165a am: 3aeca773 am: 5e776643 am: 43dcaa91

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



Change-Id: I9fc20a27cbe00cd23f36521985abf7589a2aabef
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e1bb070c 43dcaa91
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -2812,6 +2812,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                            + " callback.asBinder=" + callback.asBinder());
        }

        // In case this is triggered from the caller who has handled multiple SIM config change
        // firstly, we need to update the status (mNumPhone and mCarrierPrivilegeStates) firstly.
        // This is almost a no-op if there is no multiple SIM config change in advance.
        onMultiSimConfigChanged();

        synchronized (mRecords) {
            if (!validatePhoneId(phoneId)) {
                throw new IllegalArgumentException("Invalid slot index: " + phoneId);
@@ -2874,6 +2879,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                            + ", <packages=" + pii(privilegedPackageNames)
                            + ", uids=" + Arrays.toString(privilegedUids) + ">");
        }

        // In case this is triggered from the caller who has handled multiple SIM config change
        // firstly, we need to update the status (mNumPhone and mCarrierPrivilegeStates) firstly.
        // This is almost a no-op if there is no multiple SIM config change in advance.
        onMultiSimConfigChanged();

        synchronized (mRecords) {
            if (!validatePhoneId(phoneId)) {
                throw new IllegalArgumentException("Invalid slot index: " + phoneId);
@@ -2909,6 +2920,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    + ", package=" + pii(packageName) + ", uid=" + uid);
        }

        // In case this is triggered from the caller who has handled multiple SIM config change
        // firstly, we need to update the status (mNumPhone and mCarrierServiceStates) firstly.
        // This is almost a no-op if there is no multiple SIM config change in advance.
        onMultiSimConfigChanged();

        synchronized (mRecords) {
            mCarrierServiceStates.set(
                    phoneId, new Pair<>(packageName, uid));
@@ -3374,7 +3390,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
    }

    private boolean validatePhoneId(int phoneId) {
        boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
        // Call getActiveModemCount to get the latest value instead of depending on mNumPhone
        boolean valid = (phoneId >= 0) && (phoneId < getTelephonyManager().getActiveModemCount());
        if (VDBG) log("validatePhoneId: " + valid);
        return valid;
    }