diff options
author | Adam Cohen <adamcohen@google.com> | 2014-07-24 10:39:57 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2014-07-24 10:48:20 -0700 |
commit | 8dc6e1bfa20d48babd6dd0f41bfc6de1a09cd67b (patch) | |
tree | 3b9fc9a9aef851153d8fa68239562fcf0013b99b /WallpaperPicker/src/com/android/launcher3 | |
parent | 260065cac2443d0dd5159ac1f8c74380c2f1af59 (diff) | |
download | android_packages_apps_Trebuchet-8dc6e1bfa20d48babd6dd0f41bfc6de1a09cd67b.tar.gz android_packages_apps_Trebuchet-8dc6e1bfa20d48babd6dd0f41bfc6de1a09cd67b.tar.bz2 android_packages_apps_Trebuchet-8dc6e1bfa20d48babd6dd0f41bfc6de1a09cd67b.zip |
Fix SecurityException when exiting wallpaper picker early
issue 16155967
Change-Id: Iba1add737089b73e6e5bbfb143dce4204fa9dc7c
Diffstat (limited to 'WallpaperPicker/src/com/android/launcher3')
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index 09793572b..95b19ce74 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -840,12 +840,26 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { final Context context = this; new AsyncTask<Void, Bitmap, Bitmap>() { protected Bitmap doInBackground(Void...args) { - int rotation = WallpaperCropActivity.getRotationFromExif(context, uri); - return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false); - + try { + int rotation = WallpaperCropActivity.getRotationFromExif(context, uri); + return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false); + } catch (SecurityException securityException) { + if (isDestroyed()) { + // Temporarily granted permissions are revoked when the activity + // finishes, potentially resulting in a SecurityException here. + // Even though {@link #isDestroyed} might also return true in different + // situations where the configuration changes, we are fine with + // catching these cases here as well. + cancel(false); + } else { + // otherwise it had a different cause and we throw it further + throw securityException; + } + return null; + } } protected void onPostExecute(Bitmap thumb) { - if (thumb != null) { + if (!isCancelled() && thumb != null) { image.setImageBitmap(thumb); Drawable thumbDrawable = image.getDrawable(); thumbDrawable.setDither(true); |