diff options
author | Adam Cohen <adamcohen@google.com> | 2015-06-23 16:56:59 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2015-06-23 17:50:27 -0700 |
commit | b15d43837c5c3a0c52bb5112c23738eeaee1dc1e (patch) | |
tree | ce1abb4a46449e2d41b1e59aa9732f1a68843516 /WallpaperPicker/src/com/android/launcher3 | |
parent | b42120300ec622804af2de9c29ce849f96e4de23 (diff) | |
download | android_packages_apps_Trebuchet-b15d43837c5c3a0c52bb5112c23738eeaee1dc1e.tar.gz android_packages_apps_Trebuchet-b15d43837c5c3a0c52bb5112c23738eeaee1dc1e.tar.bz2 android_packages_apps_Trebuchet-b15d43837c5c3a0c52bb5112c23738eeaee1dc1e.zip |
Avoid crashing if we don't have the READ_EXTERNAL_STORAGE permission
issue 22019397
Change-Id: I7d556494569afaeac0ecdd641a089b78663b5563
Diffstat (limited to 'WallpaperPicker/src/com/android/launcher3')
-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, |