From 40016bffce8bf60302fc09c2cdf62e31045a22a5 Mon Sep 17 00:00:00 2001 From: Candice Lo Date: Mon, 15 May 2023 04:10:00 +0000 Subject: [PATCH] Hide Quick Settings shade when the FontScalingDialog is opened When the users try to modify the font size through the Quick Settings, we would like to hide the QS shade so users could see the text content upderlying when they are modifying the font scale. We consider the following cases: 1. Screen unlocked: hide the shade and show the dialog 2. Screen locked: dismiss keyguard, hide the shade, and show the dialog Bug: 282110776 Test: manually - attach video to the bug Test: atest FontScalingTileTest Change-Id: I66a1c6b5df903c671b4b9c0eab178c5b6de99d61 --- .../systemui/qs/tiles/FontScalingTile.kt | 21 ++++++++-- .../systemui/qs/tiles/FontScalingTileTest.kt | 40 ++++++++++++++++++- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/FontScalingTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/FontScalingTile.kt index 1e227e513ba24..423fa80cacdb4 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/FontScalingTile.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/FontScalingTile.kt @@ -40,6 +40,7 @@ import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.phone.SystemUIDialog +import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.SystemSettings @@ -58,6 +59,7 @@ constructor( statusBarStateController: StatusBarStateController, activityStarter: ActivityStarter, qsLogger: QSLogger, + private val keyguardStateController: KeyguardStateController, private val dialogLaunchAnimator: DialogLaunchAnimator, private val systemSettings: SystemSettings, private val secureSettings: SecureSettings, @@ -88,7 +90,10 @@ constructor( } override fun handleClick(view: View?) { - mUiHandler.post { + // We animate from the touched view only if we are not on the keyguard + val animateFromView: Boolean = view != null && !keyguardStateController.isShowing + + val runnable = Runnable { val dialog: SystemUIDialog = FontScalingDialog( mContext, @@ -99,16 +104,26 @@ constructor( mainHandler, backgroundDelayableExecutor ) - if (view != null) { + if (animateFromView) { dialogLaunchAnimator.showFromView( dialog, - view, + view!!, DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, INTERACTION_JANK_TAG) ) } else { dialog.show() } } + + mainHandler.post { + mActivityStarter.executeRunnableDismissingKeyguard( + runnable, + /* cancelAction= */ null, + /* dismissShade= */ true, + /* afterKeyguardGone= */ true, + /* deferred= */ false + ) + } } override fun handleUpdateState(state: QSTile.State?, arg: Any?) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt index 1670a4248e26a..cbc3553805688 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt @@ -34,6 +34,7 @@ import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.settings.UserTracker +import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq @@ -45,8 +46,11 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.anyBoolean +import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @@ -63,6 +67,7 @@ class FontScalingTileTest : SysuiTestCase() { @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator @Mock private lateinit var uiEventLogger: QsEventLogger @Mock private lateinit var userTracker: UserTracker + @Mock private lateinit var keyguardStateController: KeyguardStateController private lateinit var testableLooper: TestableLooper private lateinit var systemClock: FakeSystemClock @@ -71,6 +76,8 @@ class FontScalingTileTest : SysuiTestCase() { val featureFlags = FakeFeatureFlags() + @Captor private lateinit var argumentCaptor: ArgumentCaptor + @Before fun setUp() { MockitoAnnotations.initMocks(this) @@ -90,6 +97,7 @@ class FontScalingTileTest : SysuiTestCase() { statusBarStateController, activityStarter, qsLogger, + keyguardStateController, dialogLaunchAnimator, FakeSettings(), FakeSettings(), @@ -127,14 +135,44 @@ class FontScalingTileTest : SysuiTestCase() { } @Test - fun clickTile_showDialog() { + fun clickTile_screenUnlocked_showDialogAnimationFromView() { + `when`(keyguardStateController.isShowing).thenReturn(false) val view = View(context) fontScalingTile.click(view) testableLooper.processAllMessages() + verify(activityStarter) + .executeRunnableDismissingKeyguard( + argumentCaptor.capture(), + eq(null), + eq(true), + eq(true), + eq(false) + ) + argumentCaptor.value.run() verify(dialogLaunchAnimator).showFromView(any(), eq(view), nullable(), anyBoolean()) } + @Test + fun clickTile_onLockScreen_neverShowDialogAnimationFromView() { + `when`(keyguardStateController.isShowing).thenReturn(true) + val view = View(context) + fontScalingTile.click(view) + testableLooper.processAllMessages() + + verify(activityStarter) + .executeRunnableDismissingKeyguard( + argumentCaptor.capture(), + eq(null), + eq(true), + eq(true), + eq(false) + ) + argumentCaptor.value.run() + verify(dialogLaunchAnimator, never()) + .showFromView(any(), eq(view), nullable(), anyBoolean()) + } + @Test fun getLongClickIntent_getExpectedIntent() { val intent: Intent? = fontScalingTile.getLongClickIntent()