Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +65 −28 Original line number Diff line number Diff line Loading @@ -299,6 +299,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, private static final int UNOCCLUDE_ANIMATION_DURATION = 250; private static final int NO_KEYGUARD_DONE_PENDING = -10000; /** * How far down to animate the unoccluding activity, in terms of percent of the activity's * height. Loading Loading @@ -466,7 +468,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, private boolean mWaitingUntilKeyguardVisible = false; private final LockPatternUtils mLockPatternUtils; private final BroadcastDispatcher mBroadcastDispatcher; private boolean mKeyguardDonePending = false; private int mKeyguardDonePendingForUser = NO_KEYGUARD_DONE_PENDING; private boolean mUnlockingAndWakingFromDream = false; private boolean mHideAnimationRun = false; private boolean mHideAnimationRunning = false; Loading Loading @@ -763,6 +765,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, @Override public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType, boolean isStrongBiometric) { if (userId != KeyguardUpdateMonitor.getCurrentUser()) { Log.w(TAG, "onBiometricAuthenticated() invoked for userId: " + userId + ", current " + "userId: " + KeyguardUpdateMonitor.getCurrentUser()); return; } if (mLockPatternUtils.isSecure(userId)) { mLockPatternUtils.getDevicePolicyManager().reportSuccessfulBiometricAttempt( userId); Loading Loading @@ -798,8 +805,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, if (targetUserId != KeyguardUpdateMonitor.getCurrentUser()) { return; } if (DEBUG) Log.d(TAG, "keyguardDone"); tryKeyguardDone(); Log.d(TAG, "keyguardDone: " + targetUserId); tryKeyguardDone(targetUserId); } @Override Loading @@ -816,18 +823,16 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, @Override public void keyguardDonePending(boolean primaryAuth, int targetUserId) { Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDonePending"); if (DEBUG) Log.d(TAG, "keyguardDonePending"); Log.d(TAG, "keyguardDonePending: " + targetUserId); if (targetUserId != KeyguardUpdateMonitor.getCurrentUser()) { Trace.endSection(); return; } mKeyguardDonePending = true; Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDonePending"); mKeyguardDonePendingForUser = targetUserId; mHideAnimationRun = true; mHideAnimationRunning = true; mKeyguardViewControllerLazy.get() .startPreHideAnimation(mHideAnimationFinishedRunnable); .startPreHideAnimation(new OnHideAnimationFinished(targetUserId)); mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_PENDING_TIMEOUT, KEYGUARD_DONE_PENDING_TIMEOUT_MS); Trace.endSection(); Loading Loading @@ -865,9 +870,10 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, @Override public void readyForKeyguardDone() { Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#readyForKeyguardDone"); if (mKeyguardDonePending) { mKeyguardDonePending = false; tryKeyguardDone(); if (mKeyguardDonePendingForUser != NO_KEYGUARD_DONE_PENDING) { int user = mKeyguardDonePendingForUser; mKeyguardDonePendingForUser = NO_KEYGUARD_DONE_PENDING; tryKeyguardDone(user); } Trace.endSection(); } Loading Loading @@ -2369,7 +2375,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, * expecting the keyguard to go away when called. */ public void hideWithAnimation(IRemoteAnimationRunner runner) { if (!mKeyguardDonePending) { if (mKeyguardDonePendingForUser == NO_KEYGUARD_DONE_PENDING) { return; } Loading Loading @@ -2589,12 +2595,17 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } }; private void tryKeyguardDone() { if (DEBUG) { Log.d(TAG, "tryKeyguardDone: pending - " + mKeyguardDonePending + ", animRan - " + mHideAnimationRun + " animRunning - " + mHideAnimationRunning); private void tryKeyguardDone(int userId) { String logUserId; if (mKeyguardDonePendingForUser == NO_KEYGUARD_DONE_PENDING) { logUserId = "NO_KEYGUARD_DONE_PENDING"; } else { logUserId = "" + mKeyguardDonePendingForUser; } if (!mKeyguardDonePending && mHideAnimationRun && !mHideAnimationRunning) { Log.d(TAG, "tryKeyguardDone: pendingForUser - " + logUserId + ", animRan - " + mHideAnimationRun + " animRunning - " + mHideAnimationRunning); if (mKeyguardDonePendingForUser == NO_KEYGUARD_DONE_PENDING && mHideAnimationRun && !mHideAnimationRunning) { handleKeyguardDone(); } else if (mSurfaceBehindRemoteAnimationRunning) { // We're already running the keyguard exit animation, likely due to an in-progress swipe Loading @@ -2605,7 +2616,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mHideAnimationRun = true; mHideAnimationRunning = true; mKeyguardViewControllerLazy.get() .startPreHideAnimation(mHideAnimationFinishedRunnable); .startPreHideAnimation(new OnHideAnimationFinished(userId)); } } Loading Loading @@ -2837,7 +2848,6 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mUpdateMonitor.setKeyguardGoingAway(true); mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(true); // Handled in WmLockscreenVisibilityManager if flag is enabled. mGoingAwayRequestedForUserId = KeyguardUpdateMonitor.getCurrentUser(); Log.d(TAG, "keyguardGoingAway requested for userId: " + mGoingAwayRequestedForUserId); Loading @@ -2848,6 +2858,15 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, // will be in order. final int keyguardFlag = flags; mUiBgExecutor.execute(() -> { int currentUserId = KeyguardUpdateMonitor.getCurrentUser(); if (mGoingAwayRequestedForUserId != currentUserId) { Log.e(TAG, "Not executing goingAwayRunnable() due to userId mismatch. " + "Requested: " + mGoingAwayRequestedForUserId + ", current: " + currentUserId); mUpdateMonitor.setKeyguardGoingAway(false); mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(false); return; } try { ActivityTaskManager.getService().keyguardGoingAway(keyguardFlag); } catch (RemoteException e) { Loading @@ -2859,12 +2878,6 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } }; private final Runnable mHideAnimationFinishedRunnable = () -> { Log.e(TAG, "mHideAnimationFinishedRunnable#run"); mHideAnimationRunning = false; tryKeyguardDone(); }; private void setUnlockAndWakeFromDream(boolean updatedValue, @WakeAndUnlockUpdateReason int reason) { if (!mOrderUnlockAndWake) { Loading Loading @@ -2988,6 +3001,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mHiding = false; if (mLockPatternUtils.isSecure(currentUserId)) { doKeyguardLocked(null); mShadeController.get().instantCollapseShade(); setShowingLocked(true /* showing */, true /* force */); } else { resetStateLocked(); dismiss(null, null); Loading Loading @@ -3491,7 +3506,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } private void resetKeyguardDonePendingLocked() { mKeyguardDonePending = false; mKeyguardDonePendingForUser = NO_KEYGUARD_DONE_PENDING; mHandler.removeMessages(KEYGUARD_DONE_PENDING_TIMEOUT); } Loading Loading @@ -3650,7 +3665,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, pw.print(" mDozing: "); pw.println(mDozing); pw.print(" mAodShowing: "); pw.println(mAodShowing); pw.print(" mWaitingUntilKeyguardVisible: "); pw.println(mWaitingUntilKeyguardVisible); pw.print(" mKeyguardDonePending: "); pw.println(mKeyguardDonePending); pw.print(" mKeyguardDonePendingForUser: "); pw.println(mKeyguardDonePendingForUser); pw.print(" mHideAnimationRun: "); pw.println(mHideAnimationRun); pw.print(" mPendingReset: "); pw.println(mPendingReset); pw.print(" mPendingLock: "); pw.println(mPendingLock); Loading Loading @@ -3948,4 +3963,26 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mRemoteCallback = remoteCallback; } } private class OnHideAnimationFinished implements Runnable { private final int mUserId; public OnHideAnimationFinished(int userId) { mUserId = userId; } public void run() { Log.d(TAG, "OnHideAnimationFinished.run(" + mUserId + ")"); mHideAnimationRunning = false; int currentUserId = KeyguardUpdateMonitor.getCurrentUser(); if (mUserId != currentUserId) { Log.e(TAG, "Not executing OnHideAnimationFinished.run() due to userId mismatch. " + "Requested: " + mUserId + ", current: " + currentUserId); mShadeController.get().instantCollapseShade(); resetStateLocked(); return; } tryKeyguardDone(mUserId); } } } packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +59 −0 Original line number Diff line number Diff line Loading @@ -887,6 +887,65 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test public void biometricAuthSuccessForCurrentUserDoesProceed() { final int currentUser = 25; setCurrentUser(currentUser, true); mViewMediator.mUpdateCallback.onBiometricAuthenticated(currentUser, null, false); verify(mDevicePolicyManager).reportSuccessfulBiometricAttempt(currentUser); } @Test public void biometricAuthSuccessForDifferentUserDoesNotProceed() { final int newUser = 40; setCurrentUser(newUser, true); final int oldUser = 25; mViewMediator.mUpdateCallback.onBiometricAuthenticated(oldUser, null, false); verify(mDevicePolicyManager, never()).reportSuccessfulBiometricAttempt(anyInt()); } @Test public void testDonePendingExecutesOnHideAnimationFinished() { final int currentUser = 25; setCurrentUser(currentUser, true); mViewMediator.mViewMediatorCallback.keyguardDonePending(true, currentUser); final ArgumentCaptor<Runnable> onHideAnimationFinished = ArgumentCaptor.forClass(Runnable.class); verify(mStatusBarKeyguardViewManager).startPreHideAnimation( onHideAnimationFinished.capture()); onHideAnimationFinished.getValue().run(); // This is executed when the user is incorrect. Should not be called verify(mShadeController, never()).instantCollapseShade(); } @Test public void testDonePendingExecutesOnHideAnimationFinishedButTerminatesWhenUserHasChanged() { final int currentUser = 25; setCurrentUser(currentUser, true); mViewMediator.mViewMediatorCallback.keyguardDonePending(true, currentUser); final ArgumentCaptor<Runnable> onHideAnimationFinished = ArgumentCaptor.forClass(Runnable.class); verify(mStatusBarKeyguardViewManager).startPreHideAnimation( onHideAnimationFinished.capture()); // User switched before runnable could execute final int newUser = 40; setCurrentUser(newUser, true); onHideAnimationFinished.getValue().run(); // This is executed when the user is incorrect verify(mShadeController).instantCollapseShade(); } @Test public void testBouncerSwipeDown() { mViewMediator.getViewMediatorCallback().onBouncerSwipeDown(); Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +65 −28 Original line number Diff line number Diff line Loading @@ -299,6 +299,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, private static final int UNOCCLUDE_ANIMATION_DURATION = 250; private static final int NO_KEYGUARD_DONE_PENDING = -10000; /** * How far down to animate the unoccluding activity, in terms of percent of the activity's * height. Loading Loading @@ -466,7 +468,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, private boolean mWaitingUntilKeyguardVisible = false; private final LockPatternUtils mLockPatternUtils; private final BroadcastDispatcher mBroadcastDispatcher; private boolean mKeyguardDonePending = false; private int mKeyguardDonePendingForUser = NO_KEYGUARD_DONE_PENDING; private boolean mUnlockingAndWakingFromDream = false; private boolean mHideAnimationRun = false; private boolean mHideAnimationRunning = false; Loading Loading @@ -763,6 +765,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, @Override public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType, boolean isStrongBiometric) { if (userId != KeyguardUpdateMonitor.getCurrentUser()) { Log.w(TAG, "onBiometricAuthenticated() invoked for userId: " + userId + ", current " + "userId: " + KeyguardUpdateMonitor.getCurrentUser()); return; } if (mLockPatternUtils.isSecure(userId)) { mLockPatternUtils.getDevicePolicyManager().reportSuccessfulBiometricAttempt( userId); Loading Loading @@ -798,8 +805,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, if (targetUserId != KeyguardUpdateMonitor.getCurrentUser()) { return; } if (DEBUG) Log.d(TAG, "keyguardDone"); tryKeyguardDone(); Log.d(TAG, "keyguardDone: " + targetUserId); tryKeyguardDone(targetUserId); } @Override Loading @@ -816,18 +823,16 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, @Override public void keyguardDonePending(boolean primaryAuth, int targetUserId) { Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDonePending"); if (DEBUG) Log.d(TAG, "keyguardDonePending"); Log.d(TAG, "keyguardDonePending: " + targetUserId); if (targetUserId != KeyguardUpdateMonitor.getCurrentUser()) { Trace.endSection(); return; } mKeyguardDonePending = true; Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDonePending"); mKeyguardDonePendingForUser = targetUserId; mHideAnimationRun = true; mHideAnimationRunning = true; mKeyguardViewControllerLazy.get() .startPreHideAnimation(mHideAnimationFinishedRunnable); .startPreHideAnimation(new OnHideAnimationFinished(targetUserId)); mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_PENDING_TIMEOUT, KEYGUARD_DONE_PENDING_TIMEOUT_MS); Trace.endSection(); Loading Loading @@ -865,9 +870,10 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, @Override public void readyForKeyguardDone() { Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#readyForKeyguardDone"); if (mKeyguardDonePending) { mKeyguardDonePending = false; tryKeyguardDone(); if (mKeyguardDonePendingForUser != NO_KEYGUARD_DONE_PENDING) { int user = mKeyguardDonePendingForUser; mKeyguardDonePendingForUser = NO_KEYGUARD_DONE_PENDING; tryKeyguardDone(user); } Trace.endSection(); } Loading Loading @@ -2369,7 +2375,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, * expecting the keyguard to go away when called. */ public void hideWithAnimation(IRemoteAnimationRunner runner) { if (!mKeyguardDonePending) { if (mKeyguardDonePendingForUser == NO_KEYGUARD_DONE_PENDING) { return; } Loading Loading @@ -2589,12 +2595,17 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } }; private void tryKeyguardDone() { if (DEBUG) { Log.d(TAG, "tryKeyguardDone: pending - " + mKeyguardDonePending + ", animRan - " + mHideAnimationRun + " animRunning - " + mHideAnimationRunning); private void tryKeyguardDone(int userId) { String logUserId; if (mKeyguardDonePendingForUser == NO_KEYGUARD_DONE_PENDING) { logUserId = "NO_KEYGUARD_DONE_PENDING"; } else { logUserId = "" + mKeyguardDonePendingForUser; } if (!mKeyguardDonePending && mHideAnimationRun && !mHideAnimationRunning) { Log.d(TAG, "tryKeyguardDone: pendingForUser - " + logUserId + ", animRan - " + mHideAnimationRun + " animRunning - " + mHideAnimationRunning); if (mKeyguardDonePendingForUser == NO_KEYGUARD_DONE_PENDING && mHideAnimationRun && !mHideAnimationRunning) { handleKeyguardDone(); } else if (mSurfaceBehindRemoteAnimationRunning) { // We're already running the keyguard exit animation, likely due to an in-progress swipe Loading @@ -2605,7 +2616,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mHideAnimationRun = true; mHideAnimationRunning = true; mKeyguardViewControllerLazy.get() .startPreHideAnimation(mHideAnimationFinishedRunnable); .startPreHideAnimation(new OnHideAnimationFinished(userId)); } } Loading Loading @@ -2837,7 +2848,6 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mUpdateMonitor.setKeyguardGoingAway(true); mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(true); // Handled in WmLockscreenVisibilityManager if flag is enabled. mGoingAwayRequestedForUserId = KeyguardUpdateMonitor.getCurrentUser(); Log.d(TAG, "keyguardGoingAway requested for userId: " + mGoingAwayRequestedForUserId); Loading @@ -2848,6 +2858,15 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, // will be in order. final int keyguardFlag = flags; mUiBgExecutor.execute(() -> { int currentUserId = KeyguardUpdateMonitor.getCurrentUser(); if (mGoingAwayRequestedForUserId != currentUserId) { Log.e(TAG, "Not executing goingAwayRunnable() due to userId mismatch. " + "Requested: " + mGoingAwayRequestedForUserId + ", current: " + currentUserId); mUpdateMonitor.setKeyguardGoingAway(false); mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(false); return; } try { ActivityTaskManager.getService().keyguardGoingAway(keyguardFlag); } catch (RemoteException e) { Loading @@ -2859,12 +2878,6 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } }; private final Runnable mHideAnimationFinishedRunnable = () -> { Log.e(TAG, "mHideAnimationFinishedRunnable#run"); mHideAnimationRunning = false; tryKeyguardDone(); }; private void setUnlockAndWakeFromDream(boolean updatedValue, @WakeAndUnlockUpdateReason int reason) { if (!mOrderUnlockAndWake) { Loading Loading @@ -2988,6 +3001,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mHiding = false; if (mLockPatternUtils.isSecure(currentUserId)) { doKeyguardLocked(null); mShadeController.get().instantCollapseShade(); setShowingLocked(true /* showing */, true /* force */); } else { resetStateLocked(); dismiss(null, null); Loading Loading @@ -3491,7 +3506,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } private void resetKeyguardDonePendingLocked() { mKeyguardDonePending = false; mKeyguardDonePendingForUser = NO_KEYGUARD_DONE_PENDING; mHandler.removeMessages(KEYGUARD_DONE_PENDING_TIMEOUT); } Loading Loading @@ -3650,7 +3665,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, pw.print(" mDozing: "); pw.println(mDozing); pw.print(" mAodShowing: "); pw.println(mAodShowing); pw.print(" mWaitingUntilKeyguardVisible: "); pw.println(mWaitingUntilKeyguardVisible); pw.print(" mKeyguardDonePending: "); pw.println(mKeyguardDonePending); pw.print(" mKeyguardDonePendingForUser: "); pw.println(mKeyguardDonePendingForUser); pw.print(" mHideAnimationRun: "); pw.println(mHideAnimationRun); pw.print(" mPendingReset: "); pw.println(mPendingReset); pw.print(" mPendingLock: "); pw.println(mPendingLock); Loading Loading @@ -3948,4 +3963,26 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mRemoteCallback = remoteCallback; } } private class OnHideAnimationFinished implements Runnable { private final int mUserId; public OnHideAnimationFinished(int userId) { mUserId = userId; } public void run() { Log.d(TAG, "OnHideAnimationFinished.run(" + mUserId + ")"); mHideAnimationRunning = false; int currentUserId = KeyguardUpdateMonitor.getCurrentUser(); if (mUserId != currentUserId) { Log.e(TAG, "Not executing OnHideAnimationFinished.run() due to userId mismatch. " + "Requested: " + mUserId + ", current: " + currentUserId); mShadeController.get().instantCollapseShade(); resetStateLocked(); return; } tryKeyguardDone(mUserId); } } }
packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +59 −0 Original line number Diff line number Diff line Loading @@ -887,6 +887,65 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { assertTrue(mViewMediator.isShowingAndNotOccluded()); } @Test public void biometricAuthSuccessForCurrentUserDoesProceed() { final int currentUser = 25; setCurrentUser(currentUser, true); mViewMediator.mUpdateCallback.onBiometricAuthenticated(currentUser, null, false); verify(mDevicePolicyManager).reportSuccessfulBiometricAttempt(currentUser); } @Test public void biometricAuthSuccessForDifferentUserDoesNotProceed() { final int newUser = 40; setCurrentUser(newUser, true); final int oldUser = 25; mViewMediator.mUpdateCallback.onBiometricAuthenticated(oldUser, null, false); verify(mDevicePolicyManager, never()).reportSuccessfulBiometricAttempt(anyInt()); } @Test public void testDonePendingExecutesOnHideAnimationFinished() { final int currentUser = 25; setCurrentUser(currentUser, true); mViewMediator.mViewMediatorCallback.keyguardDonePending(true, currentUser); final ArgumentCaptor<Runnable> onHideAnimationFinished = ArgumentCaptor.forClass(Runnable.class); verify(mStatusBarKeyguardViewManager).startPreHideAnimation( onHideAnimationFinished.capture()); onHideAnimationFinished.getValue().run(); // This is executed when the user is incorrect. Should not be called verify(mShadeController, never()).instantCollapseShade(); } @Test public void testDonePendingExecutesOnHideAnimationFinishedButTerminatesWhenUserHasChanged() { final int currentUser = 25; setCurrentUser(currentUser, true); mViewMediator.mViewMediatorCallback.keyguardDonePending(true, currentUser); final ArgumentCaptor<Runnable> onHideAnimationFinished = ArgumentCaptor.forClass(Runnable.class); verify(mStatusBarKeyguardViewManager).startPreHideAnimation( onHideAnimationFinished.capture()); // User switched before runnable could execute final int newUser = 40; setCurrentUser(newUser, true); onHideAnimationFinished.getValue().run(); // This is executed when the user is incorrect verify(mShadeController).instantCollapseShade(); } @Test public void testBouncerSwipeDown() { mViewMediator.getViewMediatorCallback().onBouncerSwipeDown(); Loading