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

Commit 7ee6d98b authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge "Add `enabledForCurrentUser` flow that provides the current state of the...

Merge "Add `enabledForCurrentUser` flow that provides the current state of the touch to unlock settings toggle" into main
parents 75ccaa14 2e9cb6c5
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -16,14 +16,20 @@
package com.android.systemui.biometrics

import android.hardware.biometrics.common.AuthenticateReason
import kotlinx.coroutines.flow.Flow

/** Provides the status of the interactive to auth feature. */
/**
 * Provides the status of the interactive to auth feature.
 *
 * This controls whether fingerprint authentication can be used to unlock the device any time versus
 * only when the device is interactive. This is controlled by the user through a settings toggle.
 */
interface FingerprintInteractiveToAuthProvider {
    /**
     * @param userId the user Id.
     * @return true if the InteractiveToAuthFeature is enabled, false if disabled.
     * Whether the setting is enabled for the current user. This is the opposite of the "Touch to
     * Unlock" settings toggle.
     */
    fun isEnabled(userId: Int): Boolean
    val enabledForCurrentUser: Flow<Boolean>

    /**
     * @param userId the user Id.
+5 −0
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags.REFACTOR_GETCURRENTUSER
import com.android.systemui.user.data.repository.UserRepository
import javax.inject.Inject
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map

/** Encapsulates business logic to interact the selected user */
@SysUISingleton
@@ -17,6 +19,9 @@ constructor(
    private val flags: FeatureFlagsClassic,
) {

    /** Flow providing the ID of the currently selected user. */
    val selectedUser = repository.selectedUserInfo.map { it.id }.distinctUntilChanged()

    /**
     * Returns the ID of the currently-selected user.
     *
+0 −30
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static android.hardware.biometrics.SensorProperties.STRENGTH_CONVENIENCE;
import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG;
import static android.hardware.face.FaceAuthenticateOptions.AUTHENTICATE_REASON_PRIMARY_BOUNCER_SHOWN;
import static android.hardware.face.FaceAuthenticateOptions.AUTHENTICATE_REASON_STARTED_WAKING_UP;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_POWER_BUTTON;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL;
import static android.telephony.SubscriptionManager.DATA_ROAMING_DISABLE;
import static android.telephony.SubscriptionManager.NAME_SOURCE_CARRIER_ID;
@@ -1690,35 +1689,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(true)).isEqualTo(true);
    }

    @Test
    public void listeningForSfps_whenGoingToSleep_ifRequireInteractiveToAuthDisabled()
            throws RemoteException {
        // GIVEN SFPS supported and enrolled
        final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
        props.add(createFingerprintSensorPropertiesInternal(TYPE_POWER_BUTTON,
                /* isClass3 */ true));
        when(mAuthController.getSfpsProps()).thenReturn(props);
        when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);

        // GIVEN Preconditions for sfps auth to run
        keyguardNotGoingAway();
        currentUserIsSystem();
        currentUserDoesNotHaveTrust();
        biometricsNotDisabledThroughDevicePolicyManager();
        biometricsEnabledForCurrentUser();
        userNotCurrentlySwitching();
        statusBarShadeIsLocked();

        // WHEN require interactive to auth is disabled & keyguard is going to sleep
        when(mInteractiveToAuthProvider.isEnabled(anyInt())).thenReturn(false);
        deviceGoingToSleep();

        mTestableLooper.processAllMessages();

        // THEN we should listen for sfps because screen on to auth is  disabled
        assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(false)).isTrue();
    }

    @Test
    public void testShouldNotListenForUdfps_whenTrustEnabled() {
        // GIVEN a "we should listen for udfps" state