summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Martinz <amartinz@shiftphones.com>2018-07-06 15:02:24 (GMT)
committerJoey Rizzoli <joey@lineageos.org>2018-07-14 13:35:02 (GMT)
commit801a519603e977c1f6075ebeaffe2d3816684cf0 (patch)
tree3e9a60dcc4b57f02f4e9d728a68ba37941ecec21
parent7cd01f5393dbb8d60fef34edd9e7f26863c19495 (diff)
downloadandroid_packages_apps_Trebuchet-801a519603e977c1f6075ebeaffe2d3816684cf0.zip
android_packages_apps_Trebuchet-801a519603e977c1f6075ebeaffe2d3816684cf0.tar.gz
android_packages_apps_Trebuchet-801a519603e977c1f6075ebeaffe2d3816684cf0.tar.bz2
WallpaperManager: do not crash because of insufficient permissions
In order to get the wallpaper, the app needs to be able to read external storage. Check if READ_EXTERNAL_STORAGE is granted before using it. Change-Id: I1559a3b9fa3dc3e20180bc380ddd4fa70eda1be3 Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
-rw-r--r--src/com/android/launcher3/compat/WallpaperManagerCompatVL.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java b/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
index 8e572ee..2a6d583 100644
--- a/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.compat;
+import android.Manifest;
import android.app.WallpaperInfo;
import android.app.WallpaperManager;
import android.app.job.JobInfo;
@@ -38,6 +39,7 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.ParcelFileDescriptor;
import android.support.annotation.Nullable;
+import android.support.v4.content.ContextCompat;
import android.support.v7.graphics.Palette;
import android.util.Log;
import android.util.Pair;
@@ -213,7 +215,8 @@ public class WallpaperManagerCompatVL extends WallpaperManagerCompat {
if (info != null) {
// For live wallpaper, extract colors from thumbnail
drawable = info.loadThumbnail(getPackageManager());
- } else {
+ } else if (ContextCompat.checkSelfPermission(this,
+ Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
if (Utilities.ATLEAST_NOUGAT) {
try (ParcelFileDescriptor fd = wm.getWallpaperFile(FLAG_SYSTEM)) {
BitmapRegionDecoder decoder = BitmapRegionDecoder