Some fixes in the compat implementation of wallpaper manager

Change-Id: I781fd520e812aaeaab42b8b765d7e7f2e64a96a1
diff --git a/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java b/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
index b175f21..3431664 100644
--- a/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
@@ -132,14 +132,15 @@
         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 @@
 
                         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);