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

Commit b3e07300 authored by Jeff Pu's avatar Jeff Pu Committed by Android (Google) Code Review
Browse files

Merge "Support lockscreen indication of being locked by watch disconnect" into main

parents cf320c95 f06eba79
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1713,7 +1713,8 @@ public class LockPatternUtils {
                        STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN,
                        STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT,
                        SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED,
                        SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST})
                        SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST,
                        SOME_AUTH_REQUIRED_AFTER_WATCH_DISCONNECTED})
        @Retention(RetentionPolicy.SOURCE)
        public @interface StrongAuthFlags {}

@@ -1782,6 +1783,12 @@ public class LockPatternUtils {
         */
        public static final int SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST = 0x200;

        /**
         * Some authentication is required because the associated watch was disconnected from the
         * device
         */
        public static final int SOME_AUTH_REQUIRED_AFTER_WATCH_DISCONNECTED = 0x400;

        /**
         * Strong auth flags that do not prevent biometric methods from being accepted as auth.
         * If any other flags are set, biometric authentication is disabled.
@@ -1789,7 +1796,8 @@ public class LockPatternUtils {
        private static final int ALLOWING_BIOMETRIC = STRONG_AUTH_NOT_REQUIRED
                | SOME_AUTH_REQUIRED_AFTER_USER_REQUEST
                | SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED
                | SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST;
                | SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST
                | SOME_AUTH_REQUIRED_AFTER_WATCH_DISCONNECTED;

        private final SparseIntArray mStrongAuthRequiredForUser = new SparseIntArray();
        private final H mHandler;
+8 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.deviceentry.domain.interactor.BiometricMessageInteractor;
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryBiometricSettingsInteractor;
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor;
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFingerprintAuthInteractor;
import com.android.systemui.dock.DockManager;
@@ -170,6 +171,9 @@ public class KeyguardIndicationControllerBaseTest extends SysuiTestCase {
    protected AlarmManager mAlarmManager;
    @Mock
    protected UserTracker mUserTracker;
    @Mock
    protected DeviceEntryBiometricSettingsInteractor mDeviceEntryBiometricSettingsInteractor;

    @Captor
    protected ArgumentCaptor<DockManager.AlignmentStateListener> mAlignmentListener;
    @Captor
@@ -257,6 +261,9 @@ public class KeyguardIndicationControllerBaseTest extends SysuiTestCase {

        mIndicationHelper = new IndicationHelper(mKeyguardUpdateMonitor);

        when(mDeviceEntryBiometricSettingsInteractor.getAuthenticationFlags())
                .thenReturn(mock(StateFlow.class));

        mWakeLock = new WakeLockFake();
        mWakeLockBuilder = new WakeLockFake.Builder(mContext);
        mWakeLockBuilder.setWakeLock(mWakeLock);
@@ -296,6 +303,7 @@ public class KeyguardIndicationControllerBaseTest extends SysuiTestCase {
                mock(BouncerMessageInteractor.class),
                mFlags,
                mIndicationHelper,
                mDeviceEntryBiometricSettingsInteractor,
                KeyguardInteractorFactory.create(mFlags).getKeyguardInteractor(),
                mBiometricMessageInteractor,
                mDeviceEntryFingerprintAuthInteractor,
+32 −0
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ import static android.view.View.VISIBLE;
import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_AVAILABLE;
import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_RECOGNIZED;
import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_HELP_FINGERPRINT_NOT_RECOGNIZED;
import static com.android.systemui.Flags.showLockedByYourWatchKeyguardIndicator;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_ADAPTIVE_AUTH;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_WATCH_DISCONNECTED;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_ALIGNMENT;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BATTERY;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BIOMETRIC_MESSAGE;
@@ -67,17 +69,21 @@ import android.hardware.biometrics.BiometricFingerprintConstants;
import android.hardware.biometrics.BiometricSourceType;
import android.os.BatteryManager;
import android.os.RemoteException;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;

import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.TrustGrantFlags;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.dock.DockManager;
import com.android.systemui.keyguard.KeyguardIndication;
import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController;
import com.android.systemui.Flags;
import com.android.systemui.keyguard.shared.model.AuthenticationFlags;
import com.android.systemui.res.R;

import org.junit.Test;
@@ -1597,6 +1603,32 @@ public class KeyguardIndicationControllerTest extends KeyguardIndicationControll
        verifyNoMessage(INDICATION_TYPE_ADAPTIVE_AUTH);
    }

    @Test
    @EnableFlags(Flags.FLAG_SHOW_LOCKED_BY_YOUR_WATCH_KEYGUARD_INDICATOR)
    public void updateWatchDisconnectedMessage_whenNotLockedWatchDisconnect_doesNotShowMsg() {
        createController();
        mController.setVisible(true);

        // Verify that the locked by your watch disconnect message does not show
        verifyNoMessage(INDICATION_TYPE_WATCH_DISCONNECTED);
    }

    @Test
    @EnableFlags(Flags.FLAG_SHOW_LOCKED_BY_YOUR_WATCH_KEYGUARD_INDICATOR)
    public void updateWatchDisconnectedMessage_whenLockedWatchDisconnect_noSkipBouncer_showsMsg() {
        assertTrue(showLockedByYourWatchKeyguardIndicator());
        when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(getCurrentUser())).thenReturn(false);
        createController();
        mController.mDeviceEntryBiometricSettingsInteractorCallback.accept(
                new AuthenticationFlags(mCurrentUserId,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_WATCH_DISCONNECTED));
        mController.setVisible(true);

        // Verify that the locked by your watch disconnect message shows
        String message = mContext.getString(R.string.keyguard_indication_after_watch_disconnected);
        verifyIndicationMessage(INDICATION_TYPE_WATCH_DISCONNECTED, message);
    }

    private void screenIsTurningOn() {
        when(mScreenLifecycle.getScreenState()).thenReturn(SCREEN_TURNING_ON);
    }
+3 −0
Original line number Diff line number Diff line
@@ -1741,6 +1741,9 @@
    <!-- Indication on the keyguard that appears after the device is locked by adaptive auth. [CHAR LIMIT=60] -->
    <string name="keyguard_indication_after_adaptive_auth_lock">Device locked\nFailed authentication</string>

    <!-- Indication on the keyguard that appears after the device is locked by adaptive auth. [CHAR LIMIT=60] -->
    <string name="keyguard_indication_after_watch_disconnected">Locked out by your watch</string>

    <!-- Accessibility string for current zen mode and selected exit condition. A template that simply concatenates existing mode string and the current condition description. [CHAR LIMIT=20] -->
    <string name="zen_mode_and_condition"><xliff:g id="zen_mode" example="Priority interruptions only">%1$s</xliff:g>. <xliff:g id="exit_condition" example="For one hour">%2$s</xliff:g></string>

+5 −1
Original line number Diff line number Diff line
@@ -402,6 +402,7 @@ public class KeyguardIndicationRotateTextViewController extends
    public static final int INDICATION_TYPE_BIOMETRIC_MESSAGE_FOLLOW_UP = 12;
    public static final int INDICATION_IS_DISMISSIBLE = 13;
    public static final int INDICATION_TYPE_ADAPTIVE_AUTH = 14;
    public static final int INDICATION_TYPE_WATCH_DISCONNECTED = 15;

    @IntDef({
            INDICATION_TYPE_NONE,
@@ -418,7 +419,8 @@ public class KeyguardIndicationRotateTextViewController extends
            INDICATION_TYPE_BIOMETRIC_MESSAGE,
            INDICATION_TYPE_BIOMETRIC_MESSAGE_FOLLOW_UP,
            INDICATION_IS_DISMISSIBLE,
            INDICATION_TYPE_ADAPTIVE_AUTH
            INDICATION_TYPE_ADAPTIVE_AUTH,
            INDICATION_TYPE_WATCH_DISCONNECTED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface IndicationType{}
@@ -456,6 +458,8 @@ public class KeyguardIndicationRotateTextViewController extends
                return "biometric_message_followup";
            case INDICATION_TYPE_ADAPTIVE_AUTH:
                return "adaptive_auth";
            case INDICATION_TYPE_WATCH_DISCONNECTED:
                return "watch_disconnected";
            default:
                return "unknown[" + type + "]";
        }
Loading