From 7b92e281a79d537442cc982c05fe39593bdefe85 Mon Sep 17 00:00:00 2001 From: Andre Lago Date: Thu, 25 Aug 2016 16:44:04 +0100 Subject: [PATCH] [Settings App] Get ringtone titles from Ringtone Instead of using custom code to get ringtone titles, use the Ringtone API which already returns 'None' if the Uri is null Bug: 31084929 Change-Id: Ifff3eaa3591e90020a2ac108a5916e19fb71e0bd --- .../settings/notification/SoundSettings.java | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java index 48b46167035..17e6f780fa5 100644 --- a/src/com/android/settings/notification/SoundSettings.java +++ b/src/com/android/settings/notification/SoundSettings.java @@ -478,37 +478,8 @@ public class SoundSettings extends SettingsPreferenceFragment return null; } Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type); - CharSequence summary = context.getString(com.android.internal.R.string.ringtone_unknown); - // Is it a silent ringtone? - if (ringtoneUri == null) { - summary = context.getString(com.android.internal.R.string.ringtone_silent); - } else { - Cursor cursor = null; - try { - if (MediaStore.AUTHORITY.equals(getUriWithoutUserId(ringtoneUri).getAuthority())) { - // Fetch the ringtone title from the media provider - cursor = context.getContentResolver().query(ringtoneUri, - new String[] { MediaStore.Audio.Media.TITLE }, null, null, null); - } else if (ContentResolver.SCHEME_CONTENT.equals(ringtoneUri.getScheme())) { - cursor = context.getContentResolver().query(ringtoneUri, - new String[] { OpenableColumns.DISPLAY_NAME }, null, null, null); - } - if (cursor != null) { - if (cursor.moveToFirst()) { - summary = cursor.getString(0); - } - } - } catch (SQLiteException sqle) { - // Unknown title for the ringtone - } catch (IllegalArgumentException iae) { - // Some other error retrieving the column from the provider - } finally { - if (cursor != null) { - cursor.close(); - } - } - } - return summary; + return Ringtone.getTitle(context, ringtoneUri, false /* followSettingsUri */, + true /* allowRemote */); } // === Vibrate when ringing ===