Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit a3d258e

Browse files
jmtrivischfan-1
authored andcommitted
RingtoneManager: allow video ringtone URI
When checking the MIME type for the default ringtone, also allow it to refer to video content. Bug: 205837340 Test: see POC + atest android.media.audio.cts.RingtoneManagerTest Merged-In: Iac9f27f14bae29e0fabc31e05da2357f6f4f16c7 Change-Id: Iac9f27f14bae29e0fabc31e05da2357f6f4f16c7
1 parent de5889a commit a3d258e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

media/java/android/media/RingtoneManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,13 @@ public static void setActualDefaultRingtoneUri(Context context, int type, Uri ri
834834
+ " ignored: failure to find mimeType (no access from this context?)");
835835
return;
836836
}
837-
if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg"))) {
837+
if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
838+
|| mimeType.equals("application/x-flac")
839+
// also check for video ringtones
840+
|| mimeType.startsWith("video/") || mimeType.equals("application/mp4"))) {
838841
Log.e(TAG, "setActualDefaultRingtoneUri for URI:" + ringtoneUri
839-
+ " ignored: associated mimeType:" + mimeType + " is not an audio type");
842+
+ " ignored: associated MIME type:" + mimeType
843+
+ " is not a recognized audio or video type");
840844
return;
841845
}
842846
}

packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ private boolean mutateSystemSetting(String name, String value, int runAsUserId,
18861886
cacheName = Settings.System.ALARM_ALERT_CACHE;
18871887
}
18881888
if (cacheName != null) {
1889-
if (!isValidAudioUri(name, value)) {
1889+
if (!isValidMediaUri(name, value)) {
18901890
return false;
18911891
}
18921892
final File cacheFile = new File(
@@ -1921,7 +1921,7 @@ private boolean mutateSystemSetting(String name, String value, int runAsUserId,
19211921
}
19221922
}
19231923

1924-
private boolean isValidAudioUri(String name, String uri) {
1924+
private boolean isValidMediaUri(String name, String uri) {
19251925
if (uri != null) {
19261926
Uri audioUri = Uri.parse(uri);
19271927
if (Settings.AUTHORITY.equals(
@@ -1939,10 +1939,13 @@ private boolean isValidAudioUri(String name, String uri) {
19391939
return false;
19401940
}
19411941
if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
1942-
|| mimeType.equals("application/x-flac"))) {
1942+
|| mimeType.equals("application/x-flac")
1943+
// also check for video ringtones
1944+
|| mimeType.startsWith("video/") || mimeType.equals("application/mp4"))) {
19431945
Slog.e(LOG_TAG,
19441946
"mutateSystemSetting for setting: " + name + " URI: " + audioUri
1945-
+ " ignored: associated mimeType: " + mimeType + " is not an audio type");
1947+
+ " ignored: associated MIME type: " + mimeType
1948+
+ " is not a recognized audio or video type");
19461949
return false;
19471950
}
19481951
}

0 commit comments

Comments
 (0)