Skip to content

Commit

Permalink
RingtoneManager: allow video ringtone URI
Browse files Browse the repository at this point in the history
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
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:de83ef4f51cad7ea1eb91f5d328d79b719251abe)
Merged-In: Iac9f27f14bae29e0fabc31e05da2357f6f4f16c7
Change-Id: Iac9f27f14bae29e0fabc31e05da2357f6f4f16c7
  • Loading branch information
jmtrivi authored and aoleary committed Nov 18, 2024
1 parent 83f81ad commit 91e9cf9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions media/java/android/media/RingtoneManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,13 @@ public static void setActualDefaultRingtoneUriForPhoneAccountHandle(@NonNull Con
+ " ignored: failure to find mimeType (no access from this context?)");
return;
}
if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg"))) {
if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
|| mimeType.equals("application/x-flac")
// also check for video ringtones
|| mimeType.startsWith("video/") || mimeType.equals("application/mp4"))) {
Log.e(TAG, "setActualDefaultRingtoneUri for URI:" + ringtoneUri
+ " ignored: associated mimeType:" + mimeType + " is not an audio type");
+ " ignored: associated MIME type:" + mimeType
+ " is not a recognized audio or video type");
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,7 @@ private boolean mutateSystemSetting(String name, String value, int runAsUserId,
cacheName = Settings.System.ALARM_ALERT_CACHE;
}
if (cacheName != null) {
if (!isValidAudioUri(name, value)) {
if (!isValidMediaUri(name, value)) {
return false;
}
final File cacheFile = new File(
Expand Down Expand Up @@ -1978,7 +1978,7 @@ private boolean mutateSystemSetting(String name, String value, int runAsUserId,
}
}

private boolean isValidAudioUri(String name, String uri) {
private boolean isValidMediaUri(String name, String uri) {
if (uri != null) {
Uri audioUri = Uri.parse(uri);
if (Settings.AUTHORITY.equals(
Expand All @@ -1996,10 +1996,13 @@ private boolean isValidAudioUri(String name, String uri) {
return false;
}
if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
|| mimeType.equals("application/x-flac"))) {
|| mimeType.equals("application/x-flac")
// also check for video ringtones
|| mimeType.startsWith("video/") || mimeType.equals("application/mp4"))) {
Slog.e(LOG_TAG,
"mutateSystemSetting for setting: " + name + " URI: " + audioUri
+ " ignored: associated mimeType: " + mimeType + " is not an audio type");
+ " ignored: associated MIME type: " + mimeType
+ " is not a recognized audio or video type");
return false;
}
}
Expand Down

0 comments on commit 91e9cf9

Please sign in to comment.