diff options
author | Christopher Tate <ctate@google.com> | 2014-10-07 21:59:10 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-07 21:59:10 +0000 |
commit | 152893dd66a8cdecab14595c20085a0f10917f21 (patch) | |
tree | 9dd0f5e397c65d640c059aa8a1647fa6f0193927 | |
parent | 663edb8bfb5025b58ed874432b41f60cfa587266 (diff) | |
parent | 93e5e859e3d2c0f4d4f47c90d370b38be4440655 (diff) | |
download | frameworks_base-152893dd66a8cdecab14595c20085a0f10917f21.zip frameworks_base-152893dd66a8cdecab14595c20085a0f10917f21.tar.gz frameworks_base-152893dd66a8cdecab14595c20085a0f10917f21.tar.bz2 |
am 93e5e859: am ae456fd8: Merge "Accept any restored wallpaper" into lmp-dev
* commit '93e5e859e3d2c0f4d4f47c90d370b38be4440655':
Accept any restored wallpaper
-rw-r--r-- | core/java/android/app/backup/WallpaperBackupHelper.java | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java index b8575d7..68ea9e9 100644 --- a/core/java/android/app/backup/WallpaperBackupHelper.java +++ b/core/java/android/app/backup/WallpaperBackupHelper.java @@ -39,6 +39,11 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu private static final String TAG = "WallpaperBackupHelper"; private static final boolean DEBUG = false; + // 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 = false; + // This path must match what the WallpaperManagerService uses // TODO: Will need to change if backing up non-primary user's wallpaper public static final String WALLPAPER_IMAGE = @@ -130,27 +135,36 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu if (DEBUG) Slog.d(TAG, "Restoring wallpaper image w=" + options.outWidth + " h=" + options.outHeight); - // We accept any wallpaper that is at least as wide as our preference - // (i.e. wide enough to fill the screen), and is within a comfortable - // factor of the target height, to avoid significant clipping/scaling/ - // letterboxing. - final double heightRatio = mDesiredMinHeight / options.outHeight; - if (options.outWidth >= mDesiredMinWidth - && heightRatio > 0 && heightRatio < 1.33) { - // sufficiently close to our resolution; go ahead and use it - Slog.d(TAG, "Applying restored wallpaper image."); - f.renameTo(new File(WALLPAPER_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. - } else { - Slog.i(TAG, "Restored image dimensions (w=" - + options.outWidth + ", h=" + options.outHeight - + ") too far off target (tw=" - + mDesiredMinWidth + ", th=" + mDesiredMinHeight - + "); falling back to default wallpaper."); - f.delete(); + if (REJECT_OUTSIZED_RESTORE) { + // We accept any wallpaper that is at least as wide as our preference + // (i.e. wide enough to fill the screen), and is within a comfortable + // factor of the target height, to avoid significant clipping/scaling/ + // letterboxing. + final double heightRatio = mDesiredMinHeight / options.outHeight; + if (options.outWidth < mDesiredMinWidth + || heightRatio <= 0 + || heightRatio >= 1.33) { + // Not wide enough for the screen, or too short/tall to be a good fit + // for the height of the screen, broken image file, or the system's + // desires for wallpaper size are in a bad state. Probably one of the + // first two. + Slog.i(TAG, "Restored image dimensions (w=" + + options.outWidth + ", h=" + options.outHeight + + ") too far off target (tw=" + + mDesiredMinWidth + ", th=" + mDesiredMinHeight + + "); falling back to default wallpaper."); + f.delete(); + return; + } } + + // 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)); } } else if (key.equals(WALLPAPER_INFO_KEY)) { // XML file containing wallpaper info |