From 9d1aa13a9738eaa47c419ec58ce793bf6d867bb3 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 23 May 2017 16:25:54 -0700 Subject: Some fixes in the compat implementation of wallpaper manager Change-Id: I781fd520e812aaeaab42b8b765d7e7f2e64a96a1 --- src/com/android/launcher3/compat/WallpaperManagerCompatVL.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/com/android/launcher3/compat') diff --git a/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java b/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java index b175f2113..34316644a 100644 --- a/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java +++ b/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java @@ -132,14 +132,15 @@ public class WallpaperManagerCompatVL extends WallpaperManagerCompat { String[] parts = value.split(","); Integer wallpaperId = Integer.parseInt(parts[1]); if (parts.length == 2) { + // There is no wallpaper color info present, eg when live wallpaper has no preview. return Pair.create(wallpaperId, null); } - SparseIntArray colors = new SparseIntArray((parts.length - 2) / 2); + SparseIntArray colorsToOccurrences = new SparseIntArray((parts.length - 2) / 2); for (int i = 2; i < parts.length; i += 2) { - colors.put(Integer.parseInt(parts[i]), Integer.parseInt(parts[i + 1])); + colorsToOccurrences.put(Integer.parseInt(parts[i]), Integer.parseInt(parts[i + 1])); } - return Pair.create(wallpaperId, new WallpaperColorsCompat(colors, false)); + return Pair.create(wallpaperId, new WallpaperColorsCompat(colorsToOccurrences, false)); } /** @@ -178,7 +179,7 @@ public class WallpaperManagerCompatVL extends WallpaperManagerCompat { if (requestedArea > MAX_WALLPAPER_EXTRACTION_AREA) { double areaRatio = - MAX_WALLPAPER_EXTRACTION_AREA / (double) requestedArea; + (double) requestedArea / MAX_WALLPAPER_EXTRACTION_AREA; double nearestPowOf2 = Math.floor(Math.log(areaRatio) / (2 * Math.log(2))); options.inSampleSize = (int) Math.pow(2, nearestPowOf2); -- cgit v1.2.3