Skip to content

Commit

Permalink
fix(android): Filesystem.requestPermissions() not working (#2936)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored May 15, 2020
1 parent a9d4698 commit 2a9a95d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public class PluginRequestCodes {
public static final int FILESYSTEM_REQUEST_STAT_PERMISSIONS = 9019;
public static final int FILESYSTEM_REQUEST_RENAME_PERMISSIONS = 9020;
public static final int FILESYSTEM_REQUEST_COPY_PERMISSIONS = 9021;
public static final int FILESYSTEM_REQUEST_ALL_PERMISSIONS = 9022;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,25 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

@NativePlugin(requestCodes = {
PluginRequestCodes.FILESYSTEM_REQUEST_WRITE_FILE_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_WRITE_FOLDER_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_READ_FILE_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_READ_FOLDER_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_DELETE_FILE_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_DELETE_FOLDER_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_URI_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_STAT_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_RENAME_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_COPY_PERMISSIONS,
})
@NativePlugin(
requestCodes = {
PluginRequestCodes.FILESYSTEM_REQUEST_WRITE_FILE_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_WRITE_FOLDER_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_READ_FILE_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_READ_FOLDER_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_DELETE_FILE_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_DELETE_FOLDER_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_URI_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_STAT_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_RENAME_PERMISSIONS,
PluginRequestCodes.FILESYSTEM_REQUEST_COPY_PERMISSIONS,
},
permissions={
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
},
permissionRequestCode = PluginRequestCodes.FILESYSTEM_REQUEST_ALL_PERMISSIONS
)
public class Filesystem extends Plugin {

private static final String PERMISSION_DENIED_ERROR = "Unable to do file operation, user denied permission request";
Expand Down Expand Up @@ -676,6 +683,8 @@ protected void handleRequestPermissionsResult(int requestCode, String[] permissi
this.rename(savedCall);
} else if (requestCode == PluginRequestCodes.FILESYSTEM_REQUEST_COPY_PERMISSIONS) {
this.copy(savedCall);
} else if (requestCode == PluginRequestCodes.FILESYSTEM_REQUEST_ALL_PERMISSIONS){
savedCall.resolve();
}
this.freeSavedCall();
}
Expand Down

0 comments on commit 2a9a95d

Please sign in to comment.