Skip to content

Commit

Permalink
Revert "fix(android): Request external read permission when listing e…
Browse files Browse the repository at this point in the history
…xternal directories (apache#487)"

This reverts commit a56ab1e.
  • Loading branch information
tmrkk committed Mar 25, 2022
1 parent a56ab1e commit 7b373f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| `<sdcard>/` | externalRootDirectory | sdcard | r/w\*\*\* | Yes | No | No |
| `<sdcard>/` | externalRootDirectory | sdcard | r/w | Yes | No | No |
| &nbsp;&nbsp;&nbsp;`Android/data/<app-id>/` | externalApplicationStorageDirectory | - | r/w | Yes | No | No |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`cache` | externalCacheDirectory | cache-external | r/w | Yes | No\*\*| No |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`files` | externalDataDirectory | files-external | r/w | Yes | No | No |
Expand All @@ -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`.

Expand Down
3 changes: 3 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ to config.xml in order for the application to find previously stored files.
</feature>
<allow-navigation href="cdvfile:*" />
</config-file>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:requestLegacyExternalStorage="true" />
</edit-config>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</config-file>
Expand Down
25 changes: 4 additions & 21 deletions src/android/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 7b373f1

Please sign in to comment.