am f4a34a1d: am 8aed3e3f: Only fetch titles of ringtones coming from the MediaStore.

* commit 'f4a34a1d3b4339c24f7d7563eb13f9222d1f377d':
  Only fetch titles of ringtones coming from the MediaStore.
This commit is contained in:
Dan Sandler
2014-09-05 15:43:19 +00:00
committed by Android Git Automerger

View File

@@ -37,6 +37,7 @@ import android.preference.PreferenceCategory;
import android.preference.SeekBarVolumizer;
import android.preference.TwoStatePreference;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.util.Log;
@@ -238,11 +239,16 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
if (ringtoneUri == null) {
summary = context.getString(com.android.internal.R.string.ringtone_silent);
} else {
// Fetch the ringtone title from the media provider
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(ringtoneUri,
new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
if (MediaStore.AUTHORITY.equals(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);
@@ -250,6 +256,8 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
}
} 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();