Merge "Eval KG showing, occluded and visibility together" into tm-qpr-dev

This commit is contained in:
Beverly Tai
2022-10-07 15:58:17 +00:00
committed by Android (Google) Code Review
20 changed files with 134 additions and 158 deletions

View File

@@ -69,7 +69,7 @@ open class ClockEventController @Inject constructor(
private var isCharging = false private var isCharging = false
private var dozeAmount = 0f private var dozeAmount = 0f
private var isKeyguardShowing = false private var isKeyguardVisible = false
private val regionSamplingEnabled = private val regionSamplingEnabled =
featureFlags.isEnabled(com.android.systemui.flags.Flags.REGION_SAMPLING) featureFlags.isEnabled(com.android.systemui.flags.Flags.REGION_SAMPLING)
@@ -145,7 +145,7 @@ open class ClockEventController @Inject constructor(
private val batteryCallback = object : BatteryStateChangeCallback { private val batteryCallback = object : BatteryStateChangeCallback {
override fun onBatteryLevelChanged(level: Int, pluggedIn: Boolean, charging: Boolean) { override fun onBatteryLevelChanged(level: Int, pluggedIn: Boolean, charging: Boolean) {
if (isKeyguardShowing && !isCharging && charging) { if (isKeyguardVisible && !isCharging && charging) {
clock?.animations?.charge() clock?.animations?.charge()
} }
isCharging = charging isCharging = charging
@@ -168,9 +168,9 @@ open class ClockEventController @Inject constructor(
} }
private val keyguardUpdateMonitorCallback = object : KeyguardUpdateMonitorCallback() { private val keyguardUpdateMonitorCallback = object : KeyguardUpdateMonitorCallback() {
override fun onKeyguardVisibilityChanged(showing: Boolean) { override fun onKeyguardVisibilityChanged(visible: Boolean) {
isKeyguardShowing = showing isKeyguardVisible = visible
if (!isKeyguardShowing) { if (!isKeyguardVisible) {
clock?.animations?.doze(if (isDozing) 1f else 0f) clock?.animations?.doze(if (isDozing) 1f else 0f)
} }
} }

View File

@@ -212,9 +212,9 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
} }
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
if (showing) { if (visible) {
if (DEBUG) Slog.v(TAG, "refresh statusview showing:" + showing); if (DEBUG) Slog.v(TAG, "refresh statusview visible:true");
refreshTime(); refreshTime();
} }
} }

View File

@@ -308,7 +308,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
HashMap<Integer, ServiceState> mServiceStates = new HashMap<>(); HashMap<Integer, ServiceState> mServiceStates = new HashMap<>();
private int mPhoneState; private int mPhoneState;
private boolean mKeyguardIsVisible; private boolean mKeyguardShowing;
private boolean mKeyguardOccluded;
private boolean mCredentialAttempted; private boolean mCredentialAttempted;
private boolean mKeyguardGoingAway; private boolean mKeyguardGoingAway;
private boolean mGoingToSleep; private boolean mGoingToSleep;
@@ -318,7 +319,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private boolean mAuthInterruptActive; private boolean mAuthInterruptActive;
private boolean mNeedsSlowUnlockTransition; private boolean mNeedsSlowUnlockTransition;
private boolean mAssistantVisible; private boolean mAssistantVisible;
private boolean mKeyguardOccluded;
private boolean mOccludingAppRequestingFp; private boolean mOccludingAppRequestingFp;
private boolean mOccludingAppRequestingFace; private boolean mOccludingAppRequestingFace;
private boolean mSecureCameraLaunched; private boolean mSecureCameraLaunched;
@@ -681,14 +681,42 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
/** /**
* Updates KeyguardUpdateMonitor's internal state to know if keyguard is occluded * Updates KeyguardUpdateMonitor's internal state to know if keyguard is showing and if
* its occluded. The keyguard is considered visible if its showing and NOT occluded.
*/ */
public void setKeyguardOccluded(boolean occluded) { public void setKeyguardShowing(boolean showing, boolean occluded) {
mKeyguardOccluded = occluded; final boolean occlusionChanged = mKeyguardOccluded != occluded;
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, final boolean showingChanged = mKeyguardShowing != showing;
FACE_AUTH_UPDATED_KEYGUARD_OCCLUSION_CHANGED); if (!occlusionChanged && !showingChanged) {
} return;
}
final boolean wasKeyguardVisible = isKeyguardVisible();
mKeyguardShowing = showing;
mKeyguardOccluded = occluded;
final boolean isKeyguardVisible = isKeyguardVisible();
mLogger.logKeyguardShowingChanged(showing, occluded, isKeyguardVisible);
if (isKeyguardVisible != wasKeyguardVisible) {
if (isKeyguardVisible) {
mSecureCameraLaunched = false;
}
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onKeyguardVisibilityChanged(isKeyguardVisible);
}
}
}
if (occlusionChanged) {
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
FACE_AUTH_UPDATED_KEYGUARD_OCCLUSION_CHANGED);
} else if (showingChanged) {
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
FACE_AUTH_UPDATED_KEYGUARD_VISIBILITY_CHANGED);
}
}
/** /**
* Request to listen for face authentication when an app is occluding keyguard. * Request to listen for face authentication when an app is occluding keyguard.
@@ -2442,7 +2470,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
// Triggers: // Triggers:
final boolean triggerActiveUnlockForAssistant = shouldTriggerActiveUnlockForAssistant(); final boolean triggerActiveUnlockForAssistant = shouldTriggerActiveUnlockForAssistant();
final boolean awakeKeyguard = mBouncerFullyShown || mUdfpsBouncerShowing final boolean awakeKeyguard = mBouncerFullyShown || mUdfpsBouncerShowing
|| (mKeyguardIsVisible && !mGoingToSleep || (isKeyguardVisible() && !mGoingToSleep
&& mStatusBarState != StatusBarState.SHADE_LOCKED); && mStatusBarState != StatusBarState.SHADE_LOCKED);
// Gates: // Gates:
@@ -2518,7 +2546,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
final boolean userDoesNotHaveTrust = !getUserHasTrust(user); final boolean userDoesNotHaveTrust = !getUserHasTrust(user);
final boolean shouldListenForFingerprintAssistant = shouldListenForFingerprintAssistant(); final boolean shouldListenForFingerprintAssistant = shouldListenForFingerprintAssistant();
final boolean shouldListenKeyguardState = final boolean shouldListenKeyguardState =
mKeyguardIsVisible isKeyguardVisible()
|| !mDeviceInteractive || !mDeviceInteractive
|| (mBouncerIsOrWillBeShowing && !mKeyguardGoingAway) || (mBouncerIsOrWillBeShowing && !mKeyguardGoingAway)
|| mGoingToSleep || mGoingToSleep
@@ -2567,7 +2595,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
mFingerprintLockedOut, mFingerprintLockedOut,
mGoingToSleep, mGoingToSleep,
mKeyguardGoingAway, mKeyguardGoingAway,
mKeyguardIsVisible, isKeyguardVisible(),
mKeyguardOccluded, mKeyguardOccluded,
mOccludingAppRequestingFp, mOccludingAppRequestingFp,
mIsPrimaryUser, mIsPrimaryUser,
@@ -2589,7 +2617,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
final boolean statusBarShadeLocked = mStatusBarState == StatusBarState.SHADE_LOCKED; final boolean statusBarShadeLocked = mStatusBarState == StatusBarState.SHADE_LOCKED;
final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive final boolean awakeKeyguard = isKeyguardVisible() && mDeviceInteractive
&& !statusBarShadeLocked; && !statusBarShadeLocked;
final int user = getCurrentUser(); final int user = getCurrentUser();
final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user); final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user);
@@ -3146,32 +3174,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
callbacksRefreshCarrierInfo(); callbacksRefreshCarrierInfo();
} }
/**
* Whether the keyguard is showing and not occluded.
*/
public boolean isKeyguardVisible() { public boolean isKeyguardVisible() {
return mKeyguardIsVisible; return isKeyguardShowing() && !mKeyguardOccluded;
} }
/** /**
* Notifies that the visibility state of Keyguard has changed. * Whether the keyguard is showing. It may still be occluded and not visible.
*
* <p>Needs to be called from the main thread.
*/ */
public void onKeyguardVisibilityChanged(boolean showing) { public boolean isKeyguardShowing() {
Assert.isMainThread(); return mKeyguardShowing;
mLogger.logKeyguardVisibilityChanged(showing);
mKeyguardIsVisible = showing;
if (showing) {
mSecureCameraLaunched = false;
}
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onKeyguardVisibilityChangedRaw(showing);
}
}
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
FACE_AUTH_UPDATED_KEYGUARD_VISIBILITY_CHANGED);
} }
/** /**
@@ -3380,7 +3394,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
callback.onTimeChanged(); callback.onTimeChanged();
callback.onPhoneStateChanged(mPhoneState); callback.onPhoneStateChanged(mPhoneState);
callback.onRefreshCarrierInfo(); callback.onRefreshCarrierInfo();
callback.onKeyguardVisibilityChangedRaw(mKeyguardIsVisible); callback.onKeyguardVisibilityChanged(isKeyguardVisible());
callback.onTelephonyCapable(mTelephonyCapable); callback.onTelephonyCapable(mTelephonyCapable);
for (Entry<Integer, SimData> data : mSimDatas.entrySet()) { for (Entry<Integer, SimData> data : mSimDatas.entrySet()) {

View File

@@ -16,7 +16,6 @@
package com.android.keyguard; package com.android.keyguard;
import android.hardware.biometrics.BiometricSourceType; import android.hardware.biometrics.BiometricSourceType;
import android.os.SystemClock;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.view.WindowManagerPolicyConstants; import android.view.WindowManagerPolicyConstants;
@@ -32,10 +31,6 @@ import java.util.TimeZone;
*/ */
public class KeyguardUpdateMonitorCallback { public class KeyguardUpdateMonitorCallback {
private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000;
private long mVisibilityChangedCalled;
private boolean mShowing;
/** /**
* Called when the battery status changes, e.g. when plugged in or unplugged, charge * Called when the battery status changes, e.g. when plugged in or unplugged, charge
* level, etc. changes. * level, etc. changes.
@@ -74,21 +69,6 @@ public class KeyguardUpdateMonitorCallback {
*/ */
public void onPhoneStateChanged(int phoneState) { } public void onPhoneStateChanged(int phoneState) { }
/**
* Called when the visibility of the keyguard changes.
* @param showing Indicates if the keyguard is now visible.
*/
public void onKeyguardVisibilityChanged(boolean showing) { }
public void onKeyguardVisibilityChangedRaw(boolean showing) {
final long now = SystemClock.elapsedRealtime();
if (showing == mShowing
&& (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return;
onKeyguardVisibilityChanged(showing);
mVisibilityChangedCalled = now;
mShowing = showing;
}
/** /**
* Called when the keyguard enters or leaves bouncer mode. * Called when the keyguard enters or leaves bouncer mode.
* @param bouncerIsOrWillBeShowing if true, keyguard is showing the bouncer or transitioning * @param bouncerIsOrWillBeShowing if true, keyguard is showing the bouncer or transitioning
@@ -96,6 +76,12 @@ public class KeyguardUpdateMonitorCallback {
*/ */
public void onKeyguardBouncerStateChanged(boolean bouncerIsOrWillBeShowing) { } public void onKeyguardBouncerStateChanged(boolean bouncerIsOrWillBeShowing) { }
/**
* Called when the keyguard visibility changes.
* @param visible whether the keyguard is showing and is NOT occluded
*/
public void onKeyguardVisibilityChanged(boolean visible) { }
/** /**
* Called when the keyguard fully transitions to the bouncer or is no longer the bouncer * Called when the keyguard fully transitions to the bouncer or is no longer the bouncer
* @param bouncerIsFullyShowing if true, keyguard is fully showing the bouncer * @param bouncerIsFullyShowing if true, keyguard is fully showing the bouncer

View File

@@ -446,14 +446,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback = private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback =
new KeyguardUpdateMonitorCallback() { new KeyguardUpdateMonitorCallback() {
@Override
public void onKeyguardVisibilityChanged(boolean showing) {
// reset mIsBouncerShowing state in case it was preemptively set
// onLongPress
mIsBouncerShowing = mKeyguardViewController.isBouncerShowing();
updateVisibility();
}
@Override @Override
public void onKeyguardBouncerStateChanged(boolean bouncer) { public void onKeyguardBouncerStateChanged(boolean bouncer) {
mIsBouncerShowing = bouncer; mIsBouncerShowing = bouncer;
@@ -507,6 +499,11 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
// If biometrics were removed, local vars mCanDismissLockScreen and // If biometrics were removed, local vars mCanDismissLockScreen and
// mUserUnlockedWithBiometric may not be updated. // mUserUnlockedWithBiometric may not be updated.
mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen(); mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen();
// reset mIsBouncerShowing state in case it was preemptively set
// onLongPress
mIsBouncerShowing = mKeyguardViewController.isBouncerShowing();
updateKeyguardShowing(); updateKeyguardShowing();
if (mIsKeyguardShowing) { if (mIsKeyguardShowing) {
mUserUnlockedWithBiometric = mUserUnlockedWithBiometric =

View File

@@ -170,8 +170,14 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
logBuffer.log(TAG, VERBOSE, { str1 = "$model" }, { str1!! }) logBuffer.log(TAG, VERBOSE, { str1 = "$model" }, { str1!! })
} }
fun logKeyguardVisibilityChanged(showing: Boolean) { fun logKeyguardShowingChanged(showing: Boolean, occluded: Boolean, visible: Boolean) {
logBuffer.log(TAG, DEBUG, { bool1 = showing }, { "onKeyguardVisibilityChanged($bool1)" }) logBuffer.log(TAG, DEBUG, {
bool1 = showing
bool2 = occluded
bool3 = visible
}, {
"keyguardShowingChanged(showing=$bool1 occluded=$bool2 visible=$bool3)"
})
} }
fun logMissingSupervisorAppError(userId: Int) { fun logMissingSupervisorAppError(userId: Int) {

View File

@@ -61,8 +61,8 @@ public class AccessibilityFloatingMenuController implements
} }
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
mIsKeyguardVisible = showing; mIsKeyguardVisible = visible;
handleFloatingMenuVisibility(mIsKeyguardVisible, mBtnMode, mBtnTargets); handleFloatingMenuVisibility(mIsKeyguardVisible, mBtnMode, mBtnTargets);
} }

View File

@@ -117,7 +117,7 @@ class AuthRippleController @Inject constructor(
} }
fun showUnlockRipple(biometricSourceType: BiometricSourceType?) { fun showUnlockRipple(biometricSourceType: BiometricSourceType?) {
if (!(keyguardUpdateMonitor.isKeyguardVisible || keyguardUpdateMonitor.isDreaming) || if (!keyguardStateController.isShowing ||
keyguardUpdateMonitor.userNeedsStrongAuth()) { keyguardUpdateMonitor.userNeedsStrongAuth()) {
return return
} }

View File

@@ -431,8 +431,8 @@ public class DozeLog implements Dumpable {
} }
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
traceKeyguard(showing); traceKeyguard(visible);
} }
}; };

View File

@@ -155,11 +155,11 @@ class DozeLogger @Inject constructor(
}) })
} }
fun logKeyguardVisibilityChange(isShowing: Boolean) { fun logKeyguardVisibilityChange(isVisible: Boolean) {
buffer.log(TAG, INFO, { buffer.log(TAG, INFO, {
bool1 = isShowing bool1 = isVisible
}, { }, {
"Keyguard visibility change, isShowing=$bool1" "Keyguard visibility change, isVisible=$bool1"
}) })
} }

View File

@@ -511,9 +511,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
synchronized (KeyguardViewMediator.this) { synchronized (KeyguardViewMediator.this) {
if (!showing && mPendingPinLock) { if (!visible && mPendingPinLock) {
Log.i(TAG, "PIN lock requested, starting keyguard"); Log.i(TAG, "PIN lock requested, starting keyguard");
// Bring the keyguard back in order to show the PIN lock // Bring the keyguard back in order to show the PIN lock
@@ -1806,7 +1806,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
if (mOccluded != isOccluded) { if (mOccluded != isOccluded) {
mOccluded = isOccluded; mOccluded = isOccluded;
mUpdateMonitor.setKeyguardOccluded(isOccluded);
mKeyguardViewControllerLazy.get().setOccluded(isOccluded, animate mKeyguardViewControllerLazy.get().setOccluded(isOccluded, animate
&& mDeviceInteractive); && mDeviceInteractive);
adjustStatusBarLocked(); adjustStatusBarLocked();

View File

@@ -93,13 +93,13 @@ public class DozeParameters implements
private boolean mControlScreenOffAnimation; private boolean mControlScreenOffAnimation;
private boolean mIsQuickPickupEnabled; private boolean mIsQuickPickupEnabled;
private boolean mKeyguardShowing; private boolean mKeyguardVisible;
@VisibleForTesting @VisibleForTesting
final KeyguardUpdateMonitorCallback mKeyguardVisibilityCallback = final KeyguardUpdateMonitorCallback mKeyguardVisibilityCallback =
new KeyguardUpdateMonitorCallback() { new KeyguardUpdateMonitorCallback() {
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
mKeyguardShowing = showing; mKeyguardVisible = visible;
updateControlScreenOff(); updateControlScreenOff();
} }
@@ -293,7 +293,7 @@ public class DozeParameters implements
public void updateControlScreenOff() { public void updateControlScreenOff() {
if (!getDisplayNeedsBlanking()) { if (!getDisplayNeedsBlanking()) {
final boolean controlScreenOff = final boolean controlScreenOff =
getAlwaysOn() && (mKeyguardShowing || shouldControlUnlockedScreenOff()); getAlwaysOn() && (mKeyguardVisible || shouldControlUnlockedScreenOff());
setControlScreenOffAnimation(controlScreenOff); setControlScreenOffAnimation(controlScreenOff);
} }
} }
@@ -348,7 +348,7 @@ public class DozeParameters implements
} }
private boolean willAnimateFromLockScreenToAod() { private boolean willAnimateFromLockScreenToAod() {
return getAlwaysOn() && mKeyguardShowing; return getAlwaysOn() && mKeyguardVisible;
} }
private boolean getBoolean(String propName, int resId) { private boolean getBoolean(String propName, int resId) {

View File

@@ -88,7 +88,7 @@ class KeyguardLiftController @Inject constructor(
updateListeningState() updateListeningState()
} }
override fun onKeyguardVisibilityChanged(showing: Boolean) { override fun onKeyguardVisibilityChanged(visible: Boolean) {
updateListeningState() updateListeningState()
} }
} }

View File

@@ -187,8 +187,8 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
} }
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
if (showing) { if (visible) {
updateUserSwitcher(); updateUserSwitcher();
} }
} }

View File

@@ -1534,7 +1534,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
private class KeyguardVisibilityCallback extends KeyguardUpdateMonitorCallback { private class KeyguardVisibilityCallback extends KeyguardUpdateMonitorCallback {
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
mNeedsDrawableColorUpdate = true; mNeedsDrawableColorUpdate = true;
scheduleUpdate(); scheduleUpdate();
} }

View File

@@ -1131,8 +1131,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
if (occluded != mLastOccluded || mFirstUpdate) { if (occluded != mLastOccluded || mFirstUpdate) {
mKeyguardStateController.notifyKeyguardState(showing, occluded); mKeyguardStateController.notifyKeyguardState(showing, occluded);
} }
if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { if (occluded != mLastOccluded || mShowing != showing || mFirstUpdate) {
mKeyguardUpdateManager.onKeyguardVisibilityChanged(showing && !occluded); mKeyguardUpdateManager.setKeyguardShowing(showing, occluded);
} }
if (bouncerIsOrWillBeShowing != mLastBouncerIsOrWillBeShowing || mFirstUpdate if (bouncerIsOrWillBeShowing != mLastBouncerIsOrWillBeShowing || mFirstUpdate
|| bouncerShowing != mLastBouncerShowing) { || bouncerShowing != mLastBouncerShowing) {

View File

@@ -435,7 +435,7 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum
} }
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
update(false /* updateAlways */); update(false /* updateAlways */);
} }

View File

@@ -91,11 +91,11 @@ public class KeyguardUserSwitcherController extends ViewController<KeyguardUserS
private final KeyguardUpdateMonitorCallback mInfoCallback = private final KeyguardUpdateMonitorCallback mInfoCallback =
new KeyguardUpdateMonitorCallback() { new KeyguardUpdateMonitorCallback() {
@Override @Override
public void onKeyguardVisibilityChanged(boolean showing) { public void onKeyguardVisibilityChanged(boolean visible) {
if (DEBUG) Log.d(TAG, String.format("onKeyguardVisibilityChanged %b", showing)); if (DEBUG) Log.d(TAG, String.format("onKeyguardVisibilityChanged %b", visible));
// Any time the keyguard is hidden, try to close the user switcher menu to // Any time the keyguard is hidden, try to close the user switcher menu to
// restore keyguard to the default state // restore keyguard to the default state
if (!showing) { if (!visible) {
closeSwitcherIfOpenAndNotSimple(false); closeSwitcherIfOpenAndNotSimple(false);
} }
} }

View File

@@ -607,7 +607,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testTriesToAuthenticate_whenKeyguard() { public void testTriesToAuthenticate_whenKeyguard() {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
} }
@@ -617,7 +617,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(), verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(),
anyBoolean()); anyBoolean());
} }
@@ -630,7 +630,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(), verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(),
anyBoolean()); anyBoolean());
} }
@@ -654,7 +654,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
// Stop scanning when bouncer becomes visible // Stop scanning when bouncer becomes visible
@@ -668,7 +668,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testTriesToAuthenticate_whenAssistant() { public void testTriesToAuthenticate_whenAssistant() {
mKeyguardUpdateMonitor.setKeyguardOccluded(true); mKeyguardUpdateMonitor.setKeyguardShowing(true, true);
mKeyguardUpdateMonitor.setAssistantVisible(true); mKeyguardUpdateMonitor.setAssistantVisible(true);
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
@@ -683,7 +683,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */,
KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */, KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */,
new ArrayList<>()); new ArrayList<>());
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
} }
@@ -693,7 +693,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */,
KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */, new ArrayList<>()); KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */, new ArrayList<>());
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(), verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(),
anyBoolean()); anyBoolean());
} }
@@ -705,7 +705,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn(
KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN); KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN);
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(), verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(),
anyBoolean()); anyBoolean());
} }
@@ -717,7 +717,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn(
KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT); KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT);
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
} }
@@ -738,7 +738,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testFaceAndFingerprintLockout_onlyFace() { public void testFaceAndFingerprintLockout_onlyFace() {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
faceAuthLockedOut(); faceAuthLockedOut();
@@ -749,7 +749,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testFaceAndFingerprintLockout_onlyFingerprint() { public void testFaceAndFingerprintLockout_onlyFingerprint() {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback
.onAuthenticationError(FINGERPRINT_ERROR_LOCKOUT_PERMANENT, ""); .onAuthenticationError(FINGERPRINT_ERROR_LOCKOUT_PERMANENT, "");
@@ -761,7 +761,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testFaceAndFingerprintLockout() { public void testFaceAndFingerprintLockout() {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
faceAuthLockedOut(); faceAuthLockedOut();
mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback
@@ -860,7 +860,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(), verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(),
@@ -1033,8 +1033,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testOccludingAppFingerprintListeningState() { public void testOccludingAppFingerprintListeningState() {
// GIVEN keyguard isn't visible (app occluding) // GIVEN keyguard isn't visible (app occluding)
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mKeyguardUpdateMonitor.setKeyguardOccluded(true); mKeyguardUpdateMonitor.setKeyguardShowing(true, true);
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(false);
when(mStrongAuthTracker.hasUserAuthenticatedSinceBoot()).thenReturn(true); when(mStrongAuthTracker.hasUserAuthenticatedSinceBoot()).thenReturn(true);
// THEN we shouldn't listen for fingerprints // THEN we shouldn't listen for fingerprints
@@ -1049,8 +1048,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testOccludingAppRequestsFingerprint() { public void testOccludingAppRequestsFingerprint() {
// GIVEN keyguard isn't visible (app occluding) // GIVEN keyguard isn't visible (app occluding)
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mKeyguardUpdateMonitor.setKeyguardOccluded(true); mKeyguardUpdateMonitor.setKeyguardShowing(true, true);
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(false);
// WHEN an occluding app requests fp // WHEN an occluding app requests fp
mKeyguardUpdateMonitor.requestFingerprintAuthOnOccludingApp(true); mKeyguardUpdateMonitor.requestFingerprintAuthOnOccludingApp(true);
@@ -1142,7 +1140,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
setKeyguardBouncerVisibility(false /* isVisible */); setKeyguardBouncerVisibility(false /* isVisible */);
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
when(mKeyguardBypassController.canBypass()).thenReturn(true); when(mKeyguardBypassController.canBypass()).thenReturn(true);
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
// WHEN status bar state reports a change to the keyguard that would normally indicate to // WHEN status bar state reports a change to the keyguard that would normally indicate to
// start running face auth // start running face auth
@@ -1153,8 +1151,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
// listening state to update // listening state to update
assertThat(mKeyguardUpdateMonitor.isFaceDetectionRunning()).isEqualTo(false); assertThat(mKeyguardUpdateMonitor.isFaceDetectionRunning()).isEqualTo(false);
// WHEN biometric listening state is updated // WHEN biometric listening state is updated when showing state changes from false => true
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); mKeyguardUpdateMonitor.setKeyguardShowing(false, false);
mKeyguardUpdateMonitor.setKeyguardShowing(true, false);
// THEN face unlock is running // THEN face unlock is running
assertThat(mKeyguardUpdateMonitor.isFaceDetectionRunning()).isEqualTo(true); assertThat(mKeyguardUpdateMonitor.isFaceDetectionRunning()).isEqualTo(true);
@@ -1520,7 +1519,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testFingerprintCanAuth_whenCancellationNotReceivedAndAuthFailed() { public void testFingerprintCanAuth_whenCancellationNotReceivedAndAuthFailed() {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); keyguardIsVisible();
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(), verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(),
@@ -1529,7 +1528,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mKeyguardUpdateMonitor.onFaceAuthenticated(0, false); mKeyguardUpdateMonitor.onFaceAuthenticated(0, false);
// Make sure keyguard is going away after face auth attempt, and that it calls // Make sure keyguard is going away after face auth attempt, and that it calls
// updateBiometricStateListeningState. // updateBiometricStateListeningState.
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(false); mKeyguardUpdateMonitor.setKeyguardShowing(false, false);
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
verify(mHandler).postDelayed(mKeyguardUpdateMonitor.mFpCancelNotReceived, verify(mHandler).postDelayed(mKeyguardUpdateMonitor.mFpCancelNotReceived,
@@ -1589,7 +1588,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
} }
private void keyguardIsVisible() { private void keyguardIsVisible() {
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); mKeyguardUpdateMonitor.setKeyguardShowing(true, false);
} }
private void triggerAuthInterrupt() { private void triggerAuthInterrupt() {

View File

@@ -117,13 +117,12 @@ class AuthRippleControllerTest : SysuiTestCase() {
} }
@Test @Test
fun testFingerprintTrigger_KeyguardVisible_Ripple() { fun testFingerprintTrigger_KeyguardShowing_Ripple() {
// GIVEN fp exists, keyguard is visible, user doesn't need strong auth // GIVEN fp exists, keyguard is showing, user doesn't need strong auth
val fpsLocation = Point(5, 5) val fpsLocation = Point(5, 5)
`when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation) `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
controller.onViewAttached() controller.onViewAttached()
`when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) `when`(keyguardStateController.isShowing).thenReturn(true)
`when`(keyguardUpdateMonitor.isDreaming).thenReturn(false)
`when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false) `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false)
// WHEN fingerprint authenticated // WHEN fingerprint authenticated
@@ -140,39 +139,15 @@ class AuthRippleControllerTest : SysuiTestCase() {
} }
@Test @Test
fun testFingerprintTrigger_Dreaming_Ripple() { fun testFingerprintTrigger_KeyguardNotShowing_NoRipple() {
// GIVEN fp exists, keyguard is visible, user doesn't need strong auth
val fpsLocation = Point(5, 5)
`when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
controller.onViewAttached()
`when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(false)
`when`(keyguardUpdateMonitor.isDreaming).thenReturn(true)
`when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false)
// WHEN fingerprint authenticated
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
verify(keyguardUpdateMonitor).registerCallback(captor.capture())
captor.value.onBiometricAuthenticated(
0 /* userId */,
BiometricSourceType.FINGERPRINT /* type */,
false /* isStrongBiometric */)
// THEN update sensor location and show ripple
verify(rippleView).setFingerprintSensorLocation(fpsLocation, 0f)
verify(rippleView).startUnlockedRipple(any())
}
@Test
fun testFingerprintTrigger_KeyguardNotVisible_NotDreaming_NoRipple() {
// GIVEN fp exists & user doesn't need strong auth // GIVEN fp exists & user doesn't need strong auth
val fpsLocation = Point(5, 5) val fpsLocation = Point(5, 5)
`when`(authController.udfpsLocation).thenReturn(fpsLocation) `when`(authController.udfpsLocation).thenReturn(fpsLocation)
controller.onViewAttached() controller.onViewAttached()
`when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false) `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false)
// WHEN keyguard is NOT visible & fingerprint authenticated // WHEN keyguard is NOT showing & fingerprint authenticated
`when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(false) `when`(keyguardStateController.isShowing).thenReturn(false)
`when`(keyguardUpdateMonitor.isDreaming).thenReturn(false)
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java) val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
verify(keyguardUpdateMonitor).registerCallback(captor.capture()) verify(keyguardUpdateMonitor).registerCallback(captor.capture())
captor.value.onBiometricAuthenticated( captor.value.onBiometricAuthenticated(
@@ -186,11 +161,11 @@ class AuthRippleControllerTest : SysuiTestCase() {
@Test @Test
fun testFingerprintTrigger_StrongAuthRequired_NoRipple() { fun testFingerprintTrigger_StrongAuthRequired_NoRipple() {
// GIVEN fp exists & keyguard is visible // GIVEN fp exists & keyguard is showing
val fpsLocation = Point(5, 5) val fpsLocation = Point(5, 5)
`when`(authController.udfpsLocation).thenReturn(fpsLocation) `when`(authController.udfpsLocation).thenReturn(fpsLocation)
controller.onViewAttached() controller.onViewAttached()
`when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) `when`(keyguardStateController.isShowing).thenReturn(true)
// WHEN user needs strong auth & fingerprint authenticated // WHEN user needs strong auth & fingerprint authenticated
`when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(true) `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(true)
@@ -207,12 +182,12 @@ class AuthRippleControllerTest : SysuiTestCase() {
@Test @Test
fun testFaceTriggerBypassEnabled_Ripple() { fun testFaceTriggerBypassEnabled_Ripple() {
// GIVEN face auth sensor exists, keyguard is visible & strong auth isn't required // GIVEN face auth sensor exists, keyguard is showing & strong auth isn't required
val faceLocation = Point(5, 5) val faceLocation = Point(5, 5)
`when`(authController.faceSensorLocation).thenReturn(faceLocation) `when`(authController.faceSensorLocation).thenReturn(faceLocation)
controller.onViewAttached() controller.onViewAttached()
`when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) `when`(keyguardStateController.isShowing).thenReturn(true)
`when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false) `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false)
// WHEN bypass is enabled & face authenticated // WHEN bypass is enabled & face authenticated
@@ -299,7 +274,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
val fpsLocation = Point(5, 5) val fpsLocation = Point(5, 5)
`when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation) `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
controller.onViewAttached() controller.onViewAttached()
`when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) `when`(keyguardStateController.isShowing).thenReturn(true)
`when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true) `when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true)
controller.showUnlockRipple(BiometricSourceType.FINGERPRINT) controller.showUnlockRipple(BiometricSourceType.FINGERPRINT)
@@ -317,7 +292,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
val faceLocation = Point(5, 5) val faceLocation = Point(5, 5)
`when`(authController.faceSensorLocation).thenReturn(faceLocation) `when`(authController.faceSensorLocation).thenReturn(faceLocation)
controller.onViewAttached() controller.onViewAttached()
`when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) `when`(keyguardStateController.isShowing).thenReturn(true)
`when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true) `when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true)
`when`(authController.isUdfpsFingerDown).thenReturn(true) `when`(authController.isUdfpsFingerDown).thenReturn(true)