Merge "Add logic for when to start the Udfps fp service"
This commit is contained in:
@@ -238,6 +238,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
private final boolean mIsAutomotive;
|
||||
private final AuthController mAuthController;
|
||||
private final StatusBarStateController mStatusBarStateController;
|
||||
private int mStatusBarState;
|
||||
private final StatusBarStateController.StateListener mStatusBarStateControllerListener =
|
||||
new StatusBarStateController.StateListener() {
|
||||
@Override
|
||||
public void onStateChanged(int newState) {
|
||||
mStatusBarState = newState;
|
||||
updateBiometricListeningState();
|
||||
}
|
||||
};
|
||||
|
||||
HashMap<Integer, SimData> mSimDatas = new HashMap<>();
|
||||
HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();
|
||||
|
||||
@@ -247,7 +257,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
private boolean mCredentialAttempted;
|
||||
private boolean mKeyguardGoingAway;
|
||||
private boolean mGoingToSleep;
|
||||
private boolean mBouncer;
|
||||
private boolean mBouncer; // true if bouncerIsOrWillBeShowing
|
||||
private boolean mAuthInterruptActive;
|
||||
private boolean mNeedsSlowUnlockTransition;
|
||||
private boolean mHasLockscreenWallpaper;
|
||||
@@ -1595,6 +1605,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
mBroadcastDispatcher = broadcastDispatcher;
|
||||
mRingerModeTracker = ringerModeTracker;
|
||||
mStatusBarStateController = statusBarStateController;
|
||||
mStatusBarStateController.addCallback(mStatusBarStateControllerListener);
|
||||
mStatusBarState = mStatusBarStateController.getState();
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
mAuthController = authController;
|
||||
dumpManager.registerDumpable(getClass().getName(), this);
|
||||
@@ -1905,7 +1917,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
return;
|
||||
}
|
||||
|
||||
boolean shouldListenForFingerprint = shouldListenForFingerprint();
|
||||
boolean shouldListenForFingerprint =
|
||||
isUdfpsEnrolled() ? shouldListenForUdfps() : shouldListenForFingerprint();
|
||||
boolean runningOrRestarting = mFingerprintRunningState == BIOMETRIC_STATE_RUNNING
|
||||
|| mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING;
|
||||
if (runningOrRestarting && !shouldListenForFingerprint) {
|
||||
@@ -2002,12 +2015,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
return shouldListen;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean shouldListenForUdfps() {
|
||||
return shouldListenForFingerprint()
|
||||
&& !mBouncer
|
||||
&& mStatusBarState != StatusBarState.SHADE_LOCKED
|
||||
&& mStatusBarState != StatusBarState.FULLSCREEN_USER_SWITCHER
|
||||
&& mStrongAuthTracker.hasUserAuthenticatedSinceBoot();
|
||||
}
|
||||
|
||||
/**
|
||||
* If face auth is allows to scan on this exact moment.
|
||||
*/
|
||||
public boolean shouldListenForFace() {
|
||||
final boolean statusBarShadeLocked =
|
||||
mStatusBarStateController.getState() == StatusBarState.SHADE_LOCKED;
|
||||
final boolean statusBarShadeLocked = mStatusBarState == StatusBarState.SHADE_LOCKED;
|
||||
final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep
|
||||
&& !statusBarShadeLocked;
|
||||
final int user = getCurrentUser();
|
||||
@@ -2593,13 +2614,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
*
|
||||
* @see #sendKeyguardBouncerChanged(boolean)
|
||||
*/
|
||||
private void handleKeyguardBouncerChanged(int bouncer) {
|
||||
private void handleKeyguardBouncerChanged(int bouncerVisible) {
|
||||
Assert.isMainThread();
|
||||
if (DEBUG) Log.d(TAG, "handleKeyguardBouncerChanged(" + bouncer + ")");
|
||||
boolean isBouncer = (bouncer == 1);
|
||||
mBouncer = isBouncer;
|
||||
if (DEBUG) Log.d(TAG, "handleKeyguardBouncerChanged(" + bouncerVisible + ")");
|
||||
mBouncer = bouncerVisible == 1;
|
||||
|
||||
if (isBouncer) {
|
||||
if (mBouncer) {
|
||||
// If the bouncer is shown, always clear this flag. This can happen in the following
|
||||
// situations: 1) Default camera with SHOW_WHEN_LOCKED is not chosen yet. 2) Secure
|
||||
// camera requests dismiss keyguard (tapping on photos for example). When these happen,
|
||||
@@ -2612,7 +2632,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||
if (cb != null) {
|
||||
cb.onKeyguardBouncerChanged(isBouncer);
|
||||
cb.onKeyguardBouncerChanged(mBouncer);
|
||||
}
|
||||
}
|
||||
updateBiometricListeningState();
|
||||
@@ -2745,10 +2765,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
/**
|
||||
* @see #handleKeyguardBouncerChanged(int)
|
||||
*/
|
||||
public void sendKeyguardBouncerChanged(boolean showingBouncer) {
|
||||
if (DEBUG) Log.d(TAG, "sendKeyguardBouncerChanged(" + showingBouncer + ")");
|
||||
public void sendKeyguardBouncerChanged(boolean bouncerIsOrWillBeShowing) {
|
||||
if (DEBUG) Log.d(TAG, "sendKeyguardBouncerChanged(" + bouncerIsOrWillBeShowing + ")");
|
||||
Message message = mHandler.obtainMessage(MSG_KEYGUARD_BOUNCER_CHANGED);
|
||||
message.arg1 = showingBouncer ? 1 : 0;
|
||||
message.arg1 = bouncerIsOrWillBeShowing ? 1 : 0;
|
||||
message.sendToTarget();
|
||||
}
|
||||
|
||||
@@ -3081,6 +3101,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
pw.println(" strongAuthFlags=" + Integer.toHexString(strongAuthFlags));
|
||||
pw.println(" trustManaged=" + getUserTrustIsManaged(userId));
|
||||
pw.println(" udfpsEnrolled=" + isUdfpsEnrolled());
|
||||
if (isUdfpsEnrolled()) {
|
||||
pw.println(" shouldListenForUdfps=" + shouldListenForUdfps());
|
||||
pw.println(" bouncerVisible=" + mBouncer);
|
||||
pw.println(" mStatusBarState="
|
||||
+ StatusBarState.toShortString(mStatusBarState));
|
||||
}
|
||||
}
|
||||
if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
|
||||
final int userId = ActivityManager.getCurrentUser();
|
||||
|
||||
@@ -94,7 +94,8 @@ public class KeyguardUpdateMonitorCallback {
|
||||
|
||||
/**
|
||||
* Called when the keyguard enters or leaves bouncer mode.
|
||||
* @param bouncer if true, keyguard is now in bouncer mode.
|
||||
* @param bouncer if true, keyguard is showing the bouncer or transitioning from/to bouncer
|
||||
* mode.
|
||||
*/
|
||||
public void onKeyguardBouncerChanged(boolean bouncer) { }
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.doze.DozeReceiver;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.phone.KeyguardBouncer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -68,7 +67,7 @@ import javax.inject.Provider;
|
||||
*/
|
||||
@SysUISingleton
|
||||
public class AuthController extends SystemUI implements CommandQueue.Callbacks,
|
||||
AuthDialogCallback, DozeReceiver, KeyguardBouncer.BouncerExpansionCallback {
|
||||
AuthDialogCallback, DozeReceiver {
|
||||
|
||||
private static final String TAG = "AuthController";
|
||||
private static final boolean DEBUG = true;
|
||||
@@ -460,35 +459,6 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
|
||||
mCurrentDialog = null;
|
||||
}
|
||||
|
||||
/** See {@link KeyguardBouncer.BouncerExpansionCallback#onFullyShown}. */
|
||||
@Override
|
||||
public void onFullyShown() {
|
||||
if (mUdfpsController != null) {
|
||||
mUdfpsController.setBouncerVisibility(true);
|
||||
}
|
||||
}
|
||||
|
||||
/** See {@link KeyguardBouncer.BouncerExpansionCallback#onStartingToHide}. */
|
||||
@Override
|
||||
public void onStartingToHide() {
|
||||
}
|
||||
|
||||
/** See {@link KeyguardBouncer.BouncerExpansionCallback#onStartingToShow}. */
|
||||
@Override
|
||||
public void onStartingToShow() {
|
||||
if (mUdfpsController != null) {
|
||||
mUdfpsController.setBouncerVisibility(true);
|
||||
}
|
||||
}
|
||||
|
||||
/** See {@link KeyguardBouncer.BouncerExpansionCallback#onFullyHidden}. */
|
||||
@Override
|
||||
public void onFullyHidden() {
|
||||
if (mUdfpsController != null) {
|
||||
mUdfpsController.setBouncerVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the passed userId has enrolled UDFPS.
|
||||
*/
|
||||
|
||||
@@ -107,8 +107,6 @@ class UdfpsController implements DozeReceiver {
|
||||
private boolean mIsOverlayShowing;
|
||||
// Indicates whether the overlay has been requested.
|
||||
private boolean mIsOverlayRequested;
|
||||
// Indicates whether the bouncer is showing. When it is showing, the overlay needs to be hidden.
|
||||
private boolean mIsBouncerShowing;
|
||||
|
||||
// The fingerprint AOD trigger doesn't provide an ACTION_UP/ACTION_CANCEL event to tell us when
|
||||
// to turn off high brightness mode. To get around this limitation, the state of the AOD
|
||||
@@ -260,21 +258,8 @@ class UdfpsController implements DozeReceiver {
|
||||
updateOverlay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call when the visibility of the bouncer changes.
|
||||
*
|
||||
* @param isShowing Whether or not the bouncer is showing
|
||||
*/
|
||||
void setBouncerVisibility(boolean isShowing) {
|
||||
if (isShowing == mIsBouncerShowing) {
|
||||
return;
|
||||
}
|
||||
mIsBouncerShowing = isShowing;
|
||||
updateOverlay();
|
||||
}
|
||||
|
||||
private void updateOverlay() {
|
||||
if (mIsOverlayRequested && !mIsBouncerShowing) {
|
||||
if (mIsOverlayRequested) {
|
||||
showUdfpsOverlay();
|
||||
} else {
|
||||
hideUdfpsOverlay();
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
import com.android.keyguard.dagger.KeyguardBouncerComponent;
|
||||
import com.android.systemui.DejankUtils;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.dagger.qualifiers.RootView;
|
||||
import com.android.systemui.keyguard.DismissCallbackRegistry;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
@@ -70,7 +69,6 @@ public class KeyguardBouncer {
|
||||
private final DismissCallbackRegistry mDismissCallbackRegistry;
|
||||
private final Handler mHandler;
|
||||
private final List<BouncerExpansionCallback> mExpansionCallbacks = new ArrayList<>();
|
||||
private final AuthController mAuthController;
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private final KeyguardStateController mKeyguardStateController;
|
||||
private final KeyguardSecurityModel mKeyguardSecurityModel;
|
||||
@@ -104,7 +102,6 @@ public class KeyguardBouncer {
|
||||
ViewGroup container,
|
||||
DismissCallbackRegistry dismissCallbackRegistry, FalsingManager falsingManager,
|
||||
BouncerExpansionCallback expansionCallback,
|
||||
AuthController authController,
|
||||
KeyguardStateController keyguardStateController,
|
||||
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||
KeyguardBypassController keyguardBypassController, Handler handler,
|
||||
@@ -123,8 +120,6 @@ public class KeyguardBouncer {
|
||||
mKeyguardUpdateMonitor.registerCallback(mUpdateMonitorCallback);
|
||||
mKeyguardBypassController = keyguardBypassController;
|
||||
mExpansionCallbacks.add(expansionCallback);
|
||||
mExpansionCallbacks.add(authController);
|
||||
mAuthController = authController;
|
||||
}
|
||||
|
||||
public void show(boolean resetSecuritySelection) {
|
||||
@@ -297,11 +292,6 @@ public class KeyguardBouncer {
|
||||
mIsScrimmed = false;
|
||||
mFalsingManager.onBouncerHidden();
|
||||
mCallback.onBouncerVisiblityChanged(false /* shown */);
|
||||
// TODO(b/165257355): `mAuthController.onFullyHidden` should be `dispatchFullyHidden()`
|
||||
// But, it is causing the UDFPS icon to disappear after SystemUI restarts. I guess the
|
||||
// ExpansionCallback from StatusBarKeyguardViewManager can't handle the call to
|
||||
// onFullyHidden after a restart.
|
||||
mAuthController.onFullyHidden();
|
||||
cancelShowRunnable();
|
||||
if (mKeyguardViewController != null) {
|
||||
mKeyguardViewController.cancelDismissAction();
|
||||
@@ -552,7 +542,6 @@ public class KeyguardBouncer {
|
||||
private final ViewMediatorCallback mCallback;
|
||||
private final DismissCallbackRegistry mDismissCallbackRegistry;
|
||||
private final FalsingManager mFalsingManager;
|
||||
private final AuthController mAuthController;
|
||||
private final KeyguardStateController mKeyguardStateController;
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private final KeyguardBypassController mKeyguardBypassController;
|
||||
@@ -563,7 +552,6 @@ public class KeyguardBouncer {
|
||||
@Inject
|
||||
public Factory(Context context, ViewMediatorCallback callback,
|
||||
DismissCallbackRegistry dismissCallbackRegistry, FalsingManager falsingManager,
|
||||
AuthController authController,
|
||||
KeyguardStateController keyguardStateController,
|
||||
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||
KeyguardBypassController keyguardBypassController, Handler handler,
|
||||
@@ -573,7 +561,6 @@ public class KeyguardBouncer {
|
||||
mCallback = callback;
|
||||
mDismissCallbackRegistry = dismissCallbackRegistry;
|
||||
mFalsingManager = falsingManager;
|
||||
mAuthController = authController;
|
||||
mKeyguardStateController = keyguardStateController;
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
mKeyguardBypassController = keyguardBypassController;
|
||||
@@ -586,7 +573,7 @@ public class KeyguardBouncer {
|
||||
BouncerExpansionCallback expansionCallback) {
|
||||
return new KeyguardBouncer(mContext, mCallback, container,
|
||||
mDismissCallbackRegistry, mFalsingManager, expansionCallback,
|
||||
mAuthController, mKeyguardStateController, mKeyguardUpdateMonitor,
|
||||
mKeyguardStateController, mKeyguardUpdateMonitor,
|
||||
mKeyguardBypassController, mHandler, mKeyguardSecurityModel,
|
||||
mKeyguardBouncerComponentFactory);
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
|
||||
@Override
|
||||
public void onStartingToShow() {
|
||||
updateStates();
|
||||
updateLockIcon();
|
||||
}
|
||||
|
||||
@@ -164,6 +165,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
protected boolean mLastShowing;
|
||||
protected boolean mLastOccluded;
|
||||
private boolean mLastBouncerShowing;
|
||||
private boolean mLastBouncerIsOrWillBeShowing;
|
||||
private boolean mLastBouncerDismissible;
|
||||
protected boolean mLastRemoteInputActive;
|
||||
private boolean mLastDozing;
|
||||
@@ -811,6 +813,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
boolean showing = mShowing;
|
||||
boolean occluded = mOccluded;
|
||||
boolean bouncerShowing = mBouncer.isShowing();
|
||||
boolean bouncerIsOrWillBeShowing = bouncerIsOrWillBeShowing();
|
||||
boolean bouncerDismissible = !mBouncer.isFullscreenBouncer();
|
||||
boolean remoteInputActive = mRemoteInputActive;
|
||||
|
||||
@@ -839,8 +842,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) {
|
||||
mKeyguardUpdateManager.onKeyguardVisibilityChanged(showing && !occluded);
|
||||
}
|
||||
if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) {
|
||||
mKeyguardUpdateManager.sendKeyguardBouncerChanged(bouncerShowing);
|
||||
if (bouncerIsOrWillBeShowing != mLastBouncerIsOrWillBeShowing || mFirstUpdate) {
|
||||
mKeyguardUpdateManager.sendKeyguardBouncerChanged(bouncerIsOrWillBeShowing);
|
||||
}
|
||||
|
||||
mFirstUpdate = false;
|
||||
@@ -848,6 +851,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
mLastGlobalActionsVisible = mGlobalActionsVisible;
|
||||
mLastOccluded = occluded;
|
||||
mLastBouncerShowing = bouncerShowing;
|
||||
mLastBouncerIsOrWillBeShowing = bouncerIsOrWillBeShowing;
|
||||
mLastBouncerDismissible = bouncerDismissible;
|
||||
mLastRemoteInputActive = remoteInputActive;
|
||||
mLastDozing = mDozing;
|
||||
|
||||
@@ -93,6 +93,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.InOrder;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
@@ -102,7 +103,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
@@ -159,12 +159,15 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
private StatusBarStateController mStatusBarStateController;
|
||||
@Mock
|
||||
private AuthController mAuthController;
|
||||
@Captor
|
||||
private ArgumentCaptor<StatusBarStateController.StateListener> mStatusBarStateListenerCaptor;
|
||||
// Direct executor
|
||||
private Executor mBackgroundExecutor = Runnable::run;
|
||||
private TestableLooper mTestableLooper;
|
||||
private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private TestableContext mSpiedContext;
|
||||
private MockitoSession mMockitoSession;
|
||||
private StatusBarStateController.StateListener mStatusBarStateListener;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -221,6 +224,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
mTestableLooper = TestableLooper.get(this);
|
||||
allowTestableLooperAsMainThread();
|
||||
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);
|
||||
|
||||
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());
|
||||
mStatusBarStateListener = mStatusBarStateListenerCaptor.getValue();
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -475,8 +481,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testTriesToAuthenticate_whenBouncer() {
|
||||
mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true);
|
||||
mTestableLooper.processAllMessages();
|
||||
setKeyguardBouncerVisibility(true);
|
||||
|
||||
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt());
|
||||
verify(mFaceManager).isHardwareDetected();
|
||||
@@ -493,10 +498,10 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void skipsAuthentication_whenStatusBarShadeLocked() {
|
||||
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE_LOCKED);
|
||||
|
||||
mStatusBarStateListener.onStateChanged(StatusBarState.SHADE_LOCKED);
|
||||
mKeyguardUpdateMonitor.dispatchStartedWakingUp();
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true);
|
||||
verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt());
|
||||
}
|
||||
@@ -536,8 +541,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt());
|
||||
|
||||
// Stop scanning when bouncer becomes visible
|
||||
mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true /* showingBouncer */);
|
||||
mTestableLooper.processAllMessages();
|
||||
setKeyguardBouncerVisibility(true);
|
||||
clearInvocations(mFaceManager);
|
||||
mKeyguardUpdateMonitor.requestFaceAuth();
|
||||
verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt());
|
||||
@@ -768,6 +772,85 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
orderVerify.verify(callback).onRingerModeChanged(AudioManager.RINGER_MODE_VIBRATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartUdfpsServiceBeginsOnKeyguard() {
|
||||
// GIVEN
|
||||
// - bouncer isn't showing
|
||||
// - status bar state is on the keyguard
|
||||
// - user has authenticated since boot
|
||||
setKeyguardBouncerVisibility(false /* isVisible */);
|
||||
mStatusBarStateListener.onStateChanged(StatusBarState.KEYGUARD);
|
||||
when(mStrongAuthTracker.hasUserAuthenticatedSinceBoot()).thenReturn(true);
|
||||
|
||||
// THEN we should listen for udfps
|
||||
assertThat(mKeyguardUpdateMonitor.shouldListenForUdfps()).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartUdfpsServiceOnShadeLocked() {
|
||||
// GIVEN
|
||||
// - bouncer isn't showing
|
||||
// - user has authenticated since boot
|
||||
setKeyguardBouncerVisibility(false /* isVisible */);
|
||||
when(mStrongAuthTracker.hasUserAuthenticatedSinceBoot()).thenReturn(true);
|
||||
|
||||
// WHEN the status bar state changes to SHADE_LOCKED
|
||||
mStatusBarStateListener.onStateChanged(StatusBarState.SHADE_LOCKED);
|
||||
|
||||
// THEN we shouldn't listen for udfps
|
||||
assertThat(mKeyguardUpdateMonitor.shouldListenForUdfps()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartUdfpsServiceOnFullscreenUserSwitcher() {
|
||||
// GIVEN
|
||||
// - bouncer isn't showing
|
||||
// - user has authenticated since boot
|
||||
setKeyguardBouncerVisibility(false /* isVisible */);
|
||||
when(mStrongAuthTracker.hasUserAuthenticatedSinceBoot()).thenReturn(true);
|
||||
|
||||
// WHEN the status bar state changes to FULLSCREEN_USER_SWITCHER
|
||||
mStatusBarStateListener.onStateChanged(StatusBarState.FULLSCREEN_USER_SWITCHER);
|
||||
|
||||
// THEN we shouldn't listen for udfps
|
||||
assertThat(mKeyguardUpdateMonitor.shouldListenForUdfps()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartUdfpsServiceNoAuthenticationSinceLastBoot() {
|
||||
// GIVEN
|
||||
// - bouncer isn't showing
|
||||
// - status bar state is on the keyguard
|
||||
setKeyguardBouncerVisibility(false /* isVisible */);
|
||||
mStatusBarStateListener.onStateChanged(StatusBarState.KEYGUARD);
|
||||
|
||||
// WHEN user hasn't authenticated since last boot
|
||||
when(mStrongAuthTracker.hasUserAuthenticatedSinceBoot()).thenReturn(false);
|
||||
|
||||
// THEN we shouldn't listen for udfps
|
||||
assertThat(mKeyguardUpdateMonitor.shouldListenForUdfps()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartUdfpsServiceOnBouncerNotVisible() {
|
||||
// GIVEN
|
||||
// - status bar state is on the keyguard
|
||||
// - user has authenticated since boot
|
||||
mStatusBarStateListener.onStateChanged(StatusBarState.KEYGUARD);
|
||||
when(mStrongAuthTracker.hasUserAuthenticatedSinceBoot()).thenReturn(true);
|
||||
|
||||
// WHEN the bouncer is showing
|
||||
setKeyguardBouncerVisibility(true /* isVisible */);
|
||||
|
||||
// THEN we shouldn't listen for udfps
|
||||
assertThat(mKeyguardUpdateMonitor.shouldListenForUdfps()).isEqualTo(false);
|
||||
}
|
||||
|
||||
private void setKeyguardBouncerVisibility(boolean isVisible) {
|
||||
mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(isVisible);
|
||||
mTestableLooper.processAllMessages();
|
||||
}
|
||||
|
||||
private void setBroadcastReceiverPendingResult(BroadcastReceiver receiver) {
|
||||
BroadcastReceiver.PendingResult pendingResult =
|
||||
new BroadcastReceiver.PendingResult(Activity.RESULT_OK,
|
||||
|
||||
@@ -22,7 +22,6 @@ import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -513,30 +512,6 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
verify(mUdfpsController).onCancelAodInterrupt();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnFullyShown_DelegatesToUdfpsController() {
|
||||
mAuthController.onFullyShown();
|
||||
verify(mUdfpsController).setBouncerVisibility(eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnFullyHidden_DelegatesToUdfpsController() {
|
||||
mAuthController.onFullyHidden();
|
||||
verify(mUdfpsController).setBouncerVisibility(eq(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnStartingToShow_NeverDelegatesToUdfpsController() {
|
||||
mAuthController.onStartingToShow();
|
||||
verify(mUdfpsController).setBouncerVisibility(eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnStartingToHide_NeverDelegatesToUdfpsController() {
|
||||
mAuthController.onStartingToHide();
|
||||
verify(mUdfpsController, never()).setBouncerVisibility(anyBoolean());
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
private void showDialog(int[] sensorIds, boolean credentialAllowed) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import static junit.framework.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyFloat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -90,6 +89,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
||||
private WindowManager mWindowManager;
|
||||
@Mock
|
||||
private StatusBarStateController mStatusBarStateController;
|
||||
|
||||
private FakeSettings mSystemSettings;
|
||||
private FakeExecutor mFgExecutor;
|
||||
|
||||
@@ -172,41 +172,6 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
||||
verify(mWindowManager).removeView(eq(mUdfpsView));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showUdfpsOverlay_bouncerShowing() throws RemoteException {
|
||||
// GIVEN that the bouncer is showing
|
||||
mUdfpsController.setBouncerVisibility(/* isShowing */ true);
|
||||
// WHEN a request to show the overlay is received
|
||||
mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID);
|
||||
mFgExecutor.runAllReady();
|
||||
// THEN the overlay is not attached
|
||||
verify(mWindowManager, never()).addView(eq(mUdfpsView), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setBouncerVisibility_overlayDetached() throws RemoteException {
|
||||
// GIVEN that the overlay has been requested
|
||||
mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID);
|
||||
// WHEN the bouncer becomes visible
|
||||
mUdfpsController.setBouncerVisibility(/* isShowing */ true);
|
||||
mFgExecutor.runAllReady();
|
||||
// THEN the overlay is detached
|
||||
verify(mWindowManager).removeView(eq(mUdfpsView));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setBouncerVisibility_overlayAttached() throws RemoteException {
|
||||
// GIVEN that the bouncer is visible
|
||||
mUdfpsController.setBouncerVisibility(/* isShowing */ true);
|
||||
// AND the overlay has been requested
|
||||
mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID);
|
||||
// WHEN the bouncer is closed
|
||||
mUdfpsController.setBouncerVisibility(/* isShowing */ false);
|
||||
mFgExecutor.runAllReady();
|
||||
// THEN the overlay is attached
|
||||
verify(mWindowManager).addView(eq(mUdfpsView), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fingerDown() throws RemoteException {
|
||||
// Configure UdfpsView to accept the ACTION_DOWN event
|
||||
|
||||
@@ -50,7 +50,6 @@ import com.android.keyguard.ViewMediatorCallback;
|
||||
import com.android.keyguard.dagger.KeyguardBouncerComponent;
|
||||
import com.android.systemui.DejankUtils;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.keyguard.DismissCallbackRegistry;
|
||||
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
@@ -79,8 +78,6 @@ public class KeyguardBouncerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private DismissCallbackRegistry mDismissCallbackRegistry;
|
||||
@Mock
|
||||
private AuthController mAuthController;
|
||||
@Mock
|
||||
private KeyguardHostViewController mKeyguardHostViewController;
|
||||
@Mock
|
||||
private KeyguardBouncer.BouncerExpansionCallback mExpansionCallback;
|
||||
@@ -131,7 +128,7 @@ public class KeyguardBouncerTest extends SysuiTestCase {
|
||||
|
||||
final ViewGroup container = new FrameLayout(getContext());
|
||||
mBouncer = new KeyguardBouncer.Factory(getContext(), mViewMediatorCallback,
|
||||
mDismissCallbackRegistry, mFalsingManager, mAuthController,
|
||||
mDismissCallbackRegistry, mFalsingManager,
|
||||
mKeyguardStateController, mKeyguardUpdateMonitor,
|
||||
mKeyguardBypassController, mHandler, mKeyguardSecurityModel,
|
||||
mKeyguardBouncerComponentFactory)
|
||||
@@ -209,12 +206,6 @@ public class KeyguardBouncerTest extends SysuiTestCase {
|
||||
verify(mKeyguardHostViewController).showErrorMessage(eq(errorMessage));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShow_notifiesAuthControllerStartingToShow() {
|
||||
mBouncer.show(/* resetSecuritySelection */ false);
|
||||
verify(mAuthController).onStartingToShow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetExpansion_notifiesFalsingManager() {
|
||||
mBouncer.ensureView();
|
||||
@@ -245,38 +236,6 @@ public class KeyguardBouncerTest extends SysuiTestCase {
|
||||
verify(mRootView).announceForAccessibility(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetExpansion_notifiesAuthControllerFullyShown() {
|
||||
mBouncer.ensureView();
|
||||
mBouncer.setExpansion(0.1f);
|
||||
mBouncer.setExpansion(0f);
|
||||
verify(mAuthController).onFullyShown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetExpansion_notifiesAuthControllerStartingToHide() {
|
||||
mBouncer.ensureView();
|
||||
mBouncer.setExpansion(0f);
|
||||
mBouncer.setExpansion(0.1f);
|
||||
verify(mAuthController).onStartingToHide();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetExpansion_notifiesAuthControllerFullyHidden() {
|
||||
mBouncer.ensureView();
|
||||
mBouncer.setExpansion(0.9f);
|
||||
mBouncer.setExpansion(1f);
|
||||
verify(mAuthController).onFullyHidden();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetExpansion_negativeAuthControllerStartingToShow() {
|
||||
mBouncer.ensureView();
|
||||
mBouncer.setExpansion(1f);
|
||||
mBouncer.setExpansion(0.9f);
|
||||
verify(mAuthController, never()).onStartingToShow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHide_notifiesFalsingManager() {
|
||||
mBouncer.hide(false);
|
||||
|
||||
Reference in New Issue
Block a user