summaryrefslogtreecommitdiffstats
path: root/packages/WallpaperCropper
diff options
context:
space:
mode:
authorSelim Cinek <cinek@google.com>2014-03-21 20:24:55 +0100
committerSelim Cinek <cinek@google.com>2014-03-21 20:24:55 +0100
commitd6901a95d8aabc25fdd108d3605b34f848ab10e0 (patch)
tree20e4015a13344c56deac6e5452fa9168a6a227a8 /packages/WallpaperCropper
parentfc558d56c2040220853d9912d765cfc535463689 (diff)
downloadframeworks_base-d6901a95d8aabc25fdd108d3605b34f848ab10e0.zip
frameworks_base-d6901a95d8aabc25fdd108d3605b34f848ab10e0.tar.gz
frameworks_base-d6901a95d8aabc25fdd108d3605b34f848ab10e0.tar.bz2
Catching security exception when activity destroyed
Fixed a bug where an asynctask tried to load an image even after the activity was destroyed leading to a security exception since the permission could not be granted anymore. Bug: 12760267 Change-Id: Ieffb10b1007f349371647512ffe4fe72433344e7
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 b9b87b1..4cd797d 100644
--- a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
+++ b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
@@ -136,7 +136,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;
}