Skip to content

Commit

Permalink
Swallow error when reading ActivityManager#getProcessesInErrorState i…
Browse files Browse the repository at this point in the history
…nstead of crashing (#2114)
  • Loading branch information
marandaneto authored Jun 20, 2022
1 parent 6f77e2e commit b571aae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Swallow error when reading ActivityManager#getProcessesInErrorState instead of crashing ([#2114](https://github.com/getsentry/sentry-java/pull/2114))
- Use charset string directly as StandardCharsets is not available on earlier Android versions ([#2111](https://github.com/getsentry/sentry-java/pull/2111))

## 6.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ public void run() {
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

if (am != null) {
final List<ActivityManager.ProcessErrorStateInfo> processesInErrorState =
am.getProcessesInErrorState();
List<ActivityManager.ProcessErrorStateInfo> processesInErrorState = null;
try {
// It can throw RuntimeException or OutOfMemoryError
processesInErrorState = am.getProcessesInErrorState();
} catch (Throwable e) {
logger.log(
SentryLevel.ERROR, "Error getting ActivityManager#getProcessesInErrorState.", e);
}
// if list is null, there's no process in ANR state.
if (processesInErrorState == null) {
continue;
Expand Down

0 comments on commit b571aae

Please sign in to comment.