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

Commit 22540a73 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Remove sim_pin_use_slot_id flag" into main

parents e4f4ac59 fc663014
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -1468,16 +1468,6 @@ flag {
   }
}

flag {
   name: "sim_pin_use_slot_id"
   namespace: "systemui"
   description: "Reorient SIM data processing around slotId instead of subId"
   bug: "376173142"
   metadata {
        purpose: PURPOSE_BUGFIX
   }
}

flag {
   name: "classic_flags_multi_user"
   namespace: "systemui"
+4 −5
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import junit.framework.Assert.assertTrue
import kotlin.test.Test
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -117,7 +116,7 @@ class OperatorNameViewControllerTest : SysuiTestCase() {
                }
            whenever(keyguardUpdateMonitor.getSubscriptionInfoForSubId(any()))
                .thenReturn(mockSubInfo)
            whenever(keyguardUpdateMonitor.getSimState(any()))
            whenever(keyguardUpdateMonitor.getSimStateForSlotId(any()))
                .thenReturn(TelephonyManager.SIM_STATE_READY)
            whenever(keyguardUpdateMonitor.getServiceState(any()))
                .thenReturn(ServiceState().also { it.state = ServiceState.STATE_IN_SERVICE })
@@ -142,7 +141,7 @@ class OperatorNameViewControllerTest : SysuiTestCase() {
                }
            whenever(keyguardUpdateMonitor.getSubscriptionInfoForSubId(any()))
                .thenReturn(mockSubInfo)
            whenever(keyguardUpdateMonitor.getSimState(any()))
            whenever(keyguardUpdateMonitor.getSimStateForSlotId(any()))
                .thenReturn(TelephonyManager.SIM_STATE_READY)
            whenever(keyguardUpdateMonitor.getServiceState(any()))
                .thenReturn(ServiceState().also { it.state = ServiceState.STATE_IN_SERVICE })
@@ -166,7 +165,7 @@ class OperatorNameViewControllerTest : SysuiTestCase() {
                }
            whenever(keyguardUpdateMonitor.getSubscriptionInfoForSubId(any()))
                .thenReturn(mockSubInfo)
            whenever(keyguardUpdateMonitor.getSimState(any()))
            whenever(keyguardUpdateMonitor.getSimStateForSlotId(any()))
                .thenReturn(TelephonyManager.SIM_STATE_READY)
            whenever(keyguardUpdateMonitor.getServiceState(any()))
                .thenReturn(ServiceState().also { it.state = ServiceState.STATE_IN_SERVICE })
@@ -193,7 +192,7 @@ class OperatorNameViewControllerTest : SysuiTestCase() {
                }
            whenever(keyguardUpdateMonitor.getSubscriptionInfoForSubId(any()))
                .thenReturn(mockSubInfo)
            whenever(keyguardUpdateMonitor.getSimState(any()))
            whenever(keyguardUpdateMonitor.getSimStateForSlotId(any()))
                .thenReturn(TelephonyManager.SIM_STATE_READY)

            // Not in service
+1 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.keyguard;

import static com.android.systemui.Flags.simPinUseSlotId;
import static com.android.keyguard.logging.CarrierTextManagerLogger.REASON_ACTIVE_DATA_SUB_CHANGED;
import static com.android.keyguard.logging.CarrierTextManagerLogger.REASON_ON_TELEPHONY_CAPABLE;
import static com.android.keyguard.logging.CarrierTextManagerLogger.REASON_REFRESH_CARRIER_INFO;
@@ -373,8 +372,7 @@ public class CarrierTextManager {
            carrierNames[i] = "";
            subsIds[i] = subId;
            subOrderBySlot[slotId] = i;
            int simState = simPinUseSlotId() ? mKeyguardUpdateMonitor.getSimStateForSlotId(slotId)
                    :  mKeyguardUpdateMonitor.getSimState(subId);
            int simState = mKeyguardUpdateMonitor.getSimStateForSlotId(slotId);
            CharSequence carrierName = subs.get(i).getCarrierName();
            CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
            mLogger.logUpdateLoopStart(subId, simState, String.valueOf(carrierName));
+14 −86
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.android.systemui.Flags.fingerprintCancelRaceMitigation;
import static com.android.systemui.Flags.glanceableHubV2;
import static com.android.systemui.Flags.simPinBouncerReset;
import static com.android.systemui.Flags.simPinUseSlotId;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_OPENED;

import android.annotation.AnyThread;
@@ -320,7 +319,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
    private final FaceWakeUpTriggersConfig mFaceWakeUpTriggersConfig;

    private final Object mSimDataLockObject = new Object();
    HashMap<Integer, SimData> mSimDatas = new HashMap<>();
    HashMap<Integer, SimData> mSimDatasBySlotId = new HashMap<>();
    HashMap<Integer, ServiceState> mServiceStates = new HashMap<>();

@@ -628,9 +626,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
                // It is possible for active subscriptions to become invalid (-1), and these will
                // not be present in the subscriptionInfo list
                synchronized (mSimDataLockObject) {
                    var iter = simPinUseSlotId() ? mSimDatasBySlotId.entrySet().iterator()
                            : mSimDatas.entrySet().iterator();

                    var iter = mSimDatasBySlotId.entrySet().iterator();
                    while (iter.hasNext()) {
                        SimData data = iter.next().getValue();
                        if (!activeSubIds.contains(data.subId)) {
@@ -647,13 +643,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
                    }

                    for (int i = 0; i < changedSubscriptions.size(); i++) {
                        SimData data;
                        if (simPinUseSlotId()) {
                            data = mSimDatasBySlotId.get(changedSubscriptions.get(i)
                        SimData data = mSimDatasBySlotId.get(changedSubscriptions.get(i)
                                .getSimSlotIndex());
                        } else {
                            data = mSimDatas.get(changedSubscriptions.get(i).getSubscriptionId());
                        }
                        if (data == null) {
                            Log.w(TAG, "Null SimData for subscription: "
                                    + changedSubscriptions.get(i));
@@ -3483,27 +3474,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
        }
    }

    /**
     * Removes all valid subscription info from the map for the given slotId.
     */
    private void invalidateSlot(int slotId) {
        if (simPinUseSlotId()) {
            return;
        }
        synchronized (mSimDataLockObject) {
            var iter = simPinUseSlotId() ? mSimDatasBySlotId.entrySet().iterator()
                    : mSimDatas.entrySet().iterator();
            while (iter.hasNext()) {
                SimData data = iter.next().getValue();
                if (data.slotId == slotId
                        && SubscriptionManager.isValidSubscriptionId(data.subId)) {
                    mSimLogger.logInvalidSubId(data.subId, data.slotId);
                    iter.remove();
                }
            }
        }
    }

    /**
     * Handle {@link #MSG_SIM_STATE_CHANGE}
     */
@@ -3521,20 +3491,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
                    || state == TelephonyManager.SIM_STATE_CARD_IO_ERROR) {
                updateTelephonyCapable(true);
            }
            invalidateSlot(slotId);
        }

        // TODO(b/327476182): Preserve SIM_STATE_CARD_IO_ERROR sims in a separate data source.
        synchronized (mSimDataLockObject) {
            SimData data = simPinUseSlotId() ? mSimDatasBySlotId.get(slotId) : mSimDatas.get(subId);
            SimData data = mSimDatasBySlotId.get(slotId);
            final boolean changed;
            if (data == null) {
                data = new SimData(state, slotId, subId);
                if (simPinUseSlotId()) {
                mSimDatasBySlotId.put(slotId, data);
                } else {
                    mSimDatas.put(subId, data);
                }
                changed = true; // no data yet; force update
            } else {
                changed = (data.simState != state || data.subId != subId || data.slotId != slotId);
@@ -3813,8 +3778,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
        callback.onTelephonyCapable(mTelephonyCapable);

        synchronized (mSimDataLockObject) {
            var simDatas = simPinUseSlotId() ? mSimDatasBySlotId : mSimDatas;
            for (Entry<Integer, SimData> data : simDatas.entrySet()) {
            for (Entry<Integer, SimData> data : mSimDatasBySlotId.entrySet()) {
                final SimData state = data.getValue();
                callback.onSimStateChanged(state.subId, state.slotId, state.simState);
            }
@@ -3943,8 +3907,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
     */
    public boolean isSimPinSecure() {
        synchronized (mSimDataLockObject) {
            var simDatas = simPinUseSlotId() ? mSimDatasBySlotId : mSimDatas;
            for (SimData data : simDatas.values()) {
            for (SimData data : mSimDatasBySlotId.values()) {
                if (isSimPinSecure(data.simState)) {
                    return true;
                }
@@ -3953,28 +3916,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
        }
    }

    public int getSimState(int subId) {
        if (simPinUseSlotId()) {
            throw new UnsupportedOperationException("Method not supported with flag "
                    + "simPinUseSlotId");
        }
        synchronized (mSimDataLockObject) {
            if (mSimDatas.containsKey(subId)) {
                return mSimDatas.get(subId).simState;
            } else {
                return TelephonyManager.SIM_STATE_UNKNOWN;
            }
        }
    }

    /**
     * Find the sim state for a slot id, or SIM_STATE_UNKNOWN if not found.
     */
    public int getSimStateForSlotId(int slotId) {
        if (!simPinUseSlotId()) {
            throw new UnsupportedOperationException("Method not supported without flag "
                    + "simPinUseSlotId");
        }
        synchronized (mSimDataLockObject) {
            if (mSimDatasBySlotId.containsKey(slotId)) {
                return mSimDatasBySlotId.get(slotId).simState;
@@ -3986,13 +3931,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt

    private int getSlotId(int subId) {
        synchronized (mSimDataLockObject) {
            var simDatas = simPinUseSlotId() ? mSimDatasBySlotId : mSimDatas;
            int slotId = SubscriptionManager.getSlotIndex(subId);
            int index = simPinUseSlotId() ? slotId : subId;
            if (!simDatas.containsKey(index)) {
            if (!mSimDatasBySlotId.containsKey(slotId)) {
                refreshSimState(subId, slotId);
            }
            SimData simData = simDatas.get(index);
            SimData simData = mSimDatasBySlotId.get(slotId);
            return simData != null ? simData.slotId : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        }
    }
@@ -4036,19 +3979,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
    private boolean refreshSimState(int subId, int slotId) {
        int state = mTelephonyManager.getSimState(slotId);
        synchronized (mSimDataLockObject) {
            if (!SubscriptionManager.isValidSubscriptionId(subId)) {
                invalidateSlot(slotId);
            }
            SimData data = simPinUseSlotId() ? mSimDatasBySlotId.get(slotId) : mSimDatas.get(subId);

            SimData data = mSimDatasBySlotId.get(slotId);
            final boolean changed;
            if (data == null) {
                data = new SimData(state, slotId, subId);
                if (simPinUseSlotId()) {
                mSimDatasBySlotId.put(slotId, data);
                } else {
                    mSimDatas.put(subId, data);
                }
                changed = true; // no data yet; force update
            } else {
                changed = data.simState != state;
@@ -4145,17 +4080,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
            final SubscriptionInfo info = list.get(i);
            final int id = info.getSubscriptionId();
            final int slotId = info.getSimSlotIndex();
            if (simPinUseSlotId()) {
            if (state == getSimStateForSlotId(slotId) && bestSlotId > slotId) {
                resultId = id;
                bestSlotId = slotId;
            }
            } else {
                if (state == getSimState(id) && bestSlotId > slotId) {
                    resultId = id;
                    bestSlotId = slotId;
                }
            }
        }
        return resultId;
    }
@@ -4229,7 +4157,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, CoreSt
        pw.println("  getUserUnlockedWithBiometric()="
                + getUserUnlockedWithBiometric(mSelectedUserInteractor.getSelectedUserId()));
        pw.println("  SIM States:");
        for (SimData data : mSimDatas.values()) {
        for (SimData data : mSimDatasBySlotId.values()) {
            pw.println("    " + data.toString());
        }
        pw.println("  Subs:");
+1 −1
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class OperatorNameViewController extends ViewController<OperatorNameView>
        return new SubInfo(
                sI.getSubscriptionId(),
                sI.getCarrierName(),
                mKeyguardUpdateMonitor.getSimState(defaultSubId),
                mKeyguardUpdateMonitor.getSimStateForSlotId(sI.getSimSlotIndex()),
                mKeyguardUpdateMonitor.getServiceState(defaultSubId));
    }

Loading