From 5c14853296172fe9885eee26d86351bd935e8430 Mon Sep 17 00:00:00 2001 From: Bryan Mawhinney Date: Tue, 7 Feb 2017 15:18:07 +0000 Subject: [PATCH 1/2] Workaround wallpaper restore race If WallpaperManager is asked to read a wallpaper between when we call mWm.clear and mWm.setStream, it is possible for us to end up losing restored state such as cropHint and allowBackup By not calling mWm.clear, we make this much less likely to happen. It isn't necessary to call clear, as will explicitly overwrite all the interesting state anyway. Test: by repeated adb restore Bug: 34760753 Change-Id: I2750695d5dd16077b47b5b8fca3a667b98cc4f6c --- .../src/com/android/wallpaperbackup/WallpaperBackupAgent.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java b/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java index ff934ef18677a..19da32c83cd5f 100644 --- a/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java +++ b/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java @@ -217,9 +217,6 @@ public class WallpaperBackupAgent extends BackupAgent { final int sysWhich = FLAG_SYSTEM | (lockImageStage.exists() ? 0 : FLAG_LOCK); try { - // First off, revert to the factory state - mWm.clear(FLAG_SYSTEM | FLAG_LOCK); - // It is valid for the imagery to be absent; it means that we were not permitted // to back up the original image on the source device, or there was no user-supplied // wallpaper image present. From 96eb5b724bab31125e15eef2c926f6648567c3a1 Mon Sep 17 00:00:00 2001 From: Bryan Mawhinney Date: Tue, 7 Feb 2017 15:27:19 +0000 Subject: [PATCH 2/2] Fix live wallpaper not showing on lock screen after restore A recent change in nyc-mr2 means that setWallpaperComponent will promote any static system wallpaper to the lock screen. If we don't actually have a static lock wallpaper to restore, we need to explicitly clear the lock wallpaper to have the live one show through Test: manually using adb backup / restore Bug: 35090402 Change-Id: I8a2c5ffbaefe172c9d78a9f746ab87d9bc6b7448 --- .../com/android/wallpaperbackup/WallpaperBackupAgent.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java b/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java index 19da32c83cd5f..4254a0ba200ab 100644 --- a/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java +++ b/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java @@ -230,6 +230,11 @@ public class WallpaperBackupAgent extends BackupAgent { Slog.i(TAG, "Using wallpaper service " + wpService); } mWm.setWallpaperComponent(wpService, UserHandle.USER_SYSTEM); + if (!lockImageStage.exists()) { + // We have a live wallpaper and no static lock image, + // allow live wallpaper to show "through" on lock screen. + mWm.clear(FLAG_LOCK); + } } else { if (DEBUG) { Slog.v(TAG, "Can't use wallpaper service " + wpService);