diff options
Diffstat (limited to 'packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java')
-rw-r--r-- | packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java index dd906cd..cda15d2 100644 --- a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java +++ b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java @@ -141,7 +141,21 @@ public class WallpaperCropActivity extends Activity { final AsyncTask<Void, Void, Void> loadBitmapTask = new AsyncTask<Void, Void, Void>() { protected Void doInBackground(Void...args) { if (!isCancelled()) { - bitmapSource.loadInBackground(); + try { + bitmapSource.loadInBackground(); + } 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; } |