Loading core/java/android/app/backup/WallpaperBackupHelper.java +8 −4 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,7 @@ import java.io.File; */ */ public class WallpaperBackupHelper extends FileBackupHelperBase implements BackupHelper { public class WallpaperBackupHelper extends FileBackupHelperBase implements BackupHelper { private static final String TAG = "WallpaperBackupHelper"; private static final String TAG = "WallpaperBackupHelper"; private static final boolean DEBUG = false; private static final boolean DEBUG = true; // This path must match what the WallpaperManagerService uses // This path must match what the WallpaperManagerService uses private static final String WALLPAPER_IMAGE = "/data/data/com.android.settings/files/wallpaper"; private static final String WALLPAPER_IMAGE = "/data/data/com.android.settings/files/wallpaper"; Loading Loading @@ -64,6 +64,10 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu wpm = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE); wpm = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE); mDesiredMinWidth = (double) wpm.getDesiredMinimumWidth(); mDesiredMinWidth = (double) wpm.getDesiredMinimumWidth(); mDesiredMinHeight = (double) wpm.getDesiredMinimumHeight(); mDesiredMinHeight = (double) wpm.getDesiredMinimumHeight(); if (DEBUG) { Slog.d(TAG, "dmW=" + mDesiredMinWidth + " dmH=" + mDesiredMinHeight); } } } /** /** Loading Loading @@ -94,7 +98,7 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu options.inJustDecodeBounds = true; options.inJustDecodeBounds = true; BitmapFactory.decodeFile(STAGE_FILE, options); BitmapFactory.decodeFile(STAGE_FILE, options); if (DEBUG) Slog.v(TAG, "Restoring wallpaper image w=" + options.outWidth if (DEBUG) Slog.d(TAG, "Restoring wallpaper image w=" + options.outWidth + " h=" + options.outHeight); + " h=" + options.outHeight); // how much does the image differ from our preference? // how much does the image differ from our preference? Loading @@ -103,13 +107,13 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu if (widthRatio > 0.8 && widthRatio < 1.25 if (widthRatio > 0.8 && widthRatio < 1.25 && heightRatio > 0.8 && heightRatio < 1.25) { && heightRatio > 0.8 && heightRatio < 1.25) { // sufficiently close to our resolution; go ahead and use it // sufficiently close to our resolution; go ahead and use it if (DEBUG) Slog.v(TAG, "wallpaper dimension match; using"); if (DEBUG) Slog.d(TAG, "wallpaper dimension match; using"); f.renameTo(new File(WALLPAPER_IMAGE)); f.renameTo(new File(WALLPAPER_IMAGE)); // TODO: spin a service to copy the restored image to sd/usb storage, // TODO: spin a service to copy the restored image to sd/usb storage, // since it does not exist anywhere other than the private wallpaper // since it does not exist anywhere other than the private wallpaper // file. // file. } else { } else { if (DEBUG) Slog.v(TAG, "dimensions too far off: wr=" + widthRatio if (DEBUG) Slog.d(TAG, "dimensions too far off: wr=" + widthRatio + " hr=" + heightRatio); + " hr=" + heightRatio); f.delete(); f.delete(); } } Loading Loading
core/java/android/app/backup/WallpaperBackupHelper.java +8 −4 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,7 @@ import java.io.File; */ */ public class WallpaperBackupHelper extends FileBackupHelperBase implements BackupHelper { public class WallpaperBackupHelper extends FileBackupHelperBase implements BackupHelper { private static final String TAG = "WallpaperBackupHelper"; private static final String TAG = "WallpaperBackupHelper"; private static final boolean DEBUG = false; private static final boolean DEBUG = true; // This path must match what the WallpaperManagerService uses // This path must match what the WallpaperManagerService uses private static final String WALLPAPER_IMAGE = "/data/data/com.android.settings/files/wallpaper"; private static final String WALLPAPER_IMAGE = "/data/data/com.android.settings/files/wallpaper"; Loading Loading @@ -64,6 +64,10 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu wpm = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE); wpm = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE); mDesiredMinWidth = (double) wpm.getDesiredMinimumWidth(); mDesiredMinWidth = (double) wpm.getDesiredMinimumWidth(); mDesiredMinHeight = (double) wpm.getDesiredMinimumHeight(); mDesiredMinHeight = (double) wpm.getDesiredMinimumHeight(); if (DEBUG) { Slog.d(TAG, "dmW=" + mDesiredMinWidth + " dmH=" + mDesiredMinHeight); } } } /** /** Loading Loading @@ -94,7 +98,7 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu options.inJustDecodeBounds = true; options.inJustDecodeBounds = true; BitmapFactory.decodeFile(STAGE_FILE, options); BitmapFactory.decodeFile(STAGE_FILE, options); if (DEBUG) Slog.v(TAG, "Restoring wallpaper image w=" + options.outWidth if (DEBUG) Slog.d(TAG, "Restoring wallpaper image w=" + options.outWidth + " h=" + options.outHeight); + " h=" + options.outHeight); // how much does the image differ from our preference? // how much does the image differ from our preference? Loading @@ -103,13 +107,13 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu if (widthRatio > 0.8 && widthRatio < 1.25 if (widthRatio > 0.8 && widthRatio < 1.25 && heightRatio > 0.8 && heightRatio < 1.25) { && heightRatio > 0.8 && heightRatio < 1.25) { // sufficiently close to our resolution; go ahead and use it // sufficiently close to our resolution; go ahead and use it if (DEBUG) Slog.v(TAG, "wallpaper dimension match; using"); if (DEBUG) Slog.d(TAG, "wallpaper dimension match; using"); f.renameTo(new File(WALLPAPER_IMAGE)); f.renameTo(new File(WALLPAPER_IMAGE)); // TODO: spin a service to copy the restored image to sd/usb storage, // TODO: spin a service to copy the restored image to sd/usb storage, // since it does not exist anywhere other than the private wallpaper // since it does not exist anywhere other than the private wallpaper // file. // file. } else { } else { if (DEBUG) Slog.v(TAG, "dimensions too far off: wr=" + widthRatio if (DEBUG) Slog.d(TAG, "dimensions too far off: wr=" + widthRatio + " hr=" + heightRatio); + " hr=" + heightRatio); f.delete(); f.delete(); } } Loading