summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Pietal <mpietal@google.com> 2024-08-12 10:56:32 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-08-12 10:56:32 +0000
commit77defd76974b751e63b78a99971219bcddf0c8ff (patch)
treeb2c497861ea1ea2d7472b90a2e169595d9f66e76
parentb6e426e1c5239fbba3bc68a0e7998e33ef9b7780 (diff)
parent807bad8e737ab757c6228afebc4915276be4488c (diff)
Merge "Fix race condition with remote animation cancel/finish" into main
-rw-r--r--packages/SystemUI/aconfig/systemui.aconfig10
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java60
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java13
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java28
4 files changed, 67 insertions, 44 deletions
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 1ff9a80c5bc0..03149928249b 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -1237,6 +1237,16 @@ flag {
}
flag {
+ name: "relock_with_power_button_immediately"
+ namespace: "systemui"
+ description: "UDFPS unlock followed by immediate power button push should relock"
+ bug: "343327511"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "lockscreen_preview_renderer_create_on_main_thread"
namespace: "systemui"
description: "Force preview renderer to be created on the main thread"
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 1f3df95b6e28..17c5977fc80a 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -42,6 +42,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.Flags.notifyPowerManagerUserActivityBackground;
import static com.android.systemui.Flags.refactorGetCurrentUser;
+import static com.android.systemui.Flags.relockWithPowerButtonImmediately;
import static com.android.systemui.Flags.translucentOccludingActivityFix;
import static com.android.systemui.keyguard.ui.viewmodel.LockscreenToDreamingTransitionViewModel.DREAMING_ANIMATION_DURATION_MS;
@@ -477,6 +478,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
private boolean mUnlockingAndWakingFromDream = false;
private boolean mHideAnimationRun = false;
private boolean mHideAnimationRunning = false;
+ private boolean mIsKeyguardExitAnimationCanceled = false;
private SoundPool mLockSounds;
private int mLockSoundId;
@@ -1588,10 +1590,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
setShowingLocked(!shouldWaitForProvisioning()
&& !mLockPatternUtils.isLockScreenDisabled(
mSelectedUserInteractor.getSelectedUserId()),
- true /* forceCallbacks */);
+ true /* forceCallbacks */, "setupLocked - keyguard service enabled");
} else {
// The system's keyguard is disabled or missing.
- setShowingLocked(false /* showing */, true /* forceCallbacks */);
+ setShowingLocked(false /* showing */, true /* forceCallbacks */,
+ "setupLocked - keyguard service disabled");
}
mKeyguardTransitions.register(
@@ -2833,9 +2836,10 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
playSound(mTrustedSoundId);
}
- private void updateActivityLockScreenState(boolean showing, boolean aodShowing) {
+ private void updateActivityLockScreenState(boolean showing, boolean aodShowing, String reason) {
mUiBgExecutor.execute(() -> {
- Log.d(TAG, "updateActivityLockScreenState(" + showing + ", " + aodShowing + ")");
+ Log.d(TAG, "updateActivityLockScreenState(" + showing + ", " + aodShowing + ", "
+ + reason + ")");
if (KeyguardWmStateRefactor.isEnabled()) {
// Handled in WmLockscreenVisibilityManager if flag is enabled.
@@ -2895,7 +2899,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
// Force if we're showing in the middle of unlocking, to ensure we end up in the
// correct state.
- setShowingLocked(true, hidingOrGoingAway /* force */);
+ setShowingLocked(true, hidingOrGoingAway /* force */, "handleShowInner");
mHiding = false;
if (!KeyguardWmStateRefactor.isEnabled()) {
@@ -3067,15 +3071,14 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
mHiding = true;
mKeyguardGoingAwayRunnable.run();
} else {
- Log.d(TAG, "Hiding keyguard while occluded. Just hide the keyguard view and exit.");
-
if (!KeyguardWmStateRefactor.isEnabled()) {
mKeyguardViewControllerLazy.get().hide(
mSystemClock.uptimeMillis() + mHideAnimation.getStartOffset(),
mHideAnimation.getDuration());
}
- onKeyguardExitFinished();
+ onKeyguardExitFinished("Hiding keyguard while occluded. Just hide the keyguard "
+ + "view and exit.");
}
// It's possible that the device was unlocked (via BOUNCER or Fingerprint) while
@@ -3106,6 +3109,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
Log.d(TAG, "handleStartKeyguardExitAnimation startTime=" + startTime
+ " fadeoutDuration=" + fadeoutDuration);
synchronized (KeyguardViewMediator.this) {
+ mIsKeyguardExitAnimationCanceled = false;
// Tell ActivityManager that we canceled the keyguard animation if
// handleStartKeyguardExitAnimation was called, but we're not hiding the keyguard,
// unless we're animating the surface behind the keyguard and will be hiding the
@@ -3125,7 +3129,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
Slog.w(TAG, "Failed to call onAnimationFinished", e);
}
}
- setShowingLocked(mShowing, true /* force */);
+ setShowingLocked(mShowing, true /* force */,
+ "handleStartKeyguardExitAnimation - canceled");
return;
}
mHiding = false;
@@ -3149,9 +3154,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
Slog.w(TAG, "Failed to call onAnimationFinished", e);
}
}
- onKeyguardExitFinished();
- mKeyguardViewControllerLazy.get().hide(0 /* startTime */,
- 0 /* fadeoutDuration */);
+ if (!mIsKeyguardExitAnimationCanceled) {
+ onKeyguardExitFinished("onRemoteAnimationFinished");
+ mKeyguardViewControllerLazy.get().hide(0 /* startTime */,
+ 0 /* fadeoutDuration */);
+ }
mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
@@ -3288,12 +3295,12 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
anim.start();
});
- onKeyguardExitFinished();
+ onKeyguardExitFinished("remote animation disabled");
}
}
}
- private void onKeyguardExitFinished() {
+ private void onKeyguardExitFinished(String reason) {
if (DEBUG) Log.d(TAG, "onKeyguardExitFinished()");
// only play "unlock" noises if not on a call (since the incall UI
// disables the keyguard)
@@ -3301,7 +3308,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
playSounds(false);
}
- setShowingLocked(false);
+ setShowingLocked(false, "onKeyguardExitFinished: " + reason);
mWakeAndUnlocking = false;
mDismissCallbackRegistry.notifyDismissSucceeded();
resetKeyguardDonePendingLocked();
@@ -3349,6 +3356,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
// A lock is pending, meaning the keyguard exit animation was cancelled because we're
// re-locking. We should just end the surface-behind animation without exiting the
// keyguard. The pending lock will be handled by onFinishedGoingToSleep().
+ if (relockWithPowerButtonImmediately()) {
+ mIsKeyguardExitAnimationCanceled = true;
+ }
finishSurfaceBehindRemoteAnimation(true /* showKeyguard */);
maybeHandlePendingLock();
} else {
@@ -3397,12 +3407,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
doKeyguardLocked(null);
finishSurfaceBehindRemoteAnimation(true /* showKeyguard */);
// Ensure WM is notified that we made a decision to show
- setShowingLocked(true /* showing */, true /* force */);
+ setShowingLocked(true /* showing */, true /* force */,
+ "exitKeyguardAndFinishSurfaceBehindRemoteAnimation - relocked");
return;
}
- onKeyguardExitFinished();
+ onKeyguardExitFinished("exitKeyguardAndFinishSurfaceBehindRemoteAnimation");
if (mKeyguardStateController.isDismissingFromSwipe() || wasShowing) {
Log.d(TAG, "onKeyguardExitRemoteAnimationFinished"
@@ -3459,7 +3470,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
mSurfaceBehindRemoteAnimationRequested = false;
mKeyguardStateController.notifyKeyguardGoingAway(false);
if (mShowing) {
- setShowingLocked(true, true);
+ setShowingLocked(true, true, "hideSurfaceBehindKeyguard");
}
}
@@ -3805,7 +3816,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
// update lock screen state in ATMS here, otherwise ATMS tries to resume activities when
// enabling doze state.
if (mShowing || !mPendingLock || !mDozeParameters.canControlUnlockedScreenOff()) {
- setShowingLocked(mShowing);
+ setShowingLocked(mShowing, "setDozing");
}
}
@@ -3815,7 +3826,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
// is 1f), then show the activity lock screen.
if (mAnimatingScreenOff && mDozing && linear == 1f) {
mAnimatingScreenOff = false;
- setShowingLocked(mShowing, true);
+ setShowingLocked(mShowing, true, "onDozeAmountChanged");
}
}
@@ -3853,11 +3864,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
}
}
- void setShowingLocked(boolean showing) {
- setShowingLocked(showing, false /* forceCallbacks */);
+ void setShowingLocked(boolean showing, String reason) {
+ setShowingLocked(showing, false /* forceCallbacks */, reason);
}
- private void setShowingLocked(boolean showing, boolean forceCallbacks) {
+ private void setShowingLocked(boolean showing, boolean forceCallbacks, String reason) {
final boolean aodShowing = mDozing && !mWakeAndUnlocking;
final boolean notifyDefaultDisplayCallbacks = showing != mShowing || forceCallbacks;
final boolean updateActivityLockScreenState = showing != mShowing
@@ -3868,9 +3879,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
notifyDefaultDisplayCallbacks(showing);
}
if (updateActivityLockScreenState) {
- updateActivityLockScreenState(showing, aodShowing);
+ updateActivityLockScreenState(showing, aodShowing, reason);
}
-
}
private void notifyDefaultDisplayCallbacks(boolean showing) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index ada3c52b16ab..c4fbc37b2dd5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -30,6 +30,7 @@ import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;
import static com.android.systemui.Flags.keyboardShortcutHelperRewrite;
import static com.android.systemui.Flags.lightRevealMigration;
import static com.android.systemui.Flags.newAodTransition;
+import static com.android.systemui.Flags.relockWithPowerButtonImmediately;
import static com.android.systemui.charging.WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL;
import static com.android.systemui.flags.Flags.SHORTCUT_LIST_SEARCH_LAYOUT;
import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF;
@@ -2352,11 +2353,13 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
} else if (mState == StatusBarState.KEYGUARD
&& !mStatusBarKeyguardViewManager.primaryBouncerIsOrWillBeShowing()
&& mStatusBarKeyguardViewManager.isSecure()) {
- Log.d(TAG, "showBouncerOrLockScreenIfKeyguard, showingBouncer");
- if (SceneContainerFlag.isEnabled()) {
- mStatusBarKeyguardViewManager.showPrimaryBouncer(true /* scrimmed */);
- } else {
- mStatusBarKeyguardViewManager.showBouncer(true /* scrimmed */);
+ if (!relockWithPowerButtonImmediately()) {
+ Log.d(TAG, "showBouncerOrLockScreenIfKeyguard, showingBouncer");
+ if (SceneContainerFlag.isEnabled()) {
+ mStatusBarKeyguardViewManager.showPrimaryBouncer(true /* scrimmed */);
+ } else {
+ mStatusBarKeyguardViewManager.showBouncer(true /* scrimmed */);
+ }
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
index e3a38a8d6763..37f1a3d73b0c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
@@ -443,7 +443,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.onSystemReady();
TestableLooper.get(this).processAllMessages();
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
TestableLooper.get(this).processAllMessages();
mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER);
@@ -463,7 +463,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.onSystemReady();
TestableLooper.get(this).processAllMessages();
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
TestableLooper.get(this).processAllMessages();
mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER);
@@ -570,7 +570,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
// When showing and provisioned
mViewMediator.onSystemReady();
when(mUpdateMonitor.isDeviceProvisioned()).thenReturn(true);
- mViewMediator.setShowingLocked(true);
+ mViewMediator.setShowingLocked(true, "");
// and a SIM becomes locked and requires a PIN
mViewMediator.mUpdateCallback.onSimStateChanged(
@@ -579,7 +579,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
TelephonyManager.SIM_STATE_PIN_REQUIRED);
// and the keyguard goes away
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
when(mKeyguardStateController.isShowing()).thenReturn(false);
mViewMediator.mUpdateCallback.onKeyguardVisibilityChanged(false);
@@ -595,7 +595,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
// When showing and provisioned
mViewMediator.onSystemReady();
when(mUpdateMonitor.isDeviceProvisioned()).thenReturn(true);
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
// and a SIM becomes locked and requires a PIN
mViewMediator.mUpdateCallback.onSimStateChanged(
@@ -604,7 +604,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
TelephonyManager.SIM_STATE_PIN_REQUIRED);
// and the keyguard goes away
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
when(mKeyguardStateController.isShowing()).thenReturn(false);
mViewMediator.mUpdateCallback.onKeyguardVisibilityChanged(false);
@@ -843,7 +843,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.onSystemReady();
TestableLooper.get(this).processAllMessages();
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
TestableLooper.get(this).processAllMessages();
mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER);
@@ -863,7 +863,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.onSystemReady();
TestableLooper.get(this).processAllMessages();
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
TestableLooper.get(this).processAllMessages();
mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER);
@@ -978,7 +978,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
@Test
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public void testDoKeyguardWhileInteractive_resets() {
- mViewMediator.setShowingLocked(true);
+ mViewMediator.setShowingLocked(true, "");
when(mKeyguardStateController.isShowing()).thenReturn(true);
TestableLooper.get(this).processAllMessages();
@@ -992,7 +992,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
@Test
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public void testDoKeyguardWhileNotInteractive_showsInsteadOfResetting() {
- mViewMediator.setShowingLocked(true);
+ mViewMediator.setShowingLocked(true, "");
when(mKeyguardStateController.isShowing()).thenReturn(true);
TestableLooper.get(this).processAllMessages();
@@ -1051,7 +1051,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.onSystemReady();
processAllMessagesAndBgExecutorMessages();
- mViewMediator.setShowingLocked(true);
+ mViewMediator.setShowingLocked(true, "");
RemoteAnimationTarget[] apps = new RemoteAnimationTarget[]{
mock(RemoteAnimationTarget.class)
@@ -1123,7 +1123,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
@Test
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public void testNotStartingKeyguardWhenFlagIsDisabled() {
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
when(mKeyguardStateController.isShowing()).thenReturn(false);
mViewMediator.onDreamingStarted();
@@ -1133,7 +1133,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
@Test
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public void testStartingKeyguardWhenFlagIsEnabled() {
- mViewMediator.setShowingLocked(true);
+ mViewMediator.setShowingLocked(true, "");
when(mKeyguardStateController.isShowing()).thenReturn(true);
mViewMediator.onDreamingStarted();
@@ -1174,7 +1174,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
TestableLooper.get(this).processAllMessages();
// WHEN keyguard visibility becomes FALSE
- mViewMediator.setShowingLocked(false);
+ mViewMediator.setShowingLocked(false, "");
keyguardUpdateMonitorCallback.onKeyguardVisibilityChanged(false);
TestableLooper.get(this).processAllMessages();