Skip to content

Commit

Permalink
Catch NullPointerException for onRequestPermissionsResult (#39715)
Browse files Browse the repository at this point in the history
Summary:
On Android 13 Devices, we are seeing `NullPointerException`, which should be handled with this

## Changelog:

[ANDROID] [FIXED] - Handle Crash for onRequestPermissionsResult

Pull Request resolved: #39715

Reviewed By: NickGerleman

Differential Revision: D49965583

Pulled By: javache

fbshipit-source-id: 8a39049675510f9cca8141c893d93fdb04ba0e25
  • Loading branch information
chakrihacker authored and facebook-github-bot committed Oct 6, 2023
1 parent 6355703 commit 9252099
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ public void invoke(Object... args) {
public boolean onRequestPermissionsResult(
int requestCode, String[] permissions, int[] grantResults) {
try {
mCallbacks.get(requestCode).invoke(grantResults, getPermissionAwareActivity());
mCallbacks.remove(requestCode);
Callback callback = mCallbacks.get(requestCode);
if (callback != null) {
callback.invoke(grantResults, getPermissionAwareActivity());
mCallbacks.remove(requestCode);
} else {
FLog.w("PermissionsModule", "Unable to find callback with requestCode %d", requestCode);
}
return mCallbacks.size() == 0;
} catch (IllegalStateException e) {
FLog.e(
Expand Down

0 comments on commit 9252099

Please sign in to comment.