diff options
author | Adam Cohen <adamcohen@google.com> | 2015-06-24 16:19:22 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-24 16:19:23 +0000 |
commit | ba5ecebd1b4a5605da3846a6b1222a95d296c2cb (patch) | |
tree | e6f979785194d7c5968c708bddb1228bb4ab728e | |
parent | adb031e5ea81a86123355d76a4006d7da20a4039 (diff) | |
parent | b15d43837c5c3a0c52bb5112c23738eeaee1dc1e (diff) | |
download | android_packages_apps_Trebuchet-ba5ecebd1b4a5605da3846a6b1222a95d296c2cb.tar.gz android_packages_apps_Trebuchet-ba5ecebd1b4a5605da3846a6b1222a95d296c2cb.tar.bz2 android_packages_apps_Trebuchet-ba5ecebd1b4a5605da3846a6b1222a95d296c2cb.zip |
Merge "Avoid crashing if we don't have the READ_EXTERNAL_STORAGE permission" into ub-launcher3-burnaby
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java | 13 |
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 d9bfc30eb..88dc3e22b 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, |