Merge "Revert "Ringtone uri should add type query"" am: 56da278127 am: 7a5e865a80 am: b145311a8d am: 3bff601a8a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1429968 Change-Id: I3df68434989ee8231db6adf41a203526be5027ab
This commit is contained in:
@@ -1129,14 +1129,12 @@ public class RingtoneManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try finding the scanned ringtone
|
// Try finding the scanned ringtone
|
||||||
final String whichAudio = getQueryStringForType(type);
|
|
||||||
final String filename = getDefaultRingtoneFilename(type);
|
final String filename = getDefaultRingtoneFilename(type);
|
||||||
final String where = MediaColumns.DISPLAY_NAME + "=?," + whichAudio + "=?";
|
|
||||||
final Uri baseUri = MediaStore.Audio.Media.INTERNAL_CONTENT_URI;
|
final Uri baseUri = MediaStore.Audio.Media.INTERNAL_CONTENT_URI;
|
||||||
try (Cursor cursor = context.getContentResolver().query(baseUri,
|
try (Cursor cursor = context.getContentResolver().query(baseUri,
|
||||||
new String[] { MediaColumns._ID },
|
new String[] { MediaColumns._ID },
|
||||||
where,
|
MediaColumns.DISPLAY_NAME + "=?",
|
||||||
new String[] { filename , "1"}, null)) {
|
new String[] { filename }, null)) {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
final Uri ringtoneUri = context.getContentResolver().canonicalizeOrElse(
|
final Uri ringtoneUri = context.getContentResolver().canonicalizeOrElse(
|
||||||
ContentUris.withAppendedId(baseUri, cursor.getLong(0)));
|
ContentUris.withAppendedId(baseUri, cursor.getLong(0)));
|
||||||
@@ -1164,13 +1162,4 @@ public class RingtoneManager {
|
|||||||
default: throw new IllegalArgumentException();
|
default: throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getQueryStringForType(int type) {
|
|
||||||
switch (type) {
|
|
||||||
case TYPE_RINGTONE: return MediaStore.Audio.AudioColumns.IS_RINGTONE;
|
|
||||||
case TYPE_NOTIFICATION: return MediaStore.Audio.AudioColumns.IS_NOTIFICATION;
|
|
||||||
case TYPE_ALARM: return MediaStore.Audio.AudioColumns.IS_ALARM;
|
|
||||||
default: throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user