2024-11-14 07:47:52 -05:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2024-11-14 07:37:58 -05:00
|
|
|
From: Jean-Michel Trivi <jmtrivi@google.com>
|
|
|
|
Date: Mon, 24 Jun 2024 17:29:14 -0700
|
|
|
|
Subject: [PATCH] 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
|
|
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:a8d2785d69314086dc3b5b2531386fefff079ce7)
|
|
|
|
Merged-In: Iac9f27f14bae29e0fabc31e05da2357f6f4f16c7
|
|
|
|
Change-Id: Iac9f27f14bae29e0fabc31e05da2357f6f4f16c7
|
|
|
|
---
|
|
|
|
media/java/android/media/RingtoneManager.java | 8 ++++++--
|
|
|
|
.../android/providers/settings/SettingsProvider.java | 11 +++++++----
|
|
|
|
2 files changed, 13 insertions(+), 6 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java
|
2024-11-14 07:47:52 -05:00
|
|
|
index ad4751165d30..ea1cddca99d1 100644
|
2024-11-14 07:37:58 -05:00
|
|
|
--- a/media/java/android/media/RingtoneManager.java
|
|
|
|
+++ b/media/java/android/media/RingtoneManager.java
|
2024-11-14 07:47:52 -05:00
|
|
|
@@ -824,9 +824,13 @@ public class RingtoneManager {
|
2024-11-14 07:37:58 -05:00
|
|
|
+ " 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
|
2024-11-14 07:47:52 -05:00
|
|
|
index 7cb41275984e..02165eb8a213 100644
|
2024-11-14 07:37:58 -05:00
|
|
|
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
|
|
|
|
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
|
2024-11-14 07:47:52 -05:00
|
|
|
@@ -1734,7 +1734,7 @@ public class SettingsProvider extends ContentProvider {
|
2024-11-14 07:37:58 -05:00
|
|
|
cacheName = Settings.System.ALARM_ALERT_CACHE;
|
|
|
|
}
|
|
|
|
if (cacheName != null) {
|
|
|
|
- if (!isValidAudioUri(name, value)) {
|
|
|
|
+ if (!isValidMediaUri(name, value)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final File cacheFile = new File(
|
2024-11-14 07:47:52 -05:00
|
|
|
@@ -1769,7 +1769,7 @@ public class SettingsProvider extends ContentProvider {
|
2024-11-14 07:37:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- 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(
|
2024-11-14 07:47:52 -05:00
|
|
|
@@ -1787,10 +1787,13 @@ public class SettingsProvider extends ContentProvider {
|
2024-11-14 07:37:58 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|