From 7b373f10ced8cce4fbea3c8cc314f2aab1a6e9da Mon Sep 17 00:00:00 2001 From: Kristian Korsgaard Date: Fri, 25 Mar 2022 12:01:55 +0100 Subject: [PATCH] Revert "fix(android): Request external read permission when listing external directories (#487)" This reverts commit a56ab1eb890e4a6a7f0ff5aac42165593f1a5a4c. --- README.md | 4 +--- plugin.xml | 3 +++ src/android/FileUtils.java | 25 ++++--------------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 3bf3ebd9..ae47fa3a 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ the `cordova.file.*` properties map to physical paths on a real device. |    `cache` | cacheDirectory | cache | r/w | Yes | Yes\* | Yes | |    `files` | dataDirectory | files | r/w | Yes | No | Yes | |       `Documents` | | documents | r/w | Yes | No | Yes | -| `/` | externalRootDirectory | sdcard | r/w\*\*\* | Yes | No | No | +| `/` | externalRootDirectory | sdcard | r/w | Yes | No | No | |    `Android/data//` | externalApplicationStorageDirectory | - | r/w | Yes | No | No | |       `cache` | externalCacheDirectory | cache-external | r/w | Yes | No\*\*| No | |       `files` | externalDataDirectory | files-external | r/w | Yes | No | No | @@ -173,8 +173,6 @@ the `cordova.file.*` properties map to physical paths on a real device. the contents yourself. Should the user purge the cache manually, the contents of the directory are removed. -\*\*\* As of API 30, these directories are no longer writable. - **Note**: If external storage can't be mounted, the `cordova.file.external*` properties are `null`. diff --git a/plugin.xml b/plugin.xml index 0a2ee724..2eec461c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -132,6 +132,9 @@ to config.xml in order for the application to find previously stored files. + + + diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java index c2b1ca00..cd2a3383 100644 --- a/src/android/FileUtils.java +++ b/src/android/FileUtils.java @@ -88,7 +88,6 @@ public class FileUtils extends CordovaPlugin { public static final int ACTION_GET_FILE = 0; public static final int ACTION_WRITE = 1; public static final int ACTION_GET_DIRECTORY = 2; - public static final int ACTION_READ_ENTRIES = 3; public static final int WRITE = 3; public static final int READ = 4; @@ -286,7 +285,6 @@ public boolean execute(String action, final String rawArgs, final CallbackContex if (action.equals("testSaveLocationExists")) { threadhelper(new FileOp() { public void run(JSONArray args) { - boolean b = DirectoryManager.testSaveLocationExists(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, b)); } @@ -545,16 +543,10 @@ public void run(JSONArray args) throws JSONException, NoModificationAllowedExcep } else if (action.equals("readEntries")) { threadhelper( new FileOp( ){ - public void run(JSONArray args) throws FileNotFoundException, JSONException, MalformedURLException, IOException { - String directory = args.getString(0); - String nativeURL = resolveLocalFileSystemURI(directory).getString("nativeURL"); - if (needPermission(nativeURL, READ)) { - getReadPermission(rawArgs, ACTION_READ_ENTRIES, callbackContext); - } - else { - JSONArray entries = readEntries(directory); - callbackContext.success(entries); - } + public void run(JSONArray args) throws FileNotFoundException, JSONException, MalformedURLException { + String fname=args.getString(0); + JSONArray entries = readEntries(fname); + callbackContext.success(entries); } }, rawArgs, callbackContext); } @@ -1244,15 +1236,6 @@ public void run(JSONArray args) throws JSONException, FileNotFoundException, IOE } }, req.getRawArgs(), req.getCallbackContext()); break; - case ACTION_READ_ENTRIES: - threadhelper( new FileOp( ){ - public void run(JSONArray args) throws FileNotFoundException, JSONException, MalformedURLException { - String fname=args.getString(0); - JSONArray entries = readEntries(fname); - req.getCallbackContext().success(entries); - } - }, req.getRawArgs(), req.getCallbackContext()); - break; } } else { LOG.d(LOG_TAG, "Received permission callback for unknown request code");