* commit '152893dd66a8cdecab14595c20085a0f10917f21': Accept any restored wallpaper
This commit is contained in:
@@ -39,6 +39,11 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu
|
|||||||
private static final String TAG = "WallpaperBackupHelper";
|
private static final String TAG = "WallpaperBackupHelper";
|
||||||
private static final boolean DEBUG = false;
|
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
|
// This path must match what the WallpaperManagerService uses
|
||||||
// TODO: Will need to change if backing up non-primary user's wallpaper
|
// TODO: Will need to change if backing up non-primary user's wallpaper
|
||||||
public static final String WALLPAPER_IMAGE =
|
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
|
if (DEBUG) Slog.d(TAG, "Restoring wallpaper image w=" + options.outWidth
|
||||||
+ " h=" + options.outHeight);
|
+ " h=" + options.outHeight);
|
||||||
|
|
||||||
// We accept any wallpaper that is at least as wide as our preference
|
if (REJECT_OUTSIZED_RESTORE) {
|
||||||
// (i.e. wide enough to fill the screen), and is within a comfortable
|
// We accept any wallpaper that is at least as wide as our preference
|
||||||
// factor of the target height, to avoid significant clipping/scaling/
|
// (i.e. wide enough to fill the screen), and is within a comfortable
|
||||||
// letterboxing.
|
// factor of the target height, to avoid significant clipping/scaling/
|
||||||
final double heightRatio = mDesiredMinHeight / options.outHeight;
|
// letterboxing.
|
||||||
if (options.outWidth >= mDesiredMinWidth
|
final double heightRatio = mDesiredMinHeight / options.outHeight;
|
||||||
&& heightRatio > 0 && heightRatio < 1.33) {
|
if (options.outWidth < mDesiredMinWidth
|
||||||
// sufficiently close to our resolution; go ahead and use it
|
|| heightRatio <= 0
|
||||||
Slog.d(TAG, "Applying restored wallpaper image.");
|
|| heightRatio >= 1.33) {
|
||||||
f.renameTo(new File(WALLPAPER_IMAGE));
|
// Not wide enough for the screen, or too short/tall to be a good fit
|
||||||
// TODO: spin a service to copy the restored image to sd/usb storage,
|
// for the height of the screen, broken image file, or the system's
|
||||||
// since it does not exist anywhere other than the private wallpaper
|
// desires for wallpaper size are in a bad state. Probably one of the
|
||||||
// file.
|
// first two.
|
||||||
} else {
|
Slog.i(TAG, "Restored image dimensions (w="
|
||||||
Slog.i(TAG, "Restored image dimensions (w="
|
+ options.outWidth + ", h=" + options.outHeight
|
||||||
+ options.outWidth + ", h=" + options.outHeight
|
+ ") too far off target (tw="
|
||||||
+ ") too far off target (tw="
|
+ mDesiredMinWidth + ", th=" + mDesiredMinHeight
|
||||||
+ mDesiredMinWidth + ", th=" + mDesiredMinHeight
|
+ "); falling back to default wallpaper.");
|
||||||
+ "); falling back to default wallpaper.");
|
f.delete();
|
||||||
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)) {
|
} else if (key.equals(WALLPAPER_INFO_KEY)) {
|
||||||
// XML file containing wallpaper info
|
// XML file containing wallpaper info
|
||||||
|
|||||||
Reference in New Issue
Block a user