Skip to content

Commit

Permalink
Behavior change: Do not crash if the corresponding permission request…
Browse files Browse the repository at this point in the history
… can not be found. Instead we no-op. (#271)
  • Loading branch information
vanniktech authored Jan 17, 2025
1 parent 7d1fead commit b655e76
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,19 @@ void onRequestPermissionsResult(@NonNull final int[] grantResults, @NonNull fina
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 for " + permission);
}

final boolean granted = grantResults[i] == PERMISSION_GRANTED;
if (subject != null) {
final boolean granted = grantResults[i] == PERMISSION_GRANTED;

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

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

subject.onComplete();
}
}

Expand Down

0 comments on commit b655e76

Please sign in to comment.