diff options
author | Selim Cinek <cinek@google.com> | 2014-03-04 21:29:40 +0100 |
---|---|---|
committer | Selim Cinek <cinek@google.com> | 2014-03-05 14:56:42 +0100 |
commit | 459875d09eca62e9f8511adcf269216a7f8d87ac (patch) | |
tree | 7ed2a6234c27c61fa126354b4438c0b0346c9c39 /WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java | |
parent | 10acea596e3752d1eab693fd34209767e991c92d (diff) | |
download | android_packages_apps_Trebuchet-459875d09eca62e9f8511adcf269216a7f8d87ac.tar.gz android_packages_apps_Trebuchet-459875d09eca62e9f8511adcf269216a7f8d87ac.tar.bz2 android_packages_apps_Trebuchet-459875d09eca62e9f8511adcf269216a7f8d87ac.zip |
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: I76ee2c0ab268b0ab4bde606706046caf0e39f1e9
Diffstat (limited to 'WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java')
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java index 561c4bb6a..bbbd9105c 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/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; } |