Commit aa3bf82b authored by Evan W. Patton's avatar Evan W. Patton Committed by Susan Rati Lane

Allow loading media from private directory without file: scheme

Change-Id: I49edca7a3026328b6fb88f21d21ff5fe729738e3
parent a699e8cf
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2020 MIT, All rights reserved
// Copyright 2011-2023 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
......@@ -28,7 +28,6 @@ import android.view.Display;
import android.view.WindowManager;
import android.widget.VideoView;
import com.google.appinventor.components.common.FileScope;
import com.google.appinventor.components.runtime.Form;
import com.google.appinventor.components.runtime.ReplForm;
import com.google.appinventor.components.runtime.errors.PermissionException;
......@@ -56,7 +55,16 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class MediaUtil {
private enum MediaSource { ASSET, REPL_ASSET, SDCARD, FILE_URL, URL, CONTENT_URI, CONTACT_URI }
private enum MediaSource {
ASSET,
REPL_ASSET,
SDCARD,
FILE_URL,
URL,
CONTENT_URI,
CONTACT_URI,
PRIVATE_DATA
}
private static final String LOG_TAG = "MediaUtil";
......@@ -107,6 +115,8 @@ public class MediaUtil {
} else if (mediaPath.startsWith("content://")) {
return MediaSource.CONTENT_URI;
} else if (mediaPath.startsWith("/data/")) {
return MediaSource.PRIVATE_DATA;
}
try {
......@@ -274,6 +284,9 @@ public class MediaUtil {
}
return getAssetsIgnoreCaseInputStream(form, mediaPath);
case PRIVATE_DATA:
return new FileInputStream(mediaPath);
case REPL_ASSET:
if (RUtil.needsFilePermission(form, mediaPath, null)) {
// App specific storage does not need read permission
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment