Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9d8d494 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

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: Id9b81e2db8314bc16df77d0a9221ce93143a8012
Change-Id: Iac9f27f14bae29e0fabc31e05da2357f6f4f16c7
parent 41f9ecdb
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -924,9 +924,13 @@ public class RingtoneManager {
                        + " 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;
            }
        }
+7 −4
Original line number Diff line number Diff line
@@ -1985,7 +1985,7 @@ public class SettingsProvider extends ContentProvider {

        File cacheFile = getCacheFile(name, callingUserId);
        if (cacheFile != null) {
            if (!isValidAudioUri(name, value)) {
            if (!isValidMediaUri(name, value)) {
                return false;
            }
            // Invalidate any relevant cache files
@@ -2046,7 +2046,7 @@ public class SettingsProvider extends ContentProvider {
        return true;
    }

    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(
@@ -2064,10 +2064,13 @@ public class SettingsProvider extends ContentProvider {
                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;
            }
        }