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

Commit 328a8bf0 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

Setting/getting per-screen wallpaper (2/3).

Necessary changes to support setting and getting wallpapers per-screen,
which is what's needed for the wallpaper quick switcher to apply the
selected wallpaper only to the screen whose tab is currently selected.

Setting the individual per-screen wallpaper is complete but work still
needs to be done to provide separate recents for each screen. That work
is captured in b/265066284.

Bug: 262924643
Test: manually verified that setting per-screen wallpaper works by
switching between the home screen and lock screen tabs and selecting
different wallpapers
Test: manually verified that undo/restore works as expected, especially
given the lack of per-screen recents to serve as a baseline (it always
resets to both having the same wallpaper)
Test: unit tests throughout the layers

Change-Id: Ib7f312b29476c102621740c2dde8ea8f9b59b55b
parent cc51e1bf
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -83,6 +83,7 @@ public final class DefaultCustomizationSections implements CustomizationSections
        // Wallpaper quick switch section.
        // Wallpaper quick switch section.
        sectionControllers.add(
        sectionControllers.add(
                new WallpaperQuickSwitchSectionController(
                new WallpaperQuickSwitchSectionController(
                        screen,
                        wallpaperQuickSwitchViewModel,
                        wallpaperQuickSwitchViewModel,
                        lifecycleOwner,
                        lifecycleOwner,
                        sectionNavigationController));
                        sectionNavigationController));
+2 −1
Original line number Original line Diff line number Diff line
@@ -18,12 +18,13 @@
package com.android.customization.picker.clock.domain.interactor
package com.android.customization.picker.clock.domain.interactor


import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotStore
import com.android.wallpaper.picker.undo.shared.model.RestorableSnapshot
import com.android.wallpaper.picker.undo.shared.model.RestorableSnapshot


/** Handles state restoration for clocks. */
/** Handles state restoration for clocks. */
class ClocksSnapshotRestorer : SnapshotRestorer {
class ClocksSnapshotRestorer : SnapshotRestorer {
    override suspend fun setUpSnapshotRestorer(
    override suspend fun setUpSnapshotRestorer(
        updater: (RestorableSnapshot) -> Unit,
        store: SnapshotStore,
    ): RestorableSnapshot {
    ): RestorableSnapshot {
        // TODO(b/262924055): implement as part of the clock settings screen.
        // TODO(b/262924055): implement as part of the clock settings screen.
        return RestorableSnapshot(mapOf())
        return RestorableSnapshot(mapOf())
+5 −4
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.customization.picker.quickaffordance.domain.interactor


import com.android.systemui.shared.customization.data.content.CustomizationProviderClient
import com.android.systemui.shared.customization.data.content.CustomizationProviderClient
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotStore
import com.android.wallpaper.picker.undo.shared.model.RestorableSnapshot
import com.android.wallpaper.picker.undo.shared.model.RestorableSnapshot


/** Handles state restoration for the quick affordances system. */
/** Handles state restoration for the quick affordances system. */
@@ -27,16 +28,16 @@ class KeyguardQuickAffordanceSnapshotRestorer(
    private val client: CustomizationProviderClient,
    private val client: CustomizationProviderClient,
) : SnapshotRestorer {
) : SnapshotRestorer {


    private lateinit var snapshotUpdater: (RestorableSnapshot) -> Unit
    private lateinit var snapshotStore: SnapshotStore


    suspend fun storeSnapshot() {
    suspend fun storeSnapshot() {
        snapshotUpdater(snapshot())
        snapshotStore.store(snapshot())
    }
    }


    override suspend fun setUpSnapshotRestorer(
    override suspend fun setUpSnapshotRestorer(
        updater: (RestorableSnapshot) -> Unit,
        store: SnapshotStore,
    ): RestorableSnapshot {
    ): RestorableSnapshot {
        snapshotUpdater = updater
        snapshotStore = store
        return snapshot()
        return snapshot()
    }
    }


+2 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.customization.picker.quickaffordance.domain.interactor.Keygua
import com.android.customization.picker.quickaffordance.shared.model.KeyguardQuickAffordancePickerSelectionModel
import com.android.customization.picker.quickaffordance.shared.model.KeyguardQuickAffordancePickerSelectionModel
import com.android.systemui.shared.customization.data.content.FakeCustomizationProviderClient
import com.android.systemui.shared.customization.data.content.FakeCustomizationProviderClient
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
import com.android.wallpaper.testing.FakeSnapshotStore
import com.android.wallpaper.testing.collectLastValue
import com.android.wallpaper.testing.collectLastValue
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers
@@ -69,7 +70,7 @@ class KeyguardQuickAffordancePickerInteractorTest {
                            interactor = underTest,
                            interactor = underTest,
                            client = client,
                            client = client,
                        )
                        )
                        .apply { runBlocking { setUpSnapshotRestorer {} } }
                        .apply { runBlocking { setUpSnapshotRestorer(FakeSnapshotStore()) } }
                },
                },
            )
            )
    }
    }
+2 −1
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.picker.undo.data.repository.UndoRepository
import com.android.wallpaper.picker.undo.data.repository.UndoRepository
import com.android.wallpaper.picker.undo.domain.interactor.UndoInteractor
import com.android.wallpaper.picker.undo.domain.interactor.UndoInteractor
import com.android.wallpaper.testing.FAKE_RESTORERS
import com.android.wallpaper.testing.FAKE_RESTORERS
import com.android.wallpaper.testing.FakeSnapshotStore
import com.android.wallpaper.testing.TestCurrentWallpaperInfoFactory
import com.android.wallpaper.testing.TestCurrentWallpaperInfoFactory
import com.android.wallpaper.testing.TestInjector
import com.android.wallpaper.testing.TestInjector
import com.android.wallpaper.testing.collectLastValue
import com.android.wallpaper.testing.collectLastValue
@@ -90,7 +91,7 @@ class KeyguardQuickAffordancePickerViewModelTest {
                            interactor = quickAffordanceInteractor,
                            interactor = quickAffordanceInteractor,
                            client = client,
                            client = client,
                        )
                        )
                        .apply { runBlocking { setUpSnapshotRestorer {} } }
                        .apply { runBlocking { setUpSnapshotRestorer(FakeSnapshotStore()) } }
                },
                },
            )
            )
        val undoInteractor =
        val undoInteractor =