From 6096b1a59705fd3cdec617c9a95f3cd00935ab76 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 7 Jul 2022 12:56:52 -0700 Subject: [PATCH] [Keyguard] Fix unlock animation for occluded LS. When we open shade from dream (which is in an occluded keyguard state) and open settings. We are prompted to authenticate with the bouncer. Upon doing so, the app hangs in keyguard even though the user is no unlocked. In order to fix this, we opt not to defer keyguard done when keyguard is occluded. Test: Manual and a unit test Bug: 228064734 Change-Id: I58aebe033f069dc6bedb3ad3a78da849ed29dc78 --- .../statusbar/phone/CentralSurfacesImpl.java | 7 ++++++- .../phone/CentralSurfacesImplTest.java | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) 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 2daa4759457d0..5a227957e7451 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -2560,8 +2560,13 @@ public class CentralSurfacesImpl extends CoreStartable implements callback.onActivityStarted(ActivityManager.START_CANCELED); } }; + // Do not deferKeyguard when occluded because, when keyguard is occluded, + // we do not launch the activity until keyguard is done. + boolean occluded = mStatusBarKeyguardViewManager.isShowing() + && mStatusBarKeyguardViewManager.isOccluded(); + boolean deferred = !occluded; executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShadeDirectly, - willLaunchResolverActivity, true /* deferred */, animate); + willLaunchResolverActivity, deferred /* deferred */, animate); } @Nullable diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index b4532c4314157..79b186a60398f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -19,6 +19,8 @@ package com.android.systemui.statusbar.phone; import static android.app.NotificationManager.IMPORTANCE_HIGH; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; +import static com.google.common.truth.Truth.assertThat; + import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static junit.framework.TestCase.fail; @@ -44,6 +46,7 @@ import android.app.WallpaperManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.ContentResolver; +import android.content.Intent; import android.content.IntentFilter; import android.hardware.devicestate.DeviceStateManager; import android.hardware.display.AmbientDisplayConfiguration; @@ -999,6 +1002,22 @@ public class CentralSurfacesImplTest extends SysuiTestCase { verify(mStatusBarStateController, never()).setLeaveOpenOnKeyguardHide(true); } + @Test + public void startActivityDismissingKeyguard_isShowingandIsOccluded() { + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); + when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(true); + mCentralSurfaces.startActivityDismissingKeyguard( + new Intent(), + /* onlyProvisioned = */false, + /* dismissShade = */false); + verify(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any(Runnable.class)); + ArgumentCaptor onDismissActionCaptor = + ArgumentCaptor.forClass(OnDismissAction.class); + verify(mStatusBarKeyguardViewManager) + .dismissWithAction(onDismissActionCaptor.capture(), any(Runnable.class), eq(true)); + assertThat(onDismissActionCaptor.getValue().onDismiss()).isFalse(); + } + private void setDeviceState(int state) { ArgumentCaptor callbackCaptor = ArgumentCaptor.forClass(DeviceStateManager.DeviceStateCallback.class);