Fix CloudDB image fetching for Android 11+
+// -*- mode: java; c-basic-offset: 2; -*-
+// Copyright 2021-2022 MIT, All rights reserved
+// Released under the Apache License, Version 2.0
+// http://www.apache.org/licenses/LICENSE-2.0
+
package com.google.appinventor.components.runtime.util;
import android.os.Build;
@@ -22,13 +27,13 @@ public class RUtil {
if (!path.startsWith("/") && !path.startsWith("file:")) {
return false;
}
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
+ String fpath = path;
if (path.startsWith("file:")) {
- path = path.substring(5);
+ fpath = path.substring(5);
}
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
- return path.startsWith(Environment.getExternalStorageDirectory().getAbsolutePath());
+ return fpath.startsWith(Environment.getExternalStorageDirectory().getAbsolutePath());
}
- path = "file:" + path;
return FileUtil.isExternalStorageUri(form, path)
&& !FileUtil.isAppSpecificExternalUri(form, path);
}
