Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 185dbdef authored by Chris Göllner's avatar Chris Göllner Committed by Android (Google) Code Review
Browse files

Merge "Shortcut Helper - Close the helper on CLOSE_SYSTEM_DIALOGS broadcast" into main

parents fcafa1c9 6ad9ea81
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1110,7 +1110,6 @@
        <activity android:name="com.android.systemui.keyboard.shortcut.ui.view.ShortcutHelperActivity"
            android:exported="false"
            android:theme="@style/ShortcutHelperTheme"
            android:excludeFromRecents="true"
            android:finishOnCloseSystemDialogs="true" />
            android:excludeFromRecents="true" />
    </application>
</manifest>
+4 −0
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@ constructor(
            action = Intent.ACTION_DISMISS_KEYBOARD_SHORTCUTS,
            onReceive = { state.value = Inactive }
        )
        registerBroadcastReceiver(
            action = Intent.ACTION_CLOSE_SYSTEM_DIALOGS,
            onReceive = { state.value = Inactive }
        )
        commandQueue.addCallback(
            object : CommandQueue.Callbacks {
                override fun dismissKeyboardShortcutsMenu() {
+11 −0
Original line number Diff line number Diff line
@@ -102,6 +102,17 @@ class ShortcutHelperViewModelTest : SysuiTestCase() {
            assertThat(shouldShow).isFalse()
        }

    @Test
    fun shouldShow_falseAfterCloseSystemDialogs() =
        testScope.runTest {
            val shouldShow by collectLastValue(viewModel.shouldShow)

            testHelper.showFromActivity()
            testHelper.hideThroughCloseSystemDialogs()

            assertThat(shouldShow).isFalse()
        }

    @Test
    fun shouldShow_doesNotEmitDuplicateValues() =
        testScope.runTest {
+7 −0
Original line number Diff line number Diff line
@@ -32,6 +32,13 @@ class ShortcutHelperTestHelper(
        repo.start()
    }

    fun hideThroughCloseSystemDialogs() {
        fakeBroadcastDispatcher.sendIntentToMatchingReceiversOnly(
            context,
            Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
        )
    }

    fun hideFromActivity() {
        fakeBroadcastDispatcher.sendIntentToMatchingReceiversOnly(
            context,