From 66c1d726f66d8e7f26cefcdbd4ff28c39649308b Mon Sep 17 00:00:00 2001 From: yuoohama Date: Wed, 19 Jul 2023 10:34:59 +0900 Subject: [PATCH] Return false when request code invalid --- android/src/main/java/studio/midoridesign/gal/GalPlugin.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/studio/midoridesign/gal/GalPlugin.java b/android/src/main/java/studio/midoridesign/gal/GalPlugin.java index 48c0816a..fdc32877 100644 --- a/android/src/main/java/studio/midoridesign/gal/GalPlugin.java +++ b/android/src/main/java/studio/midoridesign/gal/GalPlugin.java @@ -208,8 +208,11 @@ public void onDetachedFromActivityForConfigChanges() { @Override public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + if (requestCode != PERMISSION_REQUEST_CODE || grantResults.length == 0) { + return false; + } accessRequestResult.complete( - grantResults[0] == PackageManager.PERMISSION_GRANTED && PERMISSION_REQUEST_CODE == requestCode); + grantResults[0] == PackageManager.PERMISSION_GRANTED); return true; }