diff --git a/README.md b/README.md index e5162180..e7e10f81 100644 --- a/README.md +++ b/README.md @@ -3535,7 +3535,7 @@ Checks if the application is authorized to use external storage. Notes for Android: - This is intended for Android 6 / API 23 and above. Calling on Android 5.1 / API 22 and below will always return TRUE as permissions are already granted at installation time. -- This checks for `READ_EXTERNAL_STORAGE` `CAMERA` run-time permission. +- This checks for `READ_EXTERNAL_STORAGE` run-time permission. ``` cordova.plugins.diagnostic.isExternalStorageAuthorized(successCallback, errorCallback); @@ -3653,8 +3653,6 @@ Whereas this method returns: which are on external removable storage. -- Requires permission for `READ_EXTERNAL_STORAGE` run-time permission which must be added to `AndroidManifest.xml`. - ``` cordova.plugins.diagnostic.getExternalSdCardDetails(successCallback, errorCallback); ``` @@ -3669,7 +3667,7 @@ Each array entry is an object with the following keys: - {String} path - absolute path to the storage location - {String} filePath - absolute path prefixed with file protocol for use with cordova-plugin-file - {Boolean} canWrite - true if the location is writable - - {Integer} freeSpace - number of bytes of free space on the device on which the storage locaiton is mounted. + - {Integer} freeSpace - number of bytes of free space on the device on which the storage location is mounted. - {String} type - indicates the type of storage location: either "application" if the path is an Android application sandbox path or "root" if the path is the device root. - {Function} errorCallback - The callback which will be called when operation encounters an error. The function is passed a single string parameter containing the error message. diff --git a/src/android/Diagnostic.java b/src/android/Diagnostic.java index efba17b1..88f58c9d 100644 --- a/src/android/Diagnostic.java +++ b/src/android/Diagnostic.java @@ -184,9 +184,6 @@ public class Diagnostic extends CordovaPlugin{ public static final String CPU_ARCH_MIPS = "MIPS"; public static final String CPU_ARCH_MIPS_64 = "MIPS_64"; - protected static final String externalStorageClassName = "cordova.plugins.Diagnostic_External_Storage"; - protected static final Integer GET_EXTERNAL_SD_CARD_DETAILS_PERMISSION_REQUEST = 1000; - /************* * Variables * *************/ @@ -965,17 +962,7 @@ public void onRequestPermissionResult(int requestCode, String[] permissions, int clearRequest(requestCode); } - Class externalStorageClass = null; - try { - externalStorageClass = Class.forName(externalStorageClassName); - } catch( ClassNotFoundException e ){} - - if(requestCode == GET_EXTERNAL_SD_CARD_DETAILS_PERMISSION_REQUEST && externalStorageClass != null){ - Method method = externalStorageClass.getMethod("onReceivePermissionResult"); - method.invoke(null); - }else{ - context.success(statuses); - } + context.success(statuses); }catch(Exception e ) { handleError("Exception occurred onRequestPermissionsResult: ".concat(e.getMessage()), requestCode); } diff --git a/src/android/Diagnostic_External_Storage.java b/src/android/Diagnostic_External_Storage.java index a9d10c5e..f456d423 100644 --- a/src/android/Diagnostic_External_Storage.java +++ b/src/android/Diagnostic_External_Storage.java @@ -51,7 +51,6 @@ public class Diagnostic_External_Storage extends CordovaPlugin{ * Constants * *************/ - /** * Tag for debug log messages */ @@ -74,8 +73,6 @@ public class Diagnostic_External_Storage extends CordovaPlugin{ */ protected CallbackContext currentContext; - protected static String externalStoragePermission = "READ_EXTERNAL_STORAGE"; - /************* * Public API @@ -127,29 +124,12 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo return true; } - public static void onReceivePermissionResult() throws JSONException{ - instance._getExternalSdCardDetails(); - } /************ * Internals ***********/ - protected void getExternalSdCardDetails() throws Exception{ - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - _getExternalSdCardDetails(); - } else { - String permission = diagnostic.permissionsMap.get(externalStoragePermission); - if (diagnostic.hasRuntimePermission(permission)) { - _getExternalSdCardDetails(); - } else { - diagnostic.requestRuntimePermission(permission, Diagnostic.GET_EXTERNAL_SD_CARD_DETAILS_PERMISSION_REQUEST); - } - } - } - - - protected void _getExternalSdCardDetails() throws JSONException { + protected void getExternalSdCardDetails() throws JSONException { String[] storageDirectories = getStorageDirectories(); JSONArray details = new JSONArray();