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

Commit 2329e7b2 authored by Christopher Tate's avatar Christopher Tate Committed by android-build-merger
Browse files

Fix wallpaper restore from pre-N devices am: ebadfb17

am: ac2f0b2c

Change-Id: I7b8c8eb3e880389d1f70fd15f9d82bd815f1be16
parents d4ac5602 ac2f0b2c
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
    // If 'true', then apply an acceptable-size heuristic at restore time, dropping back
    // to the factory default wallpaper if the restored one differs "too much" from the
    // device's preferred wallpaper image dimensions.
    private static final boolean REJECT_OUTSIZED_RESTORE = true;
    private static final boolean REJECT_OUTSIZED_RESTORE = false;

    // When outsized restore rejection is enabled, this is the maximum ratio between the
    // source and target image heights that will be permitted.  The ratio is checked both
@@ -60,6 +60,9 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
    public static final String WALLPAPER_IMAGE =
            new File(Environment.getUserSystemDirectory(UserHandle.USER_SYSTEM),
                    "wallpaper").getAbsolutePath();
    public static final String WALLPAPER_ORIG_IMAGE =
            new File(Environment.getUserSystemDirectory(UserHandle.USER_SYSTEM),
                    "wallpaper_orig").getAbsolutePath();
    public static final String WALLPAPER_INFO =
            new File(Environment.getUserSystemDirectory(UserHandle.USER_SYSTEM),
                    "wallpaper_info.xml").getAbsolutePath();
@@ -199,7 +202,7 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
            // 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));
            f.renameTo(new File(WALLPAPER_ORIG_IMAGE));
        }
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -252,6 +252,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
                            if (DEBUG) {
                                Slog.v(TAG, "Wallpaper written; generating crop");
                            }
                            SELinux.restorecon(changedFile);
                            if (moved) {
                                // This is a restore, so generate the crop using any just-restored new
                                // crop guidelines, making sure to preserve our local dimension hints.
@@ -259,7 +260,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
                                if (DEBUG) {
                                    Slog.v(TAG, "moved-to, therefore restore; reloading metadata");
                                }
                                SELinux.restorecon(changedFile);
                                loadSettingsLocked(wallpaper.userId, true);
                            }
                            generateCrop(wallpaper);
@@ -353,8 +353,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
                        (cropHint.bottom > options.outHeight ? options.outHeight - cropHint.bottom : 0));

                // Don't bother cropping if what we're left with is identity
                needCrop = (options.outHeight >= cropHint.height()
                        && options.outWidth >= cropHint.width());
                needCrop = (options.outHeight > cropHint.height()
                        && options.outWidth > cropHint.width());
            }

            // scale if the crop height winds up not matching the recommended metrics