From d4b815cf9740b54cd20cb362ea3720ca28303b68 Mon Sep 17 00:00:00 2001 From: Cosmin Băieș Date: Fri, 26 Apr 2024 23:03:05 +0200 Subject: Fix NotificationShade toggling FLAG_NOT_FOCUSABLE This fixes some issues caused by the NotificationShade becoming focusable momentarily (by temporarily toggling off FLAG_NOT_FOCUSABLE on their window) when locking the screen and animating in AOD. This is essentially a revert of [1], which meant to make the window focusable to block touches on the app under the NotificationShade window. The problem with this approach is that focusability does not impact where the touch events are actually dispatched, so it didn't fix the original issue, but does create issues with the IME. [1]: I81843d4901f6f3bb0bb00f3d8eaa713da494b0fe Test: FlickerTestsIme2:com.android.server.wm.flicker.ime.ShowImeOnUnlockScreenTest Bug: 300446848 Flag: NONE Change-Id: Ief3a46664ef87e4c23c732189867eda63e9e5688 --- .../NotificationShadeWindowControllerImplTest.java | 1 - .../NotificationShadeWindowControllerImpl.java | 14 +-- .../keyguard/KeyguardViewMediatorTest.java | 1 - .../com/android/systemui/wmshell/BubblesTest.java | 3 - .../android/systemui/kosmos/KosmosJavaAdapter.kt | 2 - tests/FlickerTests/IME/AndroidTestTemplate.xml | 2 + .../wm/flicker/ime/ShowImeOnUnlockScreenTest.kt | 101 +++++++++++++++++++++ 7 files changed, 105 insertions(+), 19 deletions(-) create mode 100644 tests/FlickerTests/IME/src/com/android/server/wm/flicker/ime/ShowImeOnUnlockScreenTest.kt diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java index a8da1160c503..03bd9f8f27be 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java @@ -155,7 +155,6 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { mColorExtractor, mDumpManager, mKeyguardStateController, - mKosmos.getScreenOffAnimationController(), mAuthController, mKosmos::getShadeInteractor, mShadeWindowLogger, diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowControllerImpl.java index 8b7e11c4ab47..4a636d28aa88 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowControllerImpl.java @@ -68,7 +68,6 @@ import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBypassController; -import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.StatusBarWindowCallback; import com.android.systemui.statusbar.policy.ConfigurationController; @@ -131,7 +130,6 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW mCallbacks = new ArrayList<>(); private final SysuiColorExtractor mColorExtractor; - private final ScreenOffAnimationController mScreenOffAnimationController; /** * Layout params would be aggregated and dispatched all at once if this is > 0. * @@ -159,7 +157,6 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW SysuiColorExtractor colorExtractor, DumpManager dumpManager, KeyguardStateController keyguardStateController, - ScreenOffAnimationController screenOffAnimationController, AuthController authController, Lazy shadeInteractorLazy, ShadeWindowLogger logger, @@ -179,7 +176,6 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW mKeyguardBypassController = keyguardBypassController; mBackgroundExecutor = backgroundExecutor; mColorExtractor = colorExtractor; - mScreenOffAnimationController = screenOffAnimationController; // prefix with {slow} to make sure this dumps at the END of the critical section. dumpManager.registerCriticalDumpable("{slow}NotificationShadeWindowControllerImpl", this); mAuthController = authController; @@ -441,14 +437,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW private void applyFocusableFlag(NotificationShadeWindowState state) { boolean panelFocusable = state.notificationShadeFocusable && state.shadeOrQsExpanded; if (state.bouncerShowing && (state.keyguardOccluded || state.keyguardNeedsInput) - || ENABLE_REMOTE_INPUT && state.remoteInputActive - // Make the panel focusable if we're doing the screen off animation, since the light - // reveal scrim is drawing in the panel and should consume touch events so that they - // don't go to the app behind. - || mScreenOffAnimationController.shouldIgnoreKeyguardTouches()) { - mLpChanged.flags &= ~LayoutParams.FLAG_NOT_FOCUSABLE; - mLpChanged.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; - } else if (state.glanceableHubShowing) { + || (ENABLE_REMOTE_INPUT && state.remoteInputActive) + || state.glanceableHubShowing) { mLpChanged.flags &= ~LayoutParams.FLAG_NOT_FOCUSABLE; mLpChanged.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; } else if (state.isKeyguardShowingAndNotOccluded() || panelFocusable) { 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 709f7797d2bf..8aea2f16734e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -262,7 +262,6 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { mColorExtractor, mDumpManager, mKeyguardStateController, - mScreenOffAnimationController, mAuthController, () -> mShadeInteractor, mShadeWindowLogger, diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index d9a0c4be04ff..18b1705a5f90 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -338,8 +338,6 @@ public class BubblesTest extends SysuiTestCase { @Mock private KeyguardStateController mKeyguardStateController; @Mock - private ScreenOffAnimationController mScreenOffAnimationController; - @Mock Transitions mTransitions; @Mock private Optional mOneHandedOptional; @@ -491,7 +489,6 @@ public class BubblesTest extends SysuiTestCase { mColorExtractor, mDumpManager, mKeyguardStateController, - mScreenOffAnimationController, mAuthController, () -> mShadeInteractor, mShadeWindowLogger, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt index d4b793720328..a81ac038b38a 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt @@ -56,7 +56,6 @@ import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.shade.shadeController import com.android.systemui.statusbar.notification.stack.domain.interactor.sharedNotificationContainerInteractor -import com.android.systemui.statusbar.phone.screenOffAnimationController import com.android.systemui.statusbar.pipeline.mobile.data.repository.fakeMobileConnectionsRepository import com.android.systemui.statusbar.policy.data.repository.fakeDeviceProvisioningRepository import com.android.systemui.statusbar.policy.domain.interactor.deviceProvisioningInteractor @@ -90,7 +89,6 @@ class KosmosJavaAdapter( val simBouncerInteractor by lazy { kosmos.simBouncerInteractor } val statusBarStateController by lazy { kosmos.statusBarStateController } val interactionJankMonitor by lazy { kosmos.interactionJankMonitor } - val screenOffAnimationController by lazy { kosmos.screenOffAnimationController } val fakeSceneContainerConfig by lazy { kosmos.sceneContainerConfig } val sceneInteractor by lazy { kosmos.sceneInteractor } val falsingCollector by lazy { kosmos.falsingCollector } diff --git a/tests/FlickerTests/IME/AndroidTestTemplate.xml b/tests/FlickerTests/IME/AndroidTestTemplate.xml index 988f76f4175c..38442db699f8 100644 --- a/tests/FlickerTests/IME/AndroidTestTemplate.xml +++ b/tests/FlickerTests/IME/AndroidTestTemplate.xml @@ -10,6 +10,8 @@