Merge "Once restored, the wallpaper needs to actually draw" into nyc-dev am: fcbe17e1e0
am: 3422c197a8
* commit '3422c197a82c6572fd2524bc636246ccb6b8a24a':
Once restored, the wallpaper needs to actually draw
diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java
index 30c11ef..f256a95 100644
--- a/core/java/android/app/backup/WallpaperBackupHelper.java
+++ b/core/java/android/app/backup/WallpaperBackupHelper.java
@@ -120,6 +120,7 @@
* need to be backed up, write them to the data stream, and fill in newState with the
* state as it exists now.
*/
+ @Override
public void performBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) {
performBackup_checked(oldState, data, newState, mFiles, mKeys);
@@ -130,6 +131,7 @@
* magic wallpaper file, take specific action to determine whether it is suitable for
* the current device.
*/
+ @Override
public void restoreEntity(BackupDataInputStream data) {
final String key = data.getKey();
if (isKeyInList(key, mKeys)) {
@@ -174,12 +176,8 @@
}
// We passed the acceptable-dimensions test (if any), so we're going to
- // use the restored image.
- // TODO: spin a service to copy the restored image to sd/usb storage,
- // since it does not exist anywhere other than the private wallpaper
- // file.
- Slog.d(TAG, "Applying restored wallpaper image.");
- f.renameTo(new File(WALLPAPER_IMAGE));
+ // use the restored image. That comes last, when we are done restoring
+ // both the pixels and the metadata.
}
} else if (key.equals(WALLPAPER_INFO_KEY)) {
// XML file containing wallpaper info
@@ -188,4 +186,20 @@
}
}
}
+
+ /**
+ * Hook for the agent to call this helper upon completion of the restore. We do this
+ * upon completion so that we know both the imagery and the wallpaper info have
+ * been emplaced without requiring either or relying on ordering.
+ */
+ public void onRestoreFinished() {
+ final File f = new File(STAGE_FILE);
+ if (f.exists()) {
+ // TODO: spin a service to copy the restored image to sd/usb storage,
+ // since it does not exist anywhere other than the private wallpaper
+ // file.
+ Slog.d(TAG, "Applying restored wallpaper image.");
+ f.renameTo(new File(WALLPAPER_IMAGE));
+ }
+ }
}
diff --git a/core/java/com/android/server/backup/SystemBackupAgent.java b/core/java/com/android/server/backup/SystemBackupAgent.java
index cee98b8..181ed51 100644
--- a/core/java/com/android/server/backup/SystemBackupAgent.java
+++ b/core/java/com/android/server/backup/SystemBackupAgent.java
@@ -70,6 +70,8 @@
private static final String WALLPAPER_IMAGE_KEY = WallpaperBackupHelper.WALLPAPER_IMAGE_KEY;
private static final String WALLPAPER_INFO_KEY = WallpaperBackupHelper.WALLPAPER_INFO_KEY;
+ private WallpaperBackupHelper mWallpaperHelper = null;
+
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) throws IOException {
@@ -121,13 +123,16 @@
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
throws IOException {
- // On restore, we also support a previous data schema "system_files"
- addHelper(WALLPAPER_HELPER, new WallpaperBackupHelper(this,
+ mWallpaperHelper = new WallpaperBackupHelper(this,
new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO },
- new String[] { WALLPAPER_IMAGE_KEY, WALLPAPER_INFO_KEY} ));
+ new String[] { WALLPAPER_IMAGE_KEY, WALLPAPER_INFO_KEY} );
+ addHelper(WALLPAPER_HELPER, mWallpaperHelper);
+
+ // On restore, we also support a previous data schema "system_files"
addHelper("system_files", new WallpaperBackupHelper(this,
new String[] { WALLPAPER_IMAGE },
new String[] { WALLPAPER_IMAGE_KEY} ));
+
addHelper(SYNC_SETTINGS_HELPER, new AccountSyncSettingsBackupHelper(this));
addHelper(PREFERRED_HELPER, new PreferredActivityBackupHelper());
addHelper(NOTIFICATION_HELPER, new NotificationBackupHelper(this));
@@ -202,4 +207,9 @@
}
}
}
+
+ @Override
+ public void onRestoreFinished() {
+ mWallpaperHelper.onRestoreFinished();
+ }
}
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index ccbdad2..ffdd89a 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -441,12 +441,8 @@
}
// Called during initialization of a given user's wallpaper bookkeeping
- boolean ensureCropExists() {
- // if the crop file is not present, copy over the source image to use verbatim
- if (!cropFile.exists()) {
- return FileUtils.copyFile(wallpaperFile, cropFile);
- }
- return true;
+ boolean cropExists() {
+ return cropFile.exists();
}
}
@@ -734,7 +730,12 @@
public void systemRunning() {
if (DEBUG) Slog.v(TAG, "systemReady");
WallpaperData wallpaper = mWallpaperMap.get(UserHandle.USER_SYSTEM);
- if (!wallpaper.ensureCropExists()) {
+ // No crop file? Make sure we've finished the processing sequence if necessary
+ if (!wallpaper.cropExists()) {
+ generateCrop(wallpaper);
+ }
+ // Still nothing? Fall back to default.
+ if (!wallpaper.cropExists()) {
clearWallpaperLocked(false, FLAG_SET_SYSTEM, UserHandle.USER_SYSTEM, null);
}
switchWallpaper(wallpaper, null);
@@ -1645,7 +1646,9 @@
if (wallpaper == null) {
wallpaper = new WallpaperData(userId, WALLPAPER, WALLPAPER_CROP);
mWallpaperMap.put(userId, wallpaper);
- wallpaper.ensureCropExists();
+ if (!wallpaper.cropExists()) {
+ generateCrop(wallpaper);
+ }
}
boolean success = false;
try {
@@ -1809,7 +1812,8 @@
if (DEBUG) Slog.v(TAG, "settingsRestored: success=" + success
+ " id=" + wallpaper.wallpaperId);
if (success) {
- bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false,
+ generateCrop(wallpaper); // based on the new image + metadata
+ bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, true, false,
wallpaper, null);
}
}