Don't set ImageWallpaper to home only the first time

CL only effective if lockscreen live wallpaper are not enabled.

The first time, setting a wallpaper on home only will
trigger a migration of the default wallpaper, which causes some
problems when the lockscreen live wallpaper flag is not enabled.

In that case, force the wallpaper to be set on home + lock, to make sure
the lock screen doesn't end up without any wallpaper.

Bug: b/279129369
Test: manually check that the bug is fixed
Test: atest WallpaperManagerTest
Change-Id: Id955a8336455b47a8ba30958f25f2fd276fee013
Merged-In: Id955a8336455b47a8ba30958f25f2fd276fee013
This commit is contained in:
Aurélien Pomini
2023-06-28 14:34:14 +00:00
parent c615401f23
commit 7a5705b3c2

View File

@@ -3050,7 +3050,10 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
if (which == FLAG_SYSTEM && systemIsStatic && systemIsBoth) { if (which == FLAG_SYSTEM && systemIsStatic && systemIsBoth) {
Slog.i(TAG, "Migrating current wallpaper to be lock-only before" Slog.i(TAG, "Migrating current wallpaper to be lock-only before"
+ " updating system wallpaper"); + " updating system wallpaper");
migrateStaticSystemToLockWallpaperLocked(userId); if (!migrateStaticSystemToLockWallpaperLocked(userId)
&& !isLockscreenLiveWallpaperEnabled()) {
which |= FLAG_LOCK;
}
} }
wallpaper = getWallpaperSafeLocked(userId, which); wallpaper = getWallpaperSafeLocked(userId, which);
@@ -3078,13 +3081,13 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
} }
} }
private void migrateStaticSystemToLockWallpaperLocked(int userId) { private boolean migrateStaticSystemToLockWallpaperLocked(int userId) {
WallpaperData sysWP = mWallpaperMap.get(userId); WallpaperData sysWP = mWallpaperMap.get(userId);
if (sysWP == null) { if (sysWP == null) {
if (DEBUG) { if (DEBUG) {
Slog.i(TAG, "No system wallpaper? Not tracking for lock-only"); Slog.i(TAG, "No system wallpaper? Not tracking for lock-only");
} }
return; return true;
} }
// We know a-priori that there is no lock-only wallpaper currently // We know a-priori that there is no lock-only wallpaper currently
@@ -3105,11 +3108,13 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
SELinux.restorecon(lockWP.wallpaperFile); SELinux.restorecon(lockWP.wallpaperFile);
mLastLockWallpaper = lockWP; mLastLockWallpaper = lockWP;
} }
return true;
} catch (ErrnoException e) { } catch (ErrnoException e) {
Slog.e(TAG, "Can't migrate system wallpaper: " + e.getMessage()); // can happen when migrating default wallpaper (which is not stored in wallpaperFile)
Slog.w(TAG, "Couldn't migrate system wallpaper: " + e.getMessage());
lockWP.wallpaperFile.delete(); lockWP.wallpaperFile.delete();
lockWP.cropFile.delete(); lockWP.cropFile.delete();
return; return false;
} }
} }
@@ -3310,7 +3315,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
// therefore it's a shared system+lock image that we need to migrate. // therefore it's a shared system+lock image that we need to migrate.
Slog.i(TAG, "Migrating current wallpaper to be lock-only before" Slog.i(TAG, "Migrating current wallpaper to be lock-only before"
+ "updating system wallpaper"); + "updating system wallpaper");
migrateStaticSystemToLockWallpaperLocked(userId); if (!migrateStaticSystemToLockWallpaperLocked(userId)) {
which |= FLAG_LOCK;
}
} }
} }