From 32fa5931f9ddb76ede0d3471b994a715aab27c46 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 18 May 2018 18:07:09 -0700 Subject: [PATCH] Uncanonicalize URIs before comparing them. In order to ensure we maintain compatibility, we now configure the canonical URIs instead of the raw URIs. Correspondingly, we need to uncanonicalize before comparing them. Note that we uncanonicalize the configured URI, rather than canonicalizing the one given to us. This is because the canonicalization format might change (e.g. add extra parameters) at which point they'll no longer by equal, but should always uncanonicalize to the same value. Bug: 75947705 Test: manual Change-Id: If3b02dfef480245210fd2c585c7c727de77a4a73 --- core/java/android/os/VibrationEffect.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/VibrationEffect.java b/core/java/android/os/VibrationEffect.java index 62359eccec81a..91c69fb07f773 100644 --- a/core/java/android/os/VibrationEffect.java +++ b/core/java/android/os/VibrationEffect.java @@ -18,6 +18,7 @@ package android.os; import android.annotation.Nullable; import android.annotation.TestApi; +import android.content.ContentResolver; import android.content.Context; import android.hardware.vibrator.V1_0.EffectStrength; import android.hardware.vibrator.V1_2.Effect; @@ -277,7 +278,12 @@ public abstract class VibrationEffect implements Parcelable { if (uris[i] == null) { continue; } - if (Uri.parse(uris[i]).equals(uri)) { + ContentResolver cr = context.getContentResolver(); + Uri mappedUri = cr.uncanonicalize(Uri.parse(uris[i])); + if (mappedUri == null) { + continue; + } + if (mappedUri.equals(uri)) { return get(RINGTONES[i]); } }