Android: Only check for uri permissions when it is a file or content

This amends f36b042e2b to only check
permissions for uris that are going to be local to the device itself.
Other uris, such as http, https etc, should go through fine without a
check.

Change-Id: If05caadb6e0712d9db8f57185ef017d724d9e172
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
bb10
Andy Shaw 2020-03-04 13:36:27 +01:00
parent 504b37e399
commit e7eff98401
1 changed files with 6 additions and 1 deletions

View File

@ -160,8 +160,13 @@ public class QtNative
private static Uri getUriWithValidPermission(Context context, String uri, String openMode)
{
try {
Uri parsedUri = Uri.parse(uri);
String scheme = parsedUri.getScheme();
// We only want to check permissions for files and content Uris
if (scheme.compareTo("file") != 0 && scheme.compareTo("content") != 0)
return parsedUri;
List<UriPermission> permissions = context.getContentResolver().getPersistedUriPermissions();
String uriStr = Uri.parse(uri).getPath();
String uriStr = parsedUri.getPath();
for (int i = 0; i < permissions.size(); ++i) {
Uri iterUri = permissions.get(i).getUri();