From 38bde4bce5ca38aea621a4259d990d872f695334 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 9 Feb 2021 20:00:06 +0100 Subject: [PATCH] fix(android): Reject on permission prompt cancelation --- .../src/main/java/com/getcapacitor/plugin/Filesystem.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java index 18e62b67e..b133ec2d0 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java @@ -654,6 +654,13 @@ protected void handleRequestPermissionsResult(int requestCode, String[] permissi PluginCall savedCall = getSavedCall(); + if (grantResults.length == 0) { + Logger.debug(getLogTag(), "Permission prompt was canceled."); + savedCall.error(PERMISSION_DENIED_ERROR); + this.freeSavedCall(); + return; + } + for (int i = 0; i < grantResults.length; i++) { int result = grantResults[i]; String perm = permissions[i];