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

Commit 9135ab4a authored by George Lin's avatar George Lin
Browse files

Fix stale home wallpaper info (1/3)

We will enforce refresh when finding that the cahced home wallpaper info
is not synced with what living in the Wallpaper Manager.

Test: Manually tested. See bug
Bug: 302369503
Change-Id: I3e46ebebd1ad06a1126b902783306894c26809c0
parent 2b4a52fc
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -88,14 +88,14 @@ class ClockSettingsFragment : AppbarFragment() {
                            injector
                                .getCurrentWallpaperInfoFactory(context)
                                .createCurrentWallpaperInfos(
                                    { homeWallpaper, lockWallpaper, _ ->
                                    context,
                                    forceReload,
                                ) { homeWallpaper, lockWallpaper, _ ->
                                    continuation.resume(
                                        lockWallpaper ?: homeWallpaper,
                                        null,
                                    )
                                    },
                                    forceReload,
                                )
                                }
                        }
                    },
                    onWallpaperColorChanged = { colors ->
+32 −32
Original line number Diff line number Diff line
@@ -114,7 +114,9 @@ class ColorPickerFragment : AppbarFragment() {
                        wallpaperInfoProvider = { forceReload ->
                            suspendCancellableCoroutine { continuation ->
                                wallpaperInfoFactory.createCurrentWallpaperInfos(
                                    { homeWallpaper, lockWallpaper, _ ->
                                    context,
                                    forceReload,
                                ) { homeWallpaper, lockWallpaper, _ ->
                                    lifecycleScope.launch {
                                        if (
                                            wallpaperColorsRepository.lockWallpaperColors.value
@@ -128,9 +130,7 @@ class ColorPickerFragment : AppbarFragment() {
                                        }
                                    }
                                    continuation.resume(lockWallpaper ?: homeWallpaper, null)
                                    },
                                    forceReload,
                                )
                                }
                            }
                        },
                        onWallpaperColorChanged = { colors ->
@@ -165,7 +165,9 @@ class ColorPickerFragment : AppbarFragment() {
                    wallpaperInfoProvider = { forceReload ->
                        suspendCancellableCoroutine { continuation ->
                            wallpaperInfoFactory.createCurrentWallpaperInfos(
                                { homeWallpaper, lockWallpaper, _ ->
                                context,
                                forceReload,
                            ) { homeWallpaper, lockWallpaper, _ ->
                                lifecycleScope.launch {
                                    if (
                                        wallpaperColorsRepository.homeWallpaperColors.value
@@ -179,9 +181,7 @@ class ColorPickerFragment : AppbarFragment() {
                                    }
                                }
                                continuation.resume(homeWallpaper ?: lockWallpaper, null)
                                },
                                forceReload,
                            )
                            }
                        }
                    },
                    onWallpaperColorChanged = { colors ->
+4 −4
Original line number Diff line number Diff line
@@ -185,11 +185,11 @@ class GridFragment : AppbarFragment() {
                    wallpaperInfoProvider = {
                        suspendCancellableCoroutine { continuation ->
                            wallpaperInfoFactory.createCurrentWallpaperInfos(
                                { homeWallpaper, lockWallpaper, _ ->
                                    continuation.resume(homeWallpaper ?: lockWallpaper, null)
                                },
                                context,
                                /* forceRefresh= */ true,
                            )
                            ) { homeWallpaper, lockWallpaper, _ ->
                                continuation.resume(homeWallpaper ?: lockWallpaper, null)
                            }
                        }
                    },
                    wallpaperInteractor = wallpaperInteractor,
+16 −14
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationPick
import com.android.wallpaper.picker.customization.ui.viewmodel.ScreenPreviewViewModel
import com.android.wallpaper.util.DisplayUtils
import com.android.wallpaper.util.PreviewUtils
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.suspendCancellableCoroutine

/**
@@ -69,6 +70,7 @@ open class PreviewWithThemeSectionController(
        isTwoPaneAndSmallWidth,
        customizationPickerViewModel,
    ) {
    @OptIn(ExperimentalCoroutinesApi::class)
    override fun createScreenPreviewViewModel(context: Context): ScreenPreviewViewModel {
        return PreviewWithThemeViewModel(
            previewUtils =
@@ -92,7 +94,9 @@ open class PreviewWithThemeSectionController(
            wallpaperInfoProvider = { forceReload ->
                suspendCancellableCoroutine { continuation ->
                    wallpaperInfoFactory.createCurrentWallpaperInfos(
                        { homeWallpaper, lockWallpaper, _ ->
                        context,
                        forceReload,
                    ) { homeWallpaper, lockWallpaper, _ ->
                        val wallpaper =
                            if (isOnLockScreen) {
                                lockWallpaper ?: homeWallpaper
@@ -104,9 +108,7 @@ open class PreviewWithThemeSectionController(
                            screen = screen,
                        )
                        continuation.resume(wallpaper, null)
                        },
                        forceReload,
                    )
                    }
                }
            },
            onWallpaperColorChanged = { colors ->
+4 −4
Original line number Diff line number Diff line
@@ -92,11 +92,11 @@ private constructor(
            wallpaperInfoProvider = { forceReload ->
                suspendCancellableCoroutine { continuation ->
                    wallpaperInfoFactory.createCurrentWallpaperInfos(
                        { homeWallpaper, lockWallpaper, _ ->
                            continuation.resume(lockWallpaper ?: homeWallpaper, null)
                        },
                        context,
                        forceReload,
                    )
                    ) { homeWallpaper, lockWallpaper, _ ->
                        continuation.resume(lockWallpaper ?: homeWallpaper, null)
                    }
                }
            },
            wallpaperInteractor = wallpaperInteractor,