Skip to content

Commit b571aae

Browse files
authored
Swallow error when reading ActivityManager#getProcessesInErrorState instead of crashing (#2114)
1 parent 6f77e2e commit b571aae

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Fixes
66

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

910
## 6.1.1

sentry-android-core/src/main/java/io/sentry/android/core/ANRWatchDog.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ public void run() {
106106
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
107107

108108
if (am != null) {
109-
final List<ActivityManager.ProcessErrorStateInfo> processesInErrorState =
110-
am.getProcessesInErrorState();
109+
List<ActivityManager.ProcessErrorStateInfo> processesInErrorState = null;
110+
try {
111+
// It can throw RuntimeException or OutOfMemoryError
112+
processesInErrorState = am.getProcessesInErrorState();
113+
} catch (Throwable e) {
114+
logger.log(
115+
SentryLevel.ERROR, "Error getting ActivityManager#getProcessesInErrorState.", e);
116+
}
111117
// if list is null, there's no process in ANR state.
112118
if (processesInErrorState == null) {
113119
continue;

0 commit comments

Comments
 (0)