Skip to content

Commit 476b03b

Browse files
jsharkeyAndroid (Google) Code Review
authored andcommitted
Merge "Handle silent ringtone, title without permission." into jb-dev
2 parents 2321301 + 1d8e5c5 commit 476b03b

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

media/java/android/media/Ringtone.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,16 @@ private static String getTitle(Context context, Uri uri, boolean followSettingsU
128128
actualTitle);
129129
}
130130
} else {
131-
132-
if (DrmStore.AUTHORITY.equals(authority)) {
133-
cursor = res.query(uri, DRM_COLUMNS, null, null, null);
134-
} else if (MediaStore.AUTHORITY.equals(authority)) {
135-
cursor = res.query(uri, MEDIA_COLUMNS, null, null, null);
131+
try {
132+
if (DrmStore.AUTHORITY.equals(authority)) {
133+
cursor = res.query(uri, DRM_COLUMNS, null, null, null);
134+
} else if (MediaStore.AUTHORITY.equals(authority)) {
135+
cursor = res.query(uri, MEDIA_COLUMNS, null, null, null);
136+
}
137+
} catch (SecurityException e) {
138+
// missing cursor is handled below
136139
}
137-
140+
138141
try {
139142
if (cursor != null && cursor.getCount() == 1) {
140143
cursor.moveToFirst();
@@ -188,12 +191,12 @@ public void setUri(Uri uri) {
188191
} catch (SecurityException e) {
189192
destroyLocalPlayer();
190193
if (!mAllowRemote) {
191-
throw new IllegalStateException("Remote playback not allowed", e);
194+
Log.w(TAG, "Remote playback not allowed: " + e);
192195
}
193196
} catch (IOException e) {
194197
destroyLocalPlayer();
195198
if (!mAllowRemote) {
196-
throw new IllegalStateException("Remote playback not allowed", e);
199+
Log.w(TAG, "Remote playback not allowed: " + e);
197200
}
198201
}
199202

@@ -228,7 +231,7 @@ public void play() {
228231
Log.w(TAG, "Problem playing ringtone: " + e);
229232
}
230233
} else {
231-
throw new IllegalStateException("Neither local nor remote playback available");
234+
Log.w(TAG, "Neither local nor remote playback available");
232235
}
233236
}
234237

@@ -271,7 +274,8 @@ public boolean isPlaying() {
271274
return false;
272275
}
273276
} else {
274-
throw new IllegalStateException("Neither local nor remote playback available");
277+
Log.w(TAG, "Neither local nor remote playback available");
278+
return false;
275279
}
276280
}
277281

0 commit comments

Comments
 (0)