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

Commit 2f68800a authored by Catherine Liang's avatar Catherine Liang Committed by Android (Google) Code Review
Browse files

Merge "Fix crash from resetting shortcuts to none" into main

parents eef444cf 38aeb2aa
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ class KeyguardQuickAffordancePickerInteractor(
    }

    /** Unselects all affordances from the slot with the given ID. */
    suspend fun unselectAll(slotId: String) {
    suspend fun unselectAllFromSlot(slotId: String) {
        client.deleteAllSelections(
            slotId = slotId,
        )
@@ -72,6 +72,11 @@ class KeyguardQuickAffordancePickerInteractor(
        snapshotRestorer.get().storeSnapshot()
    }

    /** Unselects all affordances from all slots. */
    suspend fun unselectAll() {
        client.querySlots().forEach { client.deleteAllSelections(it.id) }
    }

    /** Returns a [Drawable] for the given resource ID, from the system UI package. */
    suspend fun getAffordanceIcon(
        @DrawableRes iconResourceId: Int,
+7 −2
Original line number Diff line number Diff line
@@ -42,9 +42,14 @@ class KeyguardQuickAffordanceSnapshotRestorer(
    }

    override suspend fun restoreToSnapshot(snapshot: RestorableSnapshot) {
        // reset all current selections
        interactor.unselectAll()

        val allSelections = checkNotNull(snapshot.args[KEY_SELECTIONS])
        if (allSelections.isEmpty()) return

        val selections: List<Pair<String, String>> =
            checkNotNull(snapshot.args[KEY_SELECTIONS]).split(SELECTION_SEPARATOR).map { selection
                ->
            allSelections.split(SELECTION_SEPARATOR).map { selection ->
                val (slotId, affordanceId) = selection.split(SLOT_AFFORDANCE_SEPARATOR)
                slotId to affordanceId
            }
+3 −1
Original line number Diff line number Diff line
@@ -217,7 +217,9 @@ private constructor(
                            if (!isSelected) {
                                {
                                    viewModelScope.launch {
                                        quickAffordanceInteractor.unselectAll(selectedSlotId)
                                        quickAffordanceInteractor.unselectAllFromSlot(
                                            selectedSlotId
                                        )
                                        logger.logShortcutApplied(
                                            shortcut = "none",
                                            shortcutSlotId = selectedSlotId,
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ class KeyguardQuickAffordancePickerInteractorTest {
                affordanceId = FakeCustomizationProviderClient.AFFORDANCE_3,
            )

            underTest.unselectAll(
            underTest.unselectAllFromSlot(
                slotId = KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END,
            )