apache / apache/cordova-plugin-file
When using an external SD Card in Android 15, there will be problems listing files in the directory
- Dominant language
- JavaScript
- Stars
- 744
- Forks
- 754
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 1
Description
# Bug Report
## Problem
The following code will cause an error in Android 15 when using an external SD Card
```javascript
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function()
{
window.resolveLocalFileSystemURL("file:///storage/0000-0000/Android/data/xxx.xxx.xxx.xxx/files",function(d)
{
d.createReader().readEntries(function(ok)
{
console.log("ok");
},function(err)
{
console.log("err");
});
},errfunc);
},errfunc);
```
I modified FileUtils.java in the source code as shown below. After adding annotations, the program can run normally. However, this modification method is not ideal.
```javascript
} 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);
// }
}
}, rawArgs, callbackContext);
```
Contributor guide
Research direction
Start in FileUtils.java at the readEntries action and reproduce the supplied requestFileSystem/resolveLocalFileSystemURL flow on Android 15 with an external SD card. Trace the permission handling around readEntries and compare it with the shown workaround; done means the directory lists successfully without disabling those checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, javascript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100