mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-23 22:49:28 -05:00
082bc48c32
https://review.lineageos.org/q/topic:P_asb_2022-05 https://review.lineageos.org/q/topic:P_asb_2022-06 https://review.lineageos.org/q/topic:P_asb_2022-07 https://review.lineageos.org/q/topic:P_asb_2022-08 https://review.lineageos.org/q/topic:P_asb_2022-09 https://review.lineageos.org/q/topic:P_asb_2022-10 https://review.lineageos.org/q/topic:P_asb_2022-11 https://review.lineageos.org/q/topic:P_asb_2022-12 https://review.lineageos.org/q/topic:P_asb_2023-01 https://review.lineageos.org/q/topic:P_asb_2023-02 https://review.lineageos.org/q/topic:P_asb_2023-03 https://review.lineageos.org/q/topic:P_asb_2023-04 https://review.lineageos.org/q/topic:P_asb_2023-05 https://review.lineageos.org/q/topic:P_asb_2023-06 https://review.lineageos.org/q/topic:P_asb_2023-07 accounted for via manifest change: https://review.lineageos.org/c/LineageOS/android_external_freetype/+/361250 https://review.lineageos.org/q/topic:P_asb_2023-08 accounted for via manifest change: https://review.lineageos.org/c/LineageOS/android_external_freetype/+/364606 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/365328 https://review.lineageos.org/q/topic:P_asb_2023-09 https://review.lineageos.org/q/topic:P_asb_2023-10 https://review.lineageos.org/q/topic:P_asb_2023-11 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/374916 https://review.lineageos.org/q/topic:P_asb_2023-12 https://review.lineageos.org/q/topic:P_asb_2024-01 https://review.lineageos.org/q/topic:P_asb_2024-02 https://review.lineageos.org/q/topic:P_asb_2024-03 https://review.lineageos.org/q/topic:P_asb_2024-04 Signed-off-by: Tavi <tavi@divested.dev>
61 lines
2.6 KiB
Diff
61 lines
2.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jean-Michel Trivi <jmtrivi@google.com>
|
|
Date: Wed, 7 Dec 2022 04:36:46 +0000
|
|
Subject: [PATCH] RingtoneManager: verify default ringtone is audio
|
|
|
|
When a ringtone picker tries to set a ringtone through
|
|
RingtoneManager.setActualDefaultRingtoneUri (also
|
|
called by com.android.settings.DefaultRingtonePreference),
|
|
verify the mimeType can be obtained (not found when caller
|
|
doesn't have access to it) and it is an audio resource.
|
|
|
|
Bug: 205837340
|
|
Test: atest android.media.audio.cts.RingtoneManagerTest
|
|
(cherry picked from commit 38618f9fb16d3b5617e2289354d47abe5af17dad)
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:377144b64325dadad102f5233ecb50a4446b205b)
|
|
Merged-In: I3f2c487ded405c0c1a83ef0a2fe99cff7cc9328e
|
|
Change-Id: I3f2c487ded405c0c1a83ef0a2fe99cff7cc9328e
|
|
---
|
|
media/java/android/media/RingtoneManager.java | 19 +++++++++++++++++--
|
|
1 file changed, 17 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java
|
|
index fefa1ede849e..0e03bfb2502a 100644
|
|
--- a/media/java/android/media/RingtoneManager.java
|
|
+++ b/media/java/android/media/RingtoneManager.java
|
|
@@ -819,10 +819,10 @@ public class RingtoneManager {
|
|
|
|
return ringtoneUri;
|
|
}
|
|
-
|
|
+
|
|
/**
|
|
* Sets the {@link Uri} of the default sound for a given sound type.
|
|
- *
|
|
+ *
|
|
* @param context A context used for querying.
|
|
* @param type The type whose default sound should be set. One of
|
|
* {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or
|
|
@@ -843,6 +843,21 @@ public class RingtoneManager {
|
|
if(!isInternalRingtoneUri(ringtoneUri)) {
|
|
ringtoneUri = ContentProvider.maybeAddUserId(ringtoneUri, context.getUserId());
|
|
}
|
|
+
|
|
+ if (ringtoneUri != null) {
|
|
+ final String mimeType = resolver.getType(ringtoneUri);
|
|
+ if (mimeType == null) {
|
|
+ Log.e(TAG, "setActualDefaultRingtoneUri for URI:" + ringtoneUri
|
|
+ + " ignored: failure to find mimeType (no access from this context?)");
|
|
+ return;
|
|
+ }
|
|
+ if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg"))) {
|
|
+ Log.e(TAG, "setActualDefaultRingtoneUri for URI:" + ringtoneUri
|
|
+ + " ignored: associated mimeType:" + mimeType + " is not an audio type");
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
Settings.System.putStringForUser(resolver, setting,
|
|
ringtoneUri != null ? ringtoneUri.toString() : null, context.getUserId());
|
|
|