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

Commit eeffe0c9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Uncanonicalize URIs when searching for audio-coupled haptics." into qt-dev

parents beee882c 8b1f3c97
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -330,18 +330,25 @@ public abstract class VibrationEffect implements Parcelable {
    @TestApi
    @Nullable
    public static VibrationEffect get(Uri uri, Context context) {
        final ContentResolver cr = context.getContentResolver();
        Uri uncanonicalUri = cr.uncanonicalize(uri);
        if (uncanonicalUri == null) {
            // If we already had an uncanonical URI, it's possible we'll get null back here. In
            // this case, just use the URI as passed in since it wasn't canonicalized in the first
            // place.
            uncanonicalUri = uri;
        }
        String[] uris = context.getResources().getStringArray(
                com.android.internal.R.array.config_ringtoneEffectUris);
        for (int i = 0; i < uris.length && i < RINGTONES.length; i++) {
            if (uris[i] == null) {
                continue;
            }
            ContentResolver cr = context.getContentResolver();
            Uri mappedUri = cr.uncanonicalize(Uri.parse(uris[i]));
            if (mappedUri == null) {
                continue;
            }
            if (mappedUri.equals(uri)) {
            if (mappedUri.equals(uncanonicalUri)) {
                return get(RINGTONES[i]);
            }
        }