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

Commit fcbe17e1 authored by Chris Tate's avatar Chris Tate Committed by Android (Google) Code Review
Browse files

Merge "Once restored, the wallpaper needs to actually draw" into nyc-dev

parents 48103be6 41297ff8
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
     * 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 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
     * 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 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
                    }

                    // 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 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
            }
        }
    }

    /**
     * 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));
        }
    }
}
+13 −3
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ public class SystemBackupAgent extends BackupAgentHelper {
    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 @@ public class SystemBackupAgent extends BackupAgentHelper {
    @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 @@ public class SystemBackupAgent extends BackupAgentHelper {
            }
        }
    }

    @Override
    public void onRestoreFinished() {
        mWallpaperHelper.onRestoreFinished();
    }
}
+13 −9
Original line number Diff line number Diff line
@@ -441,12 +441,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
        }

        // 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 class WallpaperManagerService extends IWallpaperManager.Stub {
    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 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
        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 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
                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);
                }
            }