[automerger skipped] Merge Android 12L am: e9d328d6a6 -s ours am: 184899bbeb -s ours

am skip reason: Merged-In I0f76e316e9e7f504b92e157799074e4c5606adbf with SHA-1 e6b2cd3620 is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Messaging/+/2013097

Change-Id: Ie75fb77cf964d5462299062dda15acd5c6df5ddf
diff --git a/src/com/android/messaging/mmslib/pdu/PduPersister.java b/src/com/android/messaging/mmslib/pdu/PduPersister.java
index 6615d30..436867a 100644
--- a/src/com/android/messaging/mmslib/pdu/PduPersister.java
+++ b/src/com/android/messaging/mmslib/pdu/PduPersister.java
@@ -52,6 +52,7 @@
 import com.android.messaging.util.ContentType;
 import com.android.messaging.util.LogUtil;
 import com.android.messaging.util.OsUtil;
+import com.android.messaging.util.UriUtil;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -1018,8 +1019,7 @@
         String path = null;
         if (null != uri) {
             final String scheme = uri.getScheme();
-            if (null == scheme || scheme.equals("") ||
-                    scheme.equals(ContentResolver.SCHEME_FILE)) {
+            if (null == scheme || scheme.equals("") || UriUtil.isFileUri(uri)) {
                 path = uri.getPath();
 
             } else if (scheme.equals("http")) {
diff --git a/src/com/android/messaging/util/FileUtil.java b/src/com/android/messaging/util/FileUtil.java
index 7d59aa7..71fbb4b 100644
--- a/src/com/android/messaging/util/FileUtil.java
+++ b/src/com/android/messaging/util/FileUtil.java
@@ -117,15 +117,11 @@
         }
     }
 
-    private static boolean isFileUri(final Uri uri) {
-        return TextUtils.equals(uri.getScheme(), ContentResolver.SCHEME_FILE);
-    }
-
     // Checks if the file is in /data, and don't allow any app to send personal information.
     // We're told it's possible to create world readable hardlinks to other apps private data
     // so we ban all /data file uris.
     public static boolean isInPrivateDir(Uri uri) {
-        if (!isFileUri(uri)) {
+        if (!UriUtil.isFileUri(uri)) {
             return false;
         }
         final File file = new File(uri.getPath());
diff --git a/src/com/android/messaging/util/ImageUtils.java b/src/com/android/messaging/util/ImageUtils.java
index a228417..e541d69 100644
--- a/src/com/android/messaging/util/ImageUtils.java
+++ b/src/com/android/messaging/util/ImageUtils.java
@@ -480,7 +480,7 @@
             if (MediaScratchFileProvider.isMediaScratchSpaceUri(mUri)) {
                 inputFilePath = MediaScratchFileProvider.getFileFromUri(mUri).getAbsolutePath();
             } else {
-                if (!TextUtils.equals(mUri.getScheme(), ContentResolver.SCHEME_FILE)) {
+                if (!UriUtil.isFileUri(mUri)) {
                     Assert.fail("Expected a GIF file uri, but actual uri = " + mUri.toString());
                 }
                 inputFilePath = mUri.getPath();