Skip to content

Commit

Permalink
Include permission name in exception message. (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech authored Dec 30, 2024
1 parent 5c2404f commit cdff5da
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,21 @@ void onRequestPermissionsResult(@NonNull final int[] grantResults, @NonNull fina
final int size = permissions.length;

for (int i = 0; i < size; i++) {
final PublishSubject<Permission> subject = currentPermissionRequests.get(permissions[i]);
final String permission = permissions[i];
final PublishSubject<Permission> subject = currentPermissionRequests.remove(permission);

if (subject == null) {
throw new IllegalStateException("RealRxPermission.onRequestPermissionsResult invoked but didn't find the corresponding permission request.");
throw new IllegalStateException("RealRxPermission.onRequestPermissionsResult invoked but didn't find the corresponding permission request for " + permission);
}

currentPermissionRequests.remove(permissions[i]);

final boolean granted = grantResults[i] == PERMISSION_GRANTED;

if (granted) {
subject.onNext(Permission.granted(permissions[i]));
subject.onNext(Permission.granted(permission));
} else if (!rationale[i] && !rationaleAfter[i]) {
subject.onNext(Permission.deniedNotShown(permissions[i]));
subject.onNext(Permission.deniedNotShown(permission));
} else {
subject.onNext(Permission.denied(permissions[i]));
subject.onNext(Permission.denied(permission));
}

subject.onComplete();
Expand Down

0 comments on commit cdff5da

Please sign in to comment.