From 31f25696d950dd54e8b339074b98ad6335738f2f Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Wed, 3 Dec 2014 13:07:24 -0800 Subject: [PATCH] Adjust wallpaper-restore acceptance criteria Previously the dimension check had implicit orientation sensitivity. We now make sure to compare the candidate image's width to the smallest screen dimension for acceptance purposes; this fixes cases when we would e.g. get a restored image of (1680x2560) but believe that we needed it to have a max width of 2048, even though it had originated on that same device -- due to current-orientation issues. Bug 18448052 Change-Id: I64ca6a4ed91ce1ccc04f5a9a6851e5cfe511b7c7 --- core/java/android/app/backup/WallpaperBackupHelper.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java index a55cc2b4b78b4..7a809361632c4 100644 --- a/core/java/android/app/backup/WallpaperBackupHelper.java +++ b/core/java/android/app/backup/WallpaperBackupHelper.java @@ -102,9 +102,8 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu final Display d = wm.getDefaultDisplay(); final Point size = new Point(); d.getSize(size); - mDesiredMinWidth = size.x; + mDesiredMinWidth = Math.min(size.x, size.y); mDesiredMinHeight = (double) wpm.getDesiredMinimumHeight(); - if (mDesiredMinHeight <= 0) { mDesiredMinHeight = size.y; } @@ -149,9 +148,13 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu // 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. + // letterboxing. At this point we know that mDesiredMinWidth is the + // smallest dimension, regardless of current orientation, so we can + // safely require that the candidate's width and height both exceed + // that hard minimum. final double heightRatio = mDesiredMinHeight / options.outHeight; if (options.outWidth < mDesiredMinWidth + || options.outHeight < mDesiredMinWidth || heightRatio >= MAX_HEIGHT_RATIO || heightRatio <= MIN_HEIGHT_RATIO) { // Not wide enough for the screen, or too short/tall to be a good fit