From 8c48d8bea64b95916b18bd41a4fdb58d4d7477be Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 25 Jan 2019 15:10:18 -0800 Subject: Changing min sdk to 25 Change-Id: I0d28069967854357ca755bf25dec19d4979bdecf --- .../dynamicui/WallpaperManagerCompatVL.java | 46 ++++++++++------------ 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'src_ui_overrides/com/android/launcher3/uioverrides') diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/dynamicui/WallpaperManagerCompatVL.java b/src_ui_overrides/com/android/launcher3/uioverrides/dynamicui/WallpaperManagerCompatVL.java index 680885943..500fdc360 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/dynamicui/WallpaperManagerCompatVL.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/dynamicui/WallpaperManagerCompatVL.java @@ -44,7 +44,6 @@ import android.os.ParcelFileDescriptor; import android.util.Log; import android.util.Pair; -import com.android.launcher3.Utilities; import com.android.launcher3.icons.ColorExtractor; import java.io.IOException; @@ -61,6 +60,8 @@ public class WallpaperManagerCompatVL extends WallpaperManagerCompat { private static final String ACTION_EXTRACTION_COMPLETE = "com.android.launcher3.uioverrides.dynamicui.WallpaperManagerCompatVL.EXTRACTION_COMPLETE"; + public static final int WALLPAPER_COMPAT_JOB_ID = 1; + private final ArrayList mListeners = new ArrayList<>(); private final Context mContext; @@ -122,7 +123,7 @@ public class WallpaperManagerCompatVL extends WallpaperManagerCompat { } private void reloadColors() { - JobInfo job = new JobInfo.Builder(Utilities.WALLPAPER_COMPAT_JOB_ID, + JobInfo job = new JobInfo.Builder(WALLPAPER_COMPAT_JOB_ID, new ComponentName(mContext, ColorExtractionService.class)) .setMinimumLatency(0).build(); ((JobScheduler) mContext.getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(job); @@ -137,9 +138,6 @@ public class WallpaperManagerCompatVL extends WallpaperManagerCompat { } private static final int getWallpaperId(Context context) { - if (!Utilities.ATLEAST_NOUGAT) { - return -1; - } return context.getSystemService(WallpaperManager.class).getWallpaperId(FLAG_SYSTEM); } @@ -215,27 +213,25 @@ public class WallpaperManagerCompatVL extends WallpaperManagerCompat { // For live wallpaper, extract colors from thumbnail drawable = info.loadThumbnail(getPackageManager()); } else { - if (Utilities.ATLEAST_NOUGAT) { - try (ParcelFileDescriptor fd = wm.getWallpaperFile(FLAG_SYSTEM)) { - BitmapRegionDecoder decoder = BitmapRegionDecoder - .newInstance(fd.getFileDescriptor(), false); - - int requestedArea = decoder.getWidth() * decoder.getHeight(); - BitmapFactory.Options options = new BitmapFactory.Options(); - - if (requestedArea > MAX_WALLPAPER_EXTRACTION_AREA) { - double areaRatio = - (double) requestedArea / MAX_WALLPAPER_EXTRACTION_AREA; - double nearestPowOf2 = - Math.floor(Math.log(areaRatio) / (2 * Math.log(2))); - options.inSampleSize = (int) Math.pow(2, nearestPowOf2); - } - Rect region = new Rect(0, 0, decoder.getWidth(), decoder.getHeight()); - bitmap = decoder.decodeRegion(region, options); - decoder.recycle(); - } catch (IOException | NullPointerException e) { - Log.e(TAG, "Fetching partial bitmap failed, trying old method", e); + try (ParcelFileDescriptor fd = wm.getWallpaperFile(FLAG_SYSTEM)) { + BitmapRegionDecoder decoder = BitmapRegionDecoder + .newInstance(fd.getFileDescriptor(), false); + + int requestedArea = decoder.getWidth() * decoder.getHeight(); + BitmapFactory.Options options = new BitmapFactory.Options(); + + if (requestedArea > MAX_WALLPAPER_EXTRACTION_AREA) { + double areaRatio = + (double) requestedArea / MAX_WALLPAPER_EXTRACTION_AREA; + double nearestPowOf2 = + Math.floor(Math.log(areaRatio) / (2 * Math.log(2))); + options.inSampleSize = (int) Math.pow(2, nearestPowOf2); } + Rect region = new Rect(0, 0, decoder.getWidth(), decoder.getHeight()); + bitmap = decoder.decodeRegion(region, options); + decoder.recycle(); + } catch (IOException | NullPointerException e) { + Log.e(TAG, "Fetching partial bitmap failed, trying old method", e); } if (bitmap == null) { drawable = wm.getDrawable(); -- cgit v1.2.3