diff options
author | James Lemieux <jplemieux@google.com> | 2016-12-12 17:58:32 -0800 |
---|---|---|
committer | James Lemieux <jplemieux@google.com> | 2016-12-13 11:15:41 -0800 |
commit | f223d86acfc4d2f37727ebe5b62a28b621a7cd65 (patch) | |
tree | 13eff39bb345337b1e9908891cce24526056cb0c /src | |
parent | e32abc69373fce9f575d2b9839c98c0bae5ec4e0 (diff) | |
download | android_packages_apps_DeskClock-f223d86acfc4d2f37727ebe5b62a28b621a7cd65.tar.gz android_packages_apps_DeskClock-f223d86acfc4d2f37727ebe5b62a28b621a7cd65.tar.bz2 android_packages_apps_DeskClock-f223d86acfc4d2f37727ebe5b62a28b621a7cd65.zip |
Handle SecurityExceptions while releasing file permissions
Bug: 33461345
Test: Manual test of RingtonePickerActivity
When custom ringtones are created, a persistable file permission to
read (play) the ringtone is taken. When the ringtone is deleted, the
permission is released. If the file was removed from the file system
prior to releasing the permission, a SecurityException occurs because
the permission in question is no longer held by the application. This
SecurityException is now handled gracefully.
Change-Id: Ia6fe9dbe2d1129bd6c081ae081da52fb7e61e334
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/deskclock/ringtone/RingtonePickerActivity.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/com/android/deskclock/ringtone/RingtonePickerActivity.java b/src/com/android/deskclock/ringtone/RingtonePickerActivity.java index 30b026fae..3fd5b95ea 100644 --- a/src/com/android/deskclock/ringtone/RingtonePickerActivity.java +++ b/src/com/android/deskclock/ringtone/RingtonePickerActivity.java @@ -603,8 +603,14 @@ public class RingtonePickerActivity extends BaseActivity } } - // Release the permission to read (playback) the audio at the uri. - cr.releasePersistableUriPermission(mRemoveUri, FLAG_GRANT_READ_URI_PERMISSION); + try { + // Release the permission to read (playback) the audio at the uri. + cr.releasePersistableUriPermission(mRemoveUri, FLAG_GRANT_READ_URI_PERMISSION); + } catch (SecurityException ignore) { + // If the file was already deleted from the file system, a SecurityException is + // thrown indicating this app did not hold the read permission being released. + LogUtils.w("SecurityException while releasing read permission for " + mRemoveUri); + } return null; } |