From 53279d25103ae922de23a563ce3a3ea42d3b7e98 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Sun, 2 Jun 2024 17:22:51 -0700 Subject: [PATCH] Fix invalid return value when multiple permission requests are dispatched --- .../org/godotengine/godot/utils/PermissionsUtil.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java b/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java index 9df890e6bda..4e8e82a70a7 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java +++ b/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java @@ -125,7 +125,7 @@ public final class PermissionsUtil { } activity.requestPermissions(requestedPermissions.toArray(new String[0]), REQUEST_ALL_PERMISSION_REQ_CODE); - return true; + return false; } /** @@ -281,8 +281,9 @@ public final class PermissionsUtil { public static boolean hasManifestPermission(Context context, String permission) { try { for (String p : getManifestPermissions(context)) { - if (permission.equals(p)) + if (permission.equals(p)) { return true; + } } } catch (PackageManager.NameNotFoundException ignored) { } @@ -299,8 +300,9 @@ public final class PermissionsUtil { public static ArrayList getManifestPermissions(Context context) throws PackageManager.NameNotFoundException { PackageManager packageManager = context.getPackageManager(); PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS); - if (packageInfo.requestedPermissions == null) - return new ArrayList(); + if (packageInfo.requestedPermissions == null) { + return new ArrayList<>(); + } return new ArrayList<>(Arrays.asList(packageInfo.requestedPermissions)); }