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

Commit 760d2714 authored by Andre Lago's avatar Andre Lago
Browse files

[RingtoneManager] Remove user id from internal Uri

Prevent system ringtones from leaking with user id's on them

Test: manual
Change-Id: Ia4492c75211f9637e075450763f201bf24c5bf03
parent cd607bf5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -727,7 +727,9 @@ public class RingtoneManager {

        String setting = getSettingForType(type);
        if (setting == null) return;
        if(!isInternalRingtoneUri(ringtoneUri)) {
            ringtoneUri = ContentProvider.maybeAddUserId(ringtoneUri, context.getUserId());
        }
        Settings.System.putStringForUser(resolver, setting,
                ringtoneUri != null ? ringtoneUri.toString() : null, context.getUserId());

@@ -744,6 +746,12 @@ public class RingtoneManager {
        }
    }

    private static boolean isInternalRingtoneUri(Uri uri) {
        Uri uriWithoutUserId = ContentProvider.getUriWithoutUserId(uri);
        return uriWithoutUserId == null ? false : uriWithoutUserId.toString()
                        .startsWith(MediaStore.Audio.Media.INTERNAL_CONTENT_URI.toString());
    }

    /**
     * Try opening the given ringtone locally first, but failover to
     * {@link IRingtonePlayer} if we can't access it directly. Typically happens