summaryrefslogtreecommitdiffstats
path: root/packages/WallpaperCropper
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2014-03-21 19:54:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-03-21 19:54:55 +0000
commit146af201d380cffa6a540fd0d52590bd9d30b614 (patch)
treee5ecc0308759fc51ff4e7385f6f2baf8d6cfef38 /packages/WallpaperCropper
parent3daafcd7bab6e3ace72396576529e3049ab4c066 (diff)
parentd6901a95d8aabc25fdd108d3605b34f848ab10e0 (diff)
downloadframeworks_base-146af201d380cffa6a540fd0d52590bd9d30b614.zip
frameworks_base-146af201d380cffa6a540fd0d52590bd9d30b614.tar.gz
frameworks_base-146af201d380cffa6a540fd0d52590bd9d30b614.tar.bz2
Merge "Catching security exception when activity destroyed"
Diffstat (limited to 'packages/WallpaperCropper')
-rw-r--r--packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java16
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;
}