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

Commit 54ae6a1b authored by Josh's avatar Josh Committed by Android Build Coastguard Worker
Browse files

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
parent b8cfe84a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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
    }
}
+10 −5
Original line number Diff line number Diff line
@@ -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")
                },
        )
}
+28 −16
Original line number Diff line number Diff line
@@ -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,15 +152,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
                }

@@ -172,6 +179,11 @@ constructor(
            } else {
                inputGesturesMatchingKeyGestureType.firstOrNull()
            }
        } else {
            return customInputGesturesRepository.retrieveCustomInputGestures().firstOrNull {
                it.action.keyGestureType() == keyGestureTypeForShortcutBeingDeleted
            }
        }
    }

    suspend fun confirmAndSetShortcutCurrentlyBeingCustomized():