diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2012-05-07 11:22:08 -0700 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@android.com> | 2012-05-07 13:30:10 -0700 |
| commit | 1d8e5c588035550293ecd2558a2e285ee2789d38 (patch) | |
| tree | 24cd516caac7e5010d7f3d029f4dac6ce8a47929 /media/java | |
| parent | 3c5f92432734e1e3b9bdc515628a4c09d7759cd4 (diff) | |
| download | frameworks_base-1d8e5c588035550293ecd2558a2e285ee2789d38.zip frameworks_base-1d8e5c588035550293ecd2558a2e285ee2789d38.tar.gz frameworks_base-1d8e5c588035550293ecd2558a2e285ee2789d38.tar.bz2 | |
Handle silent ringtone, title without permission.
Silent ringtones have a valid Uri, but isn't openable by MediaPlayer,
so treat as no-op playback instead of throwing. Also handle missing
permissions when resolving title.
Bug: 6448074, 6447538
Change-Id: I656675d7fc2e78a6ba05824e13bdd43193fcfdf2
Diffstat (limited to 'media/java')
| -rw-r--r-- | media/java/android/media/Ringtone.java | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/media/java/android/media/Ringtone.java b/media/java/android/media/Ringtone.java index 57139d2..23f7b55 100644 --- a/media/java/android/media/Ringtone.java +++ b/media/java/android/media/Ringtone.java @@ -128,13 +128,16 @@ public class Ringtone { actualTitle); } } else { - - if (DrmStore.AUTHORITY.equals(authority)) { - cursor = res.query(uri, DRM_COLUMNS, null, null, null); - } else if (MediaStore.AUTHORITY.equals(authority)) { - cursor = res.query(uri, MEDIA_COLUMNS, null, null, null); + try { + if (DrmStore.AUTHORITY.equals(authority)) { + cursor = res.query(uri, DRM_COLUMNS, null, null, null); + } else if (MediaStore.AUTHORITY.equals(authority)) { + cursor = res.query(uri, MEDIA_COLUMNS, null, null, null); + } + } catch (SecurityException e) { + // missing cursor is handled below } - + try { if (cursor != null && cursor.getCount() == 1) { cursor.moveToFirst(); @@ -188,12 +191,12 @@ public class Ringtone { } catch (SecurityException e) { destroyLocalPlayer(); if (!mAllowRemote) { - throw new IllegalStateException("Remote playback not allowed", e); + Log.w(TAG, "Remote playback not allowed: " + e); } } catch (IOException e) { destroyLocalPlayer(); if (!mAllowRemote) { - throw new IllegalStateException("Remote playback not allowed", e); + Log.w(TAG, "Remote playback not allowed: " + e); } } @@ -228,7 +231,7 @@ public class Ringtone { Log.w(TAG, "Problem playing ringtone: " + e); } } else { - throw new IllegalStateException("Neither local nor remote playback available"); + Log.w(TAG, "Neither local nor remote playback available"); } } @@ -271,7 +274,8 @@ public class Ringtone { return false; } } else { - throw new IllegalStateException("Neither local nor remote playback available"); + Log.w(TAG, "Neither local nor remote playback available"); + return false; } } |
