Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt +29 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.keyboard.shortcut.data.repository import android.content.Context import android.content.Context.INPUT_SERVICE import android.hardware.input.AppLaunchData import android.hardware.input.AppLaunchData.ComponentData import android.hardware.input.AppLaunchData.RoleData import android.hardware.input.InputGestureData import android.hardware.input.InputGestureData.createKeyTrigger Loading Loading @@ -280,6 +281,29 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() { assertThat(inputGestureData?.action?.appLaunchData()).isNotNull() } @Test fun buildInputGestureDataForAppLaunchShortcut_addsComponentDataForNonDefaultAppShortcuts() = testScope.runTest { helper.toggle(deviceId = 123) repo.onCustomizationRequested( SingleShortcutCustomization.Add( categoryType = ShortcutCategoryType.AppCategories, defaultShortcutCommand = null, packageName = TEST_PACKAGE, className = TEST_CLASS, ) ) repo.updateUserKeyCombination(standardKeyCombination) val inputGestureData = repo.buildInputGestureDataForShortcutBeingCustomized() assertThat(inputGestureData?.action?.appLaunchData()) .isEqualTo( ComponentData(/* packageName= */ TEST_PACKAGE, /* className= */ TEST_CLASS) ) } @Test @EnableFlags(FLAG_ENABLE_CUSTOMIZABLE_INPUT_GESTURES, FLAG_USE_KEY_GESTURE_EVENT_HANDLER) fun deleteShortcut_successfullyRetrievesGestureDataAndDeletesShortcut() { Loading Loading @@ -480,4 +504,9 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() { key("A") }, ) private companion object { const val TEST_PACKAGE = "com.test.package" const val TEST_CLASS = "TestClass" } } packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt +10 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.keyboard.shortcut.data.repository import android.hardware.input.AppLaunchData import android.hardware.input.InputGestureData import android.hardware.input.InputGestureData.Builder import android.hardware.input.InputGestureData.KeyTrigger Loading Loading @@ -255,9 +256,16 @@ constructor( return this } val defaultShortcutCommand = shortcutBeingCustomized.defaultShortcutCommand ?: return this val defaultShortcutCommand = shortcutBeingCustomized.defaultShortcutCommand val appLaunchData = if (defaultShortcutCommand == null) { AppLaunchData.createLaunchDataForComponent( /* packageName= */ shortcutBeingCustomized.packageName, /* className= */ shortcutBeingCustomized.className ) } else{ appLaunchDataRepository.getAppLaunchDataForShortcutWithCommand(defaultShortcutCommand) } return if (appLaunchData == null) this else this.setAppLaunchData(appLaunchData) } Loading packages/SystemUI/src/com/android/systemui/keyboard/shortcut/shared/model/ShortcutCustomizationRequestInfo.kt +6 −0 Original line number Diff line number Diff line Loading @@ -23,12 +23,16 @@ sealed interface ShortcutCustomizationRequestInfo { val categoryType: ShortcutCategoryType val subCategoryLabel: String val defaultShortcutCommand: ShortcutCommand? val packageName: String val className: String data class Add( override val label: String = "", override val categoryType: ShortcutCategoryType = ShortcutCategoryType.System, override val subCategoryLabel: String = "", override val defaultShortcutCommand: ShortcutCommand? = null, override val packageName: String = "", override val className: String = "", ) : SingleShortcutCustomization data class Delete( Loading @@ -37,6 +41,8 @@ sealed interface ShortcutCustomizationRequestInfo { override val subCategoryLabel: String = "", override val defaultShortcutCommand: ShortcutCommand? = null, val customShortcutCommand: ShortcutCommand? = null, override val packageName: String = "", override val className: String = "", ) : SingleShortcutCustomization } Loading packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt +4 −0 Original line number Diff line number Diff line Loading @@ -669,6 +669,8 @@ private fun Shortcut( ShortcutCustomizationRequestInfo.SingleShortcutCustomization.Add( label = shortcut.label, defaultShortcutCommand = shortcut.commands.firstOrNull { !it.isCustom }, packageName = shortcut.pkgName, className = shortcut.className ) ) }, Loading @@ -678,6 +680,8 @@ private fun Shortcut( label = shortcut.label, defaultShortcutCommand = shortcut.commands.firstOrNull { !it.isCustom }, customShortcutCommand = shortcut.commands.firstOrNull { it.isCustom }, packageName = shortcut.pkgName, className = shortcut.className, ) ) }, Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt +29 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.keyboard.shortcut.data.repository import android.content.Context import android.content.Context.INPUT_SERVICE import android.hardware.input.AppLaunchData import android.hardware.input.AppLaunchData.ComponentData import android.hardware.input.AppLaunchData.RoleData import android.hardware.input.InputGestureData import android.hardware.input.InputGestureData.createKeyTrigger Loading Loading @@ -280,6 +281,29 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() { assertThat(inputGestureData?.action?.appLaunchData()).isNotNull() } @Test fun buildInputGestureDataForAppLaunchShortcut_addsComponentDataForNonDefaultAppShortcuts() = testScope.runTest { helper.toggle(deviceId = 123) repo.onCustomizationRequested( SingleShortcutCustomization.Add( categoryType = ShortcutCategoryType.AppCategories, defaultShortcutCommand = null, packageName = TEST_PACKAGE, className = TEST_CLASS, ) ) repo.updateUserKeyCombination(standardKeyCombination) val inputGestureData = repo.buildInputGestureDataForShortcutBeingCustomized() assertThat(inputGestureData?.action?.appLaunchData()) .isEqualTo( ComponentData(/* packageName= */ TEST_PACKAGE, /* className= */ TEST_CLASS) ) } @Test @EnableFlags(FLAG_ENABLE_CUSTOMIZABLE_INPUT_GESTURES, FLAG_USE_KEY_GESTURE_EVENT_HANDLER) fun deleteShortcut_successfullyRetrievesGestureDataAndDeletesShortcut() { Loading Loading @@ -480,4 +504,9 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() { key("A") }, ) private companion object { const val TEST_PACKAGE = "com.test.package" const val TEST_CLASS = "TestClass" } }
packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepository.kt +10 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.keyboard.shortcut.data.repository import android.hardware.input.AppLaunchData import android.hardware.input.InputGestureData import android.hardware.input.InputGestureData.Builder import android.hardware.input.InputGestureData.KeyTrigger Loading Loading @@ -255,9 +256,16 @@ constructor( return this } val defaultShortcutCommand = shortcutBeingCustomized.defaultShortcutCommand ?: return this val defaultShortcutCommand = shortcutBeingCustomized.defaultShortcutCommand val appLaunchData = if (defaultShortcutCommand == null) { AppLaunchData.createLaunchDataForComponent( /* packageName= */ shortcutBeingCustomized.packageName, /* className= */ shortcutBeingCustomized.className ) } else{ appLaunchDataRepository.getAppLaunchDataForShortcutWithCommand(defaultShortcutCommand) } return if (appLaunchData == null) this else this.setAppLaunchData(appLaunchData) } Loading
packages/SystemUI/src/com/android/systemui/keyboard/shortcut/shared/model/ShortcutCustomizationRequestInfo.kt +6 −0 Original line number Diff line number Diff line Loading @@ -23,12 +23,16 @@ sealed interface ShortcutCustomizationRequestInfo { val categoryType: ShortcutCategoryType val subCategoryLabel: String val defaultShortcutCommand: ShortcutCommand? val packageName: String val className: String data class Add( override val label: String = "", override val categoryType: ShortcutCategoryType = ShortcutCategoryType.System, override val subCategoryLabel: String = "", override val defaultShortcutCommand: ShortcutCommand? = null, override val packageName: String = "", override val className: String = "", ) : SingleShortcutCustomization data class Delete( Loading @@ -37,6 +41,8 @@ sealed interface ShortcutCustomizationRequestInfo { override val subCategoryLabel: String = "", override val defaultShortcutCommand: ShortcutCommand? = null, val customShortcutCommand: ShortcutCommand? = null, override val packageName: String = "", override val className: String = "", ) : SingleShortcutCustomization } Loading
packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt +4 −0 Original line number Diff line number Diff line Loading @@ -669,6 +669,8 @@ private fun Shortcut( ShortcutCustomizationRequestInfo.SingleShortcutCustomization.Add( label = shortcut.label, defaultShortcutCommand = shortcut.commands.firstOrNull { !it.isCustom }, packageName = shortcut.pkgName, className = shortcut.className ) ) }, Loading @@ -678,6 +680,8 @@ private fun Shortcut( label = shortcut.label, defaultShortcutCommand = shortcut.commands.firstOrNull { !it.isCustom }, customShortcutCommand = shortcut.commands.firstOrNull { it.isCustom }, packageName = shortcut.pkgName, className = shortcut.className, ) ) }, Loading