summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Josh <jmokut@google.com> 2025-03-26 14:17:13 +0000
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-04-01 20:41:25 -0700
commit54ae6a1b53c61ab5070181f6744d46ed5b534d2e (patch)
treee8a5c30496c5e149f1db123bec07c4fb83e05f1e
parentb8cfe84aa73e440d0b38ff43a94a6170afcf8dcf (diff)
Added Bugfix Flag to guard App Shortcut Removal Fix.
Adding flag to guard this Fix ag/32498740 Also modified test so that it fails with flag off and passes with flag on - This makes more sense. Test: CustomShortcutCategoriesRepositoryTest Flag: com.android.systemui.app_shortcut_removal_fix Fix: 405058325 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:c92830fb84aa243989f431a4dd5a03cfeb26309a) (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:ed6b6d67dd70db84c7654979b91ae214615748bf) Merged-In: I90c3361b75cacecac8045d3061fb0e588c5b3661 Change-Id: I90c3361b75cacecac8045d3061fb0e588c5b3661
-rw-r--r--packages/SystemUI/aconfig/systemui.aconfig10
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt44
3 files changed, 48 insertions, 21 deletions
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 3cda579aaf7b..e344566f97a3 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -2207,3 +2207,13 @@ flag {
description: "Enables global actions focus on TV."
bug: "402759931"
}
+
+flag {
+ name: "app_shortcut_removal_fix"
+ namespace: "systemui"
+ description: "During custom app shortcut removal, use custom shortcut command as key to find the right InputGestureData to be deleted"
+ bug: "405058325"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt
index 0064c09f24ec..033b9f29d39e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt
@@ -40,6 +40,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.hardware.input.Flags.FLAG_ENABLE_CUSTOMIZABLE_INPUT_GESTURES
import com.android.hardware.input.Flags.FLAG_USE_KEY_GESTURE_EVENT_HANDLER
+import com.android.systemui.Flags.FLAG_APP_SHORTCUT_REMOVAL_FIX
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyboard.shared.model.ShortcutCustomizationRequestResult
@@ -296,7 +297,11 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() {
}
@Test
- @EnableFlags(FLAG_ENABLE_CUSTOMIZABLE_INPUT_GESTURES, FLAG_USE_KEY_GESTURE_EVENT_HANDLER)
+ @EnableFlags(
+ FLAG_ENABLE_CUSTOMIZABLE_INPUT_GESTURES,
+ FLAG_USE_KEY_GESTURE_EVENT_HANDLER,
+ FLAG_APP_SHORTCUT_REMOVAL_FIX,
+ )
fun removeAppCategoryShortcut_successfullyRetrievesGestureDataAndDeletesTheCorrectShortcut() {
testScope.runTest {
// We are collecting this because the flow is a cold flow but we need its value as a
@@ -316,8 +321,8 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() {
}
helper.toggle(deviceId = 123)
- customizeShortcut(customizationRequest = ctrlAltAShortcutDeleteRequest)
- assertThat(customInputGestures).containsExactly(ctrlAltBShortcut)
+ customizeShortcut(customizationRequest = ctrlAltBShortcutDeleteRequest)
+ assertThat(customInputGestures).containsExactly(ctrlAltAShortcut)
}
}
@@ -469,7 +474,7 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() {
private val ctrlAltAShortcut = simpleInputGestureDataForAppLaunchShortcut()
private val ctrlAltBShortcut = simpleInputGestureDataForAppLaunchShortcut(keyCode = KEYCODE_B)
- private val ctrlAltAShortcutDeleteRequest =
+ private val ctrlAltBShortcutDeleteRequest =
SingleShortcutCustomization.Delete(
categoryType = ShortcutCategoryType.AppCategories,
subCategoryLabel = context.getString(R.string.keyboard_shortcut_group_applications),
@@ -477,7 +482,7 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() {
shortcutCommand {
key("Ctrl")
key("Alt")
- key("A")
+ key("B")
},
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt
index 4e200a3f182f..5602d0996b15 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt
@@ -27,6 +27,7 @@ import android.hardware.input.KeyGestureEvent.KeyGestureType
import android.hardware.input.KeyGlyphMap
import android.util.Log
import androidx.annotation.VisibleForTesting
+import com.android.systemui.Flags.appShortcutRemovalFix
import com.android.systemui.Flags.shortcutHelperKeyGlyph
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
@@ -151,26 +152,37 @@ constructor(
private fun retrieveInputGestureDataForShortcutBeingDeleted(): InputGestureData? {
val keyGestureTypeForShortcutBeingDeleted = getKeyGestureTypeForShortcutBeingCustomized()
- val inputGesturesMatchingKeyGestureType =
- customInputGesturesRepository.retrieveCustomInputGestures().filter {
- it.action.keyGestureType() == keyGestureTypeForShortcutBeingDeleted
- }
+ if (appShortcutRemovalFix()) {
+ val inputGesturesMatchingKeyGestureType =
+ customInputGesturesRepository.retrieveCustomInputGestures().filter {
+ it.action.keyGestureType() == keyGestureTypeForShortcutBeingDeleted
+ }
- return if (keyGestureTypeForShortcutBeingDeleted == KEY_GESTURE_TYPE_LAUNCH_APPLICATION) {
- val shortcutBeingDeleted = getShortcutBeingCustomized() as Delete
- if (shortcutBeingDeleted.customShortcutCommand == null){
- Log.w(TAG, "Requested to delete custom shortcut but customShortcutCommand was null")
- return null
- }
+ return if (
+ keyGestureTypeForShortcutBeingDeleted == KEY_GESTURE_TYPE_LAUNCH_APPLICATION
+ ) {
+ val shortcutBeingDeleted = getShortcutBeingCustomized() as Delete
+ if (shortcutBeingDeleted.customShortcutCommand == null) {
+ Log.w(
+ TAG,
+ "Requested to delete custom shortcut but customShortcutCommand was null",
+ )
+ return null
+ }
- inputGesturesMatchingKeyGestureType.firstOrNull {
- checkShortcutKeyTriggerEquality(
- it.trigger,
- shortcutBeingDeleted.customShortcutCommand.keys,
- ) ?: false
+ inputGesturesMatchingKeyGestureType.firstOrNull {
+ checkShortcutKeyTriggerEquality(
+ it.trigger,
+ shortcutBeingDeleted.customShortcutCommand.keys,
+ ) ?: false
+ }
+ } else {
+ inputGesturesMatchingKeyGestureType.firstOrNull()
}
} else {
- inputGesturesMatchingKeyGestureType.firstOrNull()
+ return customInputGesturesRepository.retrieveCustomInputGestures().firstOrNull {
+ it.action.keyGestureType() == keyGestureTypeForShortcutBeingDeleted
+ }
}
}