Skip to content

Commit

Permalink
fix(android): hasWritePermission for SDK 33 (#608)
Browse files Browse the repository at this point in the history
Co-authored-by: EYALIN <[email protected]>
  • Loading branch information
erisu and EYALIN authored Oct 17, 2023
1 parent c5bcbdf commit c10942a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/android/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,10 @@ private void getReadPermission(String rawArgs, int action, CallbackContext callb
}

private void getWritePermission(String rawArgs, int action, CallbackContext callbackContext) {
int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext);
PermissionHelper.requestPermission(this, requestCode, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext);
PermissionHelper.requestPermission(this, requestCode, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
}

/**
Expand All @@ -567,7 +569,10 @@ private boolean hasReadPermission() {
}

private boolean hasWritePermission() {
return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
// Starting with API 33, requesting WRITE_EXTERNAL_STORAGE is an auto permission rejection
return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
? true
: PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}

private boolean needPermission(String nativeURL, int permissionType) throws JSONException {
Expand Down

0 comments on commit c10942a

Please sign in to comment.