Skip to content

Commit

Permalink
Merge pull request #92709 from m4gr3d/fix_request_permissions_return_…
Browse files Browse the repository at this point in the history
…value

Fix invalid return value when multiple permission requests are dispatched
  • Loading branch information
akien-mga committed Jun 3, 2024
2 parents f976a62 + 53279d2 commit 7118487
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static boolean requestPermissions(Activity activity, List<String> permiss
}

activity.requestPermissions(requestedPermissions.toArray(new String[0]), REQUEST_ALL_PERMISSION_REQ_CODE);
return true;
return false;
}

/**
Expand Down Expand Up @@ -281,8 +281,9 @@ public static String[] getGrantedPermissions(Context context) {
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) {
}
Expand All @@ -299,8 +300,9 @@ public static boolean hasManifestPermission(Context context, String permission)
public static ArrayList<String> 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<String>();
if (packageInfo.requestedPermissions == null) {
return new ArrayList<>();
}
return new ArrayList<>(Arrays.asList(packageInfo.requestedPermissions));
}

Expand Down

0 comments on commit 7118487

Please sign in to comment.