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

Commit 61bd8de7 authored by Andreas Miko's avatar Andreas Miko
Browse files

Refactor now resolved classes away from getCurrentUser()

These refactors are almost without logic changes since the parent CLs
have resolved the dependency cycles that were previously occuring

Test: Refactored tests
Bug: b/303808405
Flag: b/305984787 - REFACTOR_GETCURRENTUSER (added in ag/25089323)
Change-Id: If7de1bc183f861d06b427d1005f64cbb1a046628
parent 14d4959c
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -33,11 +33,11 @@ import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_WAKE
import android.provider.Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS
import android.provider.Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD
import android.util.Log
import com.android.keyguard.KeyguardUpdateMonitor.getCurrentUser
import com.android.systemui.Dumpable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.settings.SecureSettings
import java.io.PrintWriter
import javax.inject.Inject
@@ -50,6 +50,7 @@ class ActiveUnlockConfig @Inject constructor(
    @Main private val handler: Handler,
    private val secureSettings: SecureSettings,
    private val contentResolver: ContentResolver,
    private val selectedUserInteractor: SelectedUserInteractor,
    dumpManager: DumpManager
) : Dumpable {

@@ -134,7 +135,7 @@ class ActiveUnlockConfig @Inject constructor(
                    )
            )

            onChange(true, ArrayList(), 0, getCurrentUser())
            onChange(true, ArrayList(), 0, selectedUserInteractor.getSelectedUserId())
        }

        private fun registerUri(uris: Collection<Uri>) {
@@ -153,29 +154,31 @@ class ActiveUnlockConfig @Inject constructor(
            flags: Int,
            userId: Int
        ) {
            if (getCurrentUser() != userId) {
            if (selectedUserInteractor.getSelectedUserId() != userId) {
                return
            }

            if (selfChange || uris.contains(wakeUri)) {
                requestActiveUnlockOnWakeup = secureSettings.getIntForUser(
                        ACTIVE_UNLOCK_ON_WAKE, 0, getCurrentUser()) == 1
                        ACTIVE_UNLOCK_ON_WAKE, 0, selectedUserInteractor.getSelectedUserId()) == 1
            }

            if (selfChange || uris.contains(unlockIntentUri)) {
                requestActiveUnlockOnUnlockIntent = secureSettings.getIntForUser(
                        ACTIVE_UNLOCK_ON_UNLOCK_INTENT, 0, getCurrentUser()) == 1
                        ACTIVE_UNLOCK_ON_UNLOCK_INTENT, 0,
                        selectedUserInteractor.getSelectedUserId()) == 1
            }

            if (selfChange || uris.contains(bioFailUri)) {
                requestActiveUnlockOnBioFail = secureSettings.getIntForUser(
                        ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, 0, getCurrentUser()) == 1
                        ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, 0,
                        selectedUserInteractor.getSelectedUserId()) == 1
            }

            if (selfChange || uris.contains(faceErrorsUri)) {
                processStringArray(
                        secureSettings.getStringForUser(ACTIVE_UNLOCK_ON_FACE_ERRORS,
                                getCurrentUser()),
                                selectedUserInteractor.getSelectedUserId()),
                        faceErrorsToTriggerBiometricFailOn,
                        setOf(FACE_ERROR_TIMEOUT))
            }
@@ -183,7 +186,7 @@ class ActiveUnlockConfig @Inject constructor(
            if (selfChange || uris.contains(faceAcquireInfoUri)) {
                processStringArray(
                        secureSettings.getStringForUser(ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO,
                                getCurrentUser()),
                                selectedUserInteractor.getSelectedUserId()),
                        faceAcquireInfoToTriggerBiometricFailOn,
                        emptySet())
            }
@@ -192,7 +195,7 @@ class ActiveUnlockConfig @Inject constructor(
                processStringArray(
                        secureSettings.getStringForUser(
                                ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED,
                                getCurrentUser()),
                                selectedUserInteractor.getSelectedUserId()),
                        onUnlockIntentWhenBiometricEnrolled,
                        setOf(BiometricType.NONE.intValue))
            }
@@ -201,7 +204,7 @@ class ActiveUnlockConfig @Inject constructor(
                processStringArray(
                    secureSettings.getStringForUser(
                        ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS,
                        getCurrentUser()),
                        selectedUserInteractor.getSelectedUserId()),
                    wakeupsConsideredUnlockIntents,
                    setOf(WAKE_REASON_UNFOLD_DEVICE))
            }
@@ -210,7 +213,7 @@ class ActiveUnlockConfig @Inject constructor(
                processStringArray(
                    secureSettings.getStringForUser(
                        ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD,
                        getCurrentUser()),
                        selectedUserInteractor.getSelectedUserId()),
                    wakeupsToForceDismissKeyguard,
                    setOf(WAKE_REASON_UNFOLD_DEVICE))
            }
@@ -316,7 +319,8 @@ class ActiveUnlockConfig @Inject constructor(
        keyguardUpdateMonitor?.let {
            val anyFaceEnrolled = it.isFaceEnrolled
            val anyFingerprintEnrolled =
                    it.getCachedIsUnlockWithFingerprintPossible(getCurrentUser())
                    it.getCachedIsUnlockWithFingerprintPossible(
                            selectedUserInteractor.getSelectedUserId())
            val udfpsEnrolled = it.isUdfpsEnrolled

            if (!anyFaceEnrolled && !anyFingerprintEnrolled) {
@@ -371,7 +375,8 @@ class ActiveUnlockConfig @Inject constructor(
                    "${shouldRequestActiveUnlockOnUnlockIntentFromBiometricEnrollment()}")
            pw.println("   faceEnrolled=${it.isFaceEnrolled}")
            pw.println("   fpEnrolled=${
                    it.getCachedIsUnlockWithFingerprintPossible(getCurrentUser())}")
                    it.getCachedIsUnlockWithFingerprintPossible(
                            selectedUserInteractor.getSelectedUserId())}")
            pw.println("   udfpsEnrolled=${it.isUdfpsEnrolled}")
        } ?: pw.println("   keyguardUpdateMonitor is uninitialized")
    }
+19 −15
Original line number Diff line number Diff line
@@ -28,17 +28,17 @@ import com.android.internal.app.IVisualQueryRecognitionStatusListener;
import com.android.internal.app.IVoiceInteractionSessionListener;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.res.R;
import com.android.systemui.assist.ui.DefaultUiController;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.model.SysUiState;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.res.R;
import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
import com.android.systemui.util.settings.SecureSettings;

import dagger.Lazy;
@@ -144,6 +144,7 @@ public class AssistManager {
    private final UserTracker mUserTracker;
    private final DisplayTracker mDisplayTracker;
    private final SecureSettings mSecureSettings;
    private final SelectedUserInteractor mSelectedUserInteractor;

    private final DeviceProvisionedController mDeviceProvisionedController;

@@ -183,7 +184,8 @@ public class AssistManager {
            @Main Handler uiHandler,
            UserTracker userTracker,
            DisplayTracker displayTracker,
            SecureSettings secureSettings) {
            SecureSettings secureSettings,
            SelectedUserInteractor selectedUserInteractor) {
        mContext = context;
        mDeviceProvisionedController = controller;
        mCommandQueue = commandQueue;
@@ -195,6 +197,7 @@ public class AssistManager {
        mUserTracker = userTracker;
        mDisplayTracker = displayTracker;
        mSecureSettings = secureSettings;
        mSelectedUserInteractor = selectedUserInteractor;

        registerVoiceInteractionSessionListener();
        registerVisualQueryRecognitionStatusListener();
@@ -321,7 +324,8 @@ public class AssistManager {

    /**
     * @param invocationTypes The invocation types that will henceforth be handled via
     *         OverviewProxy (Launcher); other invocation types should be handled by this class.
     *                        OverviewProxy (Launcher); other invocation types should be handled by
     *                        this class.
     */
    public void setAssistantOverridesRequested(int[] invocationTypes) {
        mAssistOverrideInvocationTypes = invocationTypes;
@@ -478,7 +482,7 @@ public class AssistManager {

    @Nullable
    private ComponentName getAssistInfo() {
        return getAssistInfoForUser(KeyguardUpdateMonitor.getCurrentUser());
        return getAssistInfoForUser(mSelectedUserInteractor.getSelectedUserId());
    }

    public void showDisclosure() {
+3 −3
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum
    private final Context mContext;
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final LockPatternUtils mLockPatternUtils;
    private final Lazy<SelectedUserInteractor> mUserInteractor;
    private final SelectedUserInteractor mUserInteractor;
    private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback =
            new UpdateMonitorCallback();
    private final Lazy<KeyguardUnlockAnimationController> mUnlockAnimationControllerLazy;
@@ -123,7 +123,7 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum
            KeyguardUpdateMonitorLogger logger,
            DumpManager dumpManager,
            FeatureFlags featureFlags,
            Lazy<SelectedUserInteractor> userInteractor) {
            SelectedUserInteractor userInteractor) {
        mContext = context;
        mLogger = logger;
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
@@ -254,7 +254,7 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum
    @VisibleForTesting
    void update(boolean updateAlways) {
        Trace.beginSection("KeyguardStateController#update");
        int user = KeyguardUpdateMonitor.getCurrentUser();
        int user = mUserInteractor.getSelectedUserId();
        boolean secure = mLockPatternUtils.isSecure(user);
        boolean canDismissLockScreen = !secure || mKeyguardUpdateMonitor.getUserCanSkipBouncer(user)
                || (Build.IS_DEBUGGABLE && DEBUG_AUTH_WITH_ADB && mDebugUnlocked);
+208 −130

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class KeyguardStateControllerTest extends SysuiTestCase {
    @Mock
    private Lazy<KeyguardUnlockAnimationController> mKeyguardUnlockAnimationControllerLazy;
    @Mock
    private Lazy<SelectedUserInteractor> mUserInteractorLazy;
    private SelectedUserInteractor mSelectedUserInteractor;
    @Mock
    private KeyguardUpdateMonitorLogger mLogger;
    @Mock
@@ -88,7 +88,7 @@ public class KeyguardStateControllerTest extends SysuiTestCase {
                mLogger,
                mDumpManager,
                mFeatureFlags,
                mUserInteractorLazy);
                mSelectedUserInteractor);
    }

    @Test