Only fetch titles of ringtones coming from the MediaStore.
As a fallback we attempt to get DISPLAY_NAME from the provider. Any other URIs probably don't have titles. Bug: 14093281 Change-Id: I39adbad52ef6dcc1686cbc738457b55c33948bd6
This commit is contained in:
@@ -37,6 +37,7 @@ import android.preference.PreferenceCategory;
|
|||||||
import android.preference.SeekBarVolumizer;
|
import android.preference.SeekBarVolumizer;
|
||||||
import android.preference.TwoStatePreference;
|
import android.preference.TwoStatePreference;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.provider.OpenableColumns;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -238,11 +239,16 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
if (ringtoneUri == null) {
|
if (ringtoneUri == null) {
|
||||||
summary = context.getString(com.android.internal.R.string.ringtone_silent);
|
summary = context.getString(com.android.internal.R.string.ringtone_silent);
|
||||||
} else {
|
} else {
|
||||||
// Fetch the ringtone title from the media provider
|
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
|
if (MediaStore.AUTHORITY.equals(ringtoneUri.getAuthority())) {
|
||||||
|
// Fetch the ringtone title from the media provider
|
||||||
cursor = context.getContentResolver().query(ringtoneUri,
|
cursor = context.getContentResolver().query(ringtoneUri,
|
||||||
new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
|
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 != null) {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
summary = cursor.getString(0);
|
summary = cursor.getString(0);
|
||||||
@@ -250,6 +256,8 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
} catch (SQLiteException sqle) {
|
} catch (SQLiteException sqle) {
|
||||||
// Unknown title for the ringtone
|
// Unknown title for the ringtone
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// Some other error retrieving the column from the provider
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
Reference in New Issue
Block a user