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

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

Merge changes from topic "mpietal_users" into main

* changes:
  Fix user switching race condition on boot
  Reset keyguard/bouncer on sim NOT_READY
parents e6a46578 7db6873b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1312,6 +1312,16 @@ flag {
   }
}

flag {
   name: "sim_pin_bouncer_reset"
   namespace: "systemui"
   description: "The SIM PIN bouncer does not close after unlocking"
   bug: "297461589"
   metadata {
        purpose: PURPOSE_BUGFIX
   }
}

flag {
   name: "use_transitions_for_keyguard_occluded"
   namespace: "systemui"
+0 −1
Original line number Diff line number Diff line
@@ -28,5 +28,4 @@ public class KeyguardConstants {
     * be used temporarily for debugging.
     */
    public static final boolean DEBUG = Log.isLoggable("Keyguard", Log.DEBUG);
    public static final boolean DEBUG_SIM_STATES = true;
}
+9 −18
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ public class KeyguardSimPinViewController
        extends KeyguardPinBasedInputViewController<KeyguardSimPinView> {
    public static final String TAG = "KeyguardSimPinView";
    private static final String LOG_TAG = "KeyguardSimPinView";
    private static final boolean DEBUG = KeyguardConstants.DEBUG_SIM_STATES;
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final TelephonyManager mTelephonyManager;

@@ -71,7 +70,7 @@ public class KeyguardSimPinViewController
    KeyguardUpdateMonitorCallback mUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() {
        @Override
        public void onSimStateChanged(int subId, int slotId, int simState) {
            if (DEBUG) Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")");
            Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")");
            // If subId has gone to PUK required then we need to go to the PUK screen.
            if (subId == mSubId && simState == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
                getKeyguardSecurityCallback().showCurrentSecurityScreen();
@@ -129,7 +128,7 @@ public class KeyguardSimPinViewController
    @Override
    void resetState() {
        super.resetState();
        if (DEBUG) Log.v(TAG, "Resetting state");
        Log.v(TAG, "Resetting state");
        handleSubInfoChangeIfNeeded();
        mMessageAreaController.setMessage("");
        if (mShowDefaultMessage) {
@@ -216,12 +215,10 @@ public class KeyguardSimPinViewController
                                mMessageAreaController.setMessage(mView.getResources().getString(
                                        R.string.kg_password_pin_failed));
                            }
                            if (DEBUG) {
                            Log.d(LOG_TAG, "verifyPasswordAndUnlock "
                                    + " CheckSimPin.onSimCheckResponse: " + result
                                    + " attemptsRemaining=" + result.getAttemptsRemaining());
                        }
                        }
                        getKeyguardSecurityCallback().userActivity();
                        mCheckSimPinThread = null;
                    });
@@ -280,10 +277,8 @@ public class KeyguardSimPinViewController
            displayMessage = mView.getResources()
                    .getString(R.string.kg_sim_lock_esim_instructions, displayMessage);
        }
        if (DEBUG) {
        Log.d(LOG_TAG, "getPinPasswordErrorMessage: attemptsRemaining="
                + attemptsRemaining + " displayMessage=" + displayMessage);
        }
        return displayMessage;
    }

@@ -323,14 +318,10 @@ public class KeyguardSimPinViewController

        @Override
        public void run() {
            if (DEBUG) {
            Log.v(TAG, "call supplyIccLockPin(subid=" + mSubId + ")");
            }
            TelephonyManager telephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
            final PinResult result = telephonyManager.supplyIccLockPin(mPin);
            if (DEBUG) {
            Log.v(TAG, "supplyIccLockPin returned: " + result.toString());
            }
            mView.post(() -> onSimCheckResponse(result));
        }
    }
+17 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
import static com.android.systemui.Flags.simPinBouncerReset;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_OPENED;

import android.annotation.AnyThread;
@@ -1703,6 +1704,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                        intent.getStringExtra(Intent.EXTRA_SIM_STATE),
                        args.slotId,
                        args.subId);
                if (args.slotId == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
                    return;
                }
                mHandler.obtainMessage(MSG_SIM_STATE_CHANGE, args.subId, args.slotId, args.simState)
                        .sendToTarget();
            } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
@@ -1940,7 +1944,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            }
            int state = TelephonyManager.SIM_STATE_UNKNOWN;
            String stateExtra = intent.getStringExtra(Intent.EXTRA_SIM_STATE);
            int slotId = intent.getIntExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0);

            int defaultSlotId = 0;
            if (simPinBouncerReset()) {
                defaultSlotId = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
            }
            int slotId = intent.getIntExtra(SubscriptionManager.EXTRA_SLOT_INDEX,
                    defaultSlotId);
            int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
                    SubscriptionManager.INVALID_SUBSCRIPTION_ID);
            if (Intent.SIM_STATE_ABSENT.equals(stateExtra)) {
@@ -2479,6 +2489,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    this::onTransitionStateChanged
            );
        }

        // start() can be invoked in the middle of user switching, so check for this state and issue
        // the call manually as that important event was missed.
        if (mUserTracker.isUserSwitching()) {
            handleUserSwitching(mUserTracker.getUserId(), () -> {});
        }
    }

    @VisibleForTesting
+16 −40
Original line number Diff line number Diff line
@@ -54,29 +54,25 @@ class CustomizationProvider :
            addURI(
                Contract.AUTHORITY,
                Contract.LockScreenQuickAffordances.qualifiedTablePath(
                    Contract.LockScreenQuickAffordances.SlotTable.TABLE_NAME,
                    Contract.LockScreenQuickAffordances.SlotTable.TABLE_NAME
                ),
                MATCH_CODE_ALL_SLOTS,
            )
            addURI(
                Contract.AUTHORITY,
                Contract.LockScreenQuickAffordances.qualifiedTablePath(
                    Contract.LockScreenQuickAffordances.AffordanceTable.TABLE_NAME,
                    Contract.LockScreenQuickAffordances.AffordanceTable.TABLE_NAME
                ),
                MATCH_CODE_ALL_AFFORDANCES,
            )
            addURI(
                Contract.AUTHORITY,
                Contract.LockScreenQuickAffordances.qualifiedTablePath(
                    Contract.LockScreenQuickAffordances.SelectionTable.TABLE_NAME,
                    Contract.LockScreenQuickAffordances.SelectionTable.TABLE_NAME
                ),
                MATCH_CODE_ALL_SELECTIONS,
            )
            addURI(
                Contract.AUTHORITY,
                Contract.FlagsTable.TABLE_NAME,
                MATCH_CODE_ALL_FLAGS,
            )
            addURI(Contract.AUTHORITY, Contract.FlagsTable.TABLE_NAME, MATCH_CODE_ALL_FLAGS)
        }

    override fun onCreate(): Boolean {
@@ -106,15 +102,15 @@ class CustomizationProvider :
            when (uriMatcher.match(uri)) {
                MATCH_CODE_ALL_SLOTS ->
                    Contract.LockScreenQuickAffordances.qualifiedTablePath(
                        Contract.LockScreenQuickAffordances.SlotTable.TABLE_NAME,
                        Contract.LockScreenQuickAffordances.SlotTable.TABLE_NAME
                    )
                MATCH_CODE_ALL_AFFORDANCES ->
                    Contract.LockScreenQuickAffordances.qualifiedTablePath(
                        Contract.LockScreenQuickAffordances.AffordanceTable.TABLE_NAME,
                        Contract.LockScreenQuickAffordances.AffordanceTable.TABLE_NAME
                    )
                MATCH_CODE_ALL_SELECTIONS ->
                    Contract.LockScreenQuickAffordances.qualifiedTablePath(
                        Contract.LockScreenQuickAffordances.SelectionTable.TABLE_NAME,
                        Contract.LockScreenQuickAffordances.SelectionTable.TABLE_NAME
                    )
                MATCH_CODE_ALL_FLAGS -> Contract.FlagsTable.TABLE_NAME
                else -> null
@@ -128,6 +124,7 @@ class CustomizationProvider :
    }

    override fun insert(uri: Uri, values: ContentValues?): Uri? {
        if (!::mainDispatcher.isInitialized) return null
        if (uriMatcher.match(uri) != MATCH_CODE_ALL_SELECTIONS) {
            throw UnsupportedOperationException()
        }
@@ -142,6 +139,7 @@ class CustomizationProvider :
        selectionArgs: Array<out String>?,
        sortOrder: String?,
    ): Cursor? {
        if (!::mainDispatcher.isInitialized) return null
        return runBlocking("$TAG#query", mainDispatcher) {
            when (uriMatcher.match(uri)) {
                MATCH_CODE_ALL_AFFORDANCES -> queryAffordances()
@@ -163,11 +161,8 @@ class CustomizationProvider :
        return 0
    }

    override fun delete(
        uri: Uri,
        selection: String?,
        selectionArgs: Array<out String>?,
    ): Int {
    override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int {
        if (!::mainDispatcher.isInitialized) return 0
        if (uriMatcher.match(uri) != MATCH_CODE_ALL_SELECTIONS) {
            throw UnsupportedOperationException()
        }
@@ -232,11 +227,7 @@ class CustomizationProvider :
            throw IllegalArgumentException("Cannot insert selection, affordance ID was empty!")
        }

        val success =
            interactor.select(
                slotId = slotId,
                affordanceId = affordanceId,
            )
        val success = interactor.select(slotId = slotId, affordanceId = affordanceId)

        return if (success) {
            Log.d(TAG, "Successfully selected $affordanceId for slot $slotId")
@@ -318,22 +309,14 @@ class CustomizationProvider :
            )
            .apply {
                interactor.getSlotPickerRepresentations().forEach { representation ->
                    addRow(
                        arrayOf(
                            representation.id,
                            representation.maxSelectedAffordances,
                        )
                    )
                    addRow(arrayOf(representation.id, representation.maxSelectedAffordances))
                }
            }
    }

    private suspend fun queryFlags(): Cursor {
        return MatrixCursor(
                arrayOf(
                    Contract.FlagsTable.Columns.NAME,
                    Contract.FlagsTable.Columns.VALUE,
                )
                arrayOf(Contract.FlagsTable.Columns.NAME, Contract.FlagsTable.Columns.VALUE)
            )
            .apply {
                interactor.getPickerFlags().forEach { flag ->
@@ -351,10 +334,7 @@ class CustomizationProvider :
            }
    }

    private suspend fun deleteSelection(
        uri: Uri,
        selectionArgs: Array<out String>?,
    ): Int {
    private suspend fun deleteSelection(uri: Uri, selectionArgs: Array<out String>?): Int {
        if (selectionArgs == null) {
            throw IllegalArgumentException(
                "Cannot delete selection, selection arguments not included!"
@@ -372,11 +352,7 @@ class CustomizationProvider :
                    )
            }

        val deleted =
            interactor.unselect(
                slotId = slotId,
                affordanceId = affordanceId,
            )
        val deleted = interactor.unselect(slotId = slotId, affordanceId = affordanceId)

        return if (deleted) {
            Log.d(TAG, "Successfully unselected $affordanceId for slot $slotId")
Loading