From 038ae4cb437ff8cf7dc1f3f668edec5f4ab27379 Mon Sep 17 00:00:00 2001 From: Manuel Beck Date: Mon, 27 Oct 2025 09:19:02 +0100 Subject: [PATCH] Call new method `CordovaPlugin.onRequestPermissionsResult` - Fixes https://github.com/apache/cordova-android/issues/1388 - `CordovaInterfaceImpl` called the deprecated method `CordovaPlugin.onRequestPermissionResult` but not the new one. Now the one will also be called. - Renamed `CordovaInterfaceImpl.onRequestPermissionResult` to `CordovaInterfaceImpl.onRequestPermissionsResult` to reflect the new method name --- framework/src/org/apache/cordova/CordovaActivity.java | 2 +- framework/src/org/apache/cordova/CordovaInterfaceImpl.java | 6 +++++- .../apache/cordova/unittests/EmbeddedWebViewActivity.java | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 50d6b3232..b9422034e 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -528,7 +528,7 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], try { - cordovaInterface.onRequestPermissionResult(requestCode, permissions, grantResults); + cordovaInterface.onRequestPermissionsResult(requestCode, permissions, grantResults); } catch (JSONException e) { diff --git a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java index 068c43697..8de98b85f 100644 --- a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java +++ b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java @@ -217,11 +217,15 @@ public ActivityResultHolder(int requestCode, int resultCode, Intent intent) { * @param permissions * @param grantResults */ - public void onRequestPermissionResult(int requestCode, String[] permissions, + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) throws JSONException { Pair callback = permissionResultCallbacks.getAndRemoveCallback(requestCode); if(callback != null) { + // This one is deprecated - see https://github.com/apache/cordova-android/issues/592 + // and should be removed in a future release callback.first.onRequestPermissionResult(callback.second, permissions, grantResults); + // Call the new method + callback.first.onRequestPermissionsResult(callback.second, permissions, grantResults); } } diff --git a/test/androidx/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java b/test/androidx/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java index 92cc74f2d..19b1039dc 100644 --- a/test/androidx/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java +++ b/test/androidx/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java @@ -87,7 +87,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent) * Called by the system when the user grants permissions! * * Note: The fragment gets priority over the activity, since the activity doesn't call - * into the parent onRequestPermissionResult, which is why there's no override. + * into the parent onRequestPermissionsResult, which is why there's no override. * * @param requestCode * @param permissions @@ -98,7 +98,7 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { try { - cordovaInterface.onRequestPermissionResult(requestCode, permissions, grantResults); + cordovaInterface.onRequestPermissionsResult(requestCode, permissions, grantResults); } catch (JSONException e) {