Loading packages/SystemUI/aconfig/systemui.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -2169,3 +2169,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 } } packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt +10 −5 Original line number Diff line number Diff line Loading @@ -41,6 +41,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 Loading Loading @@ -320,7 +321,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 Loading @@ -340,8 +345,8 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() { } helper.toggle(deviceId = 123) customizeShortcut(customizationRequest = ctrlAltAShortcutDeleteRequest) assertThat(customInputGestures).containsExactly(ctrlAltBShortcut) customizeShortcut(customizationRequest = ctrlAltBShortcutDeleteRequest) assertThat(customInputGestures).containsExactly(ctrlAltAShortcut) } } Loading Loading @@ -493,7 +498,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), Loading @@ -501,7 +506,7 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() { shortcutCommand { key("Ctrl") key("Alt") key("A") key("B") }, ) Loading packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt +33 −19 Original line number Diff line number Diff line Loading @@ -28,6 +28,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 Loading Loading @@ -152,15 +153,21 @@ constructor( private fun retrieveInputGestureDataForShortcutBeingDeleted(): InputGestureData? { val keyGestureTypeForShortcutBeingDeleted = getKeyGestureTypeForShortcutBeingCustomized() if (appShortcutRemovalFix()) { val inputGesturesMatchingKeyGestureType = customInputGesturesRepository.retrieveCustomInputGestures().filter { it.action.keyGestureType() == keyGestureTypeForShortcutBeingDeleted } return if (keyGestureTypeForShortcutBeingDeleted == KEY_GESTURE_TYPE_LAUNCH_APPLICATION) { 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") Log.w( TAG, "Requested to delete custom shortcut but customShortcutCommand was null", ) return null } Loading @@ -173,6 +180,11 @@ constructor( } else { inputGesturesMatchingKeyGestureType.firstOrNull() } } else { return customInputGesturesRepository.retrieveCustomInputGestures().firstOrNull { it.action.keyGestureType() == keyGestureTypeForShortcutBeingDeleted } } } suspend fun confirmAndSetShortcutCurrentlyBeingCustomized(): Loading Loading @@ -261,10 +273,12 @@ constructor( if (defaultShortcutCommand == null) { AppLaunchData.createLaunchDataForComponent( /* packageName= */ shortcutBeingCustomized.packageName, /* className= */ shortcutBeingCustomized.className /* className= */ shortcutBeingCustomized.className, ) } else { appLaunchDataRepository.getAppLaunchDataForShortcutWithCommand(defaultShortcutCommand) appLaunchDataRepository.getAppLaunchDataForShortcutWithCommand( defaultShortcutCommand ) } return if (appLaunchData == null) this else this.setAppLaunchData(appLaunchData) Loading Loading
packages/SystemUI/aconfig/systemui.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -2169,3 +2169,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 } }
packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt +10 −5 Original line number Diff line number Diff line Loading @@ -41,6 +41,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 Loading Loading @@ -320,7 +321,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 Loading @@ -340,8 +345,8 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() { } helper.toggle(deviceId = 123) customizeShortcut(customizationRequest = ctrlAltAShortcutDeleteRequest) assertThat(customInputGestures).containsExactly(ctrlAltBShortcut) customizeShortcut(customizationRequest = ctrlAltBShortcutDeleteRequest) assertThat(customInputGestures).containsExactly(ctrlAltAShortcut) } } Loading Loading @@ -493,7 +498,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), Loading @@ -501,7 +506,7 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() { shortcutCommand { key("Ctrl") key("Alt") key("A") key("B") }, ) Loading
packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt +33 −19 Original line number Diff line number Diff line Loading @@ -28,6 +28,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 Loading Loading @@ -152,15 +153,21 @@ constructor( private fun retrieveInputGestureDataForShortcutBeingDeleted(): InputGestureData? { val keyGestureTypeForShortcutBeingDeleted = getKeyGestureTypeForShortcutBeingCustomized() if (appShortcutRemovalFix()) { val inputGesturesMatchingKeyGestureType = customInputGesturesRepository.retrieveCustomInputGestures().filter { it.action.keyGestureType() == keyGestureTypeForShortcutBeingDeleted } return if (keyGestureTypeForShortcutBeingDeleted == KEY_GESTURE_TYPE_LAUNCH_APPLICATION) { 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") Log.w( TAG, "Requested to delete custom shortcut but customShortcutCommand was null", ) return null } Loading @@ -173,6 +180,11 @@ constructor( } else { inputGesturesMatchingKeyGestureType.firstOrNull() } } else { return customInputGesturesRepository.retrieveCustomInputGestures().firstOrNull { it.action.keyGestureType() == keyGestureTypeForShortcutBeingDeleted } } } suspend fun confirmAndSetShortcutCurrentlyBeingCustomized(): Loading Loading @@ -261,10 +273,12 @@ constructor( if (defaultShortcutCommand == null) { AppLaunchData.createLaunchDataForComponent( /* packageName= */ shortcutBeingCustomized.packageName, /* className= */ shortcutBeingCustomized.className /* className= */ shortcutBeingCustomized.className, ) } else { appLaunchDataRepository.getAppLaunchDataForShortcutWithCommand(defaultShortcutCommand) appLaunchDataRepository.getAppLaunchDataForShortcutWithCommand( defaultShortcutCommand ) } return if (appLaunchData == null) this else this.setAppLaunchData(appLaunchData) Loading