diff options
| author | 2024-06-13 15:13:09 +0100 | |
|---|---|---|
| committer | 2024-06-13 15:13:09 +0100 | |
| commit | 6ad9ea81fe44458c9563ab122c76306909165cdb (patch) | |
| tree | 11d06237810fa38f871f63175028487b822b7d28 | |
| parent | 64e23d81a5cc97fa85608bc5ff88d77077fe31ac (diff) | |
Shortcut Helper - Close the helper on CLOSE_SYSTEM_DIALOGS broadcast
The flag was already set to finishOnCloseSystemDialogs in the
AndroidManifest, but wasn't working.
The new approach is to manually register a broadcast receiver.
Flag: com.android.systemui.keyboard_shortcut_helper_rewrite
Test: Manual
Test: ShortcutHelperViewModelTest
Fixes: 343914445
Change-Id: I9751f37c70776cdafd123a416756c5954cb7e93b
4 files changed, 23 insertions, 2 deletions
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 8a99263637af..23682e323114 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -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> diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/ShortcutHelperRepository.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/ShortcutHelperRepository.kt index 9450af4c804e..cb9961160793 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/ShortcutHelperRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/ShortcutHelperRepository.kt @@ -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() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyboard/shortcut/ui/viewmodel/ShortcutHelperViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyboard/shortcut/ui/viewmodel/ShortcutHelperViewModelTest.kt index 34b2aaf8b57a..c985199a97a7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyboard/shortcut/ui/viewmodel/ShortcutHelperViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyboard/shortcut/ui/viewmodel/ShortcutHelperViewModelTest.kt @@ -103,6 +103,17 @@ class ShortcutHelperViewModelTest : SysuiTestCase() { } @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 { val shouldShowValues by collectValues(viewModel.shouldShow) diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyboard/shortcut/data/repository/ShortcutHelperTestHelper.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyboard/shortcut/data/repository/ShortcutHelperTestHelper.kt index 772ce415a6e9..e6e7b8796d39 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyboard/shortcut/data/repository/ShortcutHelperTestHelper.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyboard/shortcut/data/repository/ShortcutHelperTestHelper.kt @@ -32,6 +32,13 @@ class ShortcutHelperTestHelper( repo.start() } + fun hideThroughCloseSystemDialogs() { + fakeBroadcastDispatcher.sendIntentToMatchingReceiversOnly( + context, + Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS) + ) + } + fun hideFromActivity() { fakeBroadcastDispatcher.sendIntentToMatchingReceiversOnly( context, |