Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch exceptions thrown by Context.registerReceiver to prevent rare crashes #1240

Merged
merged 1 commit into from
May 11, 2021

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented May 10, 2021

Goal

Catches exceptions thrown by Context.registerReceiver to prevent rare crashes.

Specifically this catches SecurityException, which might be thrown by the OS if it cannot verify that the package registering the receiver has permission to do so, DeadSystemException, which is thrown when the OS is about to restart, and IllegalArgumentException, which is thrown when the process UID does not match the caller ID.

Receivers are used to check network connectivity, collect device metadata, and listen to orientation changes, so the effect of catching these exceptions is that Bugsnag's behaviour may degrade in the rare case where registerReceiver() fails. However, this is seen as preferable to Bugsnag causing process termination.

Testing

Added unit tests to verify new methods catch exceptions appropriately.

@fractalwrench fractalwrench changed the title Catch exceptions thrown by registerReceiver to prevent rare crashes Catch exceptions thrown by Context.registerReceiver to prevent rare crashes May 10, 2021
@fractalwrench fractalwrench force-pushed the PLAT-6514/make-register-receiver-safe branch from 7fd9e25 to 9f2a0db Compare May 10, 2021 13:57
@fractalwrench fractalwrench requested a review from kstenerud May 10, 2021 14:01
@fractalwrench fractalwrench force-pushed the PLAT-6514/make-register-receiver-safe branch from 9f2a0db to b22381f Compare May 10, 2021 14:07
@fractalwrench fractalwrench marked this pull request as draft May 10, 2021 14:55
@fractalwrench fractalwrench removed the request for review from kstenerud May 10, 2021 14:55
@fractalwrench fractalwrench force-pushed the PLAT-6514/make-register-receiver-safe branch from b22381f to 6f5ee75 Compare May 10, 2021 14:57
@fractalwrench fractalwrench marked this pull request as ready for review May 10, 2021 14:58
@fractalwrench fractalwrench requested a review from kstenerud May 10, 2021 14:58
@fractalwrench fractalwrench merged commit 1f07ed3 into next May 11, 2021
@fractalwrench fractalwrench deleted the PLAT-6514/make-register-receiver-safe branch May 11, 2021 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants