Skip to content

Commit

Permalink
Treat more files like drive files to handle API 30
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjdev authored Sep 10, 2021
1 parent eea13f1 commit a471420
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/android/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,16 @@ public void resolveNativePath() throws JSONException {
Log.d(TAG, "URI: " + this.uriStr);

Context appContext = this.cordova.getActivity().getApplicationContext();
String filePath = getPath(appContext, pvUrl);

String filePath;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// Seems like once you target API level 30, you can't access files you should have
// access to. So then always run this getDriveFilePath which will use
// getContentResolver().openInputStream(uri) to read it
filePath = getDriveFilePath(pvUrl, appContext);
} else {
filePath = getPath(appContext, pvUrl);
}

//check result; send error/success callback
if (filePath == GET_PATH_ERROR_ID) {
resultObj.put("code", GET_PATH_ERROR_CODE);
Expand Down

0 comments on commit a471420

Please sign in to comment.