summaryrefslogtreecommitdiffstats
path: root/WallpaperPicker
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2015-06-24 16:19:22 (GMT)
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-24 16:19:23 (GMT)
commitba5ecebd1b4a5605da3846a6b1222a95d296c2cb (patch)
treee6f979785194d7c5968c708bddb1228bb4ab728e /WallpaperPicker
parentadb031e5ea81a86123355d76a4006d7da20a4039 (diff)
parentb15d43837c5c3a0c52bb5112c23738eeaee1dc1e (diff)
downloadandroid_packages_apps_Trebuchet-ba5ecebd1b4a5605da3846a6b1222a95d296c2cb.zip
android_packages_apps_Trebuchet-ba5ecebd1b4a5605da3846a6b1222a95d296c2cb.tar.gz
android_packages_apps_Trebuchet-ba5ecebd1b4a5605da3846a6b1222a95d296c2cb.tar.bz2
Merge "Avoid crashing if we don't have the READ_EXTERNAL_STORAGE permission" into ub-launcher3-burnaby
Diffstat (limited to 'WallpaperPicker')
-rw-r--r--WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
index d9bfc30..88dc3e2 100644
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -16,6 +16,7 @@
package com.android.launcher3;
+import android.Manifest.permission;
import android.animation.LayoutTransition;
import android.annotation.TargetApi;
import android.app.ActionBar;
@@ -37,10 +38,12 @@ import android.graphics.PorterDuff;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.Manifest;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.os.Process;
import android.provider.MediaStore;
import android.util.Log;
import android.util.Pair;
@@ -680,6 +683,16 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
protected Bitmap getThumbnailOfLastPhoto() {
+ boolean canReadExternalStorage = getActivity().checkPermission(
+ Manifest.permission.READ_EXTERNAL_STORAGE, Process.myPid(), Process.myUid()) ==
+ PackageManager.PERMISSION_GRANTED;
+
+ if (!canReadExternalStorage) {
+ // MediaStore.Images.Media.EXTERNAL_CONTENT_URI requires
+ // the READ_EXTERNAL_STORAGE permission
+ return null;
+ }
+
Cursor cursor = MediaStore.Images.Media.query(getContext().getContentResolver(),
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[] { MediaStore.Images.ImageColumns._ID,