Use UriUtil when checking if a URI is a file.

UriUtil.isFileUri contains several additional fixes, so this ensure that existing instances where we check for the file scheme use this method as well. This covers all existing instances in the app of SCHEME_FILE.

Change-Id: I1f3131b33823eae3e620aa9608be8e72b2e84aa2
Bug: 215212561
This commit is contained in:
Jake Klinker
2022-01-31 20:29:42 +00:00
parent a0332cba4f
commit ebc64c5bae
3 changed files with 4 additions and 8 deletions
+1 -5
View File
@@ -117,15 +117,11 @@ public class FileUtil {
}
}
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());
@@ -480,7 +480,7 @@ public class ImageUtils {
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();