From a4714209cfbd2bd8eebad902b8f5ef3e34fb8baa Mon Sep 17 00:00:00 2001 From: Chris J Date: Fri, 10 Sep 2021 10:47:28 -0400 Subject: [PATCH] Treat more files like drive files to handle API 30 --- src/android/FilePath.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/android/FilePath.java b/src/android/FilePath.java index d58a22c..612075a 100644 --- a/src/android/FilePath.java +++ b/src/android/FilePath.java @@ -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);