summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2014-10-10 10:49:16 -0700
committerChristopher Tate <ctate@android.com>2014-10-10 17:54:14 +0000
commit1133e29f22252cc36102f41204c3de35779e49d2 (patch)
treecf6963960e5583ed1e3035bb84c67690822ed916 /core/java
parent294297df4e3f327a81d922563c518aee8ee3e51d (diff)
Tweak wallpaper restore rejection threshold
Raise the height ratio threshold slightly in order to start accepting restores of height=1920 images onto height=2560 devices. Bug 17882661 Change-Id: I63b47817fdf754cda9a052bddb62aee764522c6f
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/backup/WallpaperBackupHelper.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java
index 75a523700948..a55cc2b4b78b 100644
--- a/core/java/android/app/backup/WallpaperBackupHelper.java
+++ b/core/java/android/app/backup/WallpaperBackupHelper.java
@@ -44,6 +44,16 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
// device's preferred wallpaper image dimensions.
private static final boolean REJECT_OUTSIZED_RESTORE = true;
+ // 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
+ // ways (i.e. >= MAX, or <= 1/MAX) to validate restores from both largeer-than-target
+ // and smaller-than-target sources.
+ private static final double MAX_HEIGHT_RATIO = 1.35;
+
+ // The height ratio check when applying larger images on smaller screens is separate;
+ // in current policy we accept any such restore regardless of the relative dimensions.
+ private static final double MIN_HEIGHT_RATIO = 0;
+
// 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 =
@@ -142,8 +152,8 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
// letterboxing.
final double heightRatio = mDesiredMinHeight / options.outHeight;
if (options.outWidth < mDesiredMinWidth
- || heightRatio <= 0
- || heightRatio >= 1.33) {
+ || heightRatio >= MAX_HEIGHT_RATIO
+ || heightRatio <= MIN_HEIGHT_RATIO) {
// 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