diff --git a/CHANGELOG.md b/CHANGELOG.md index cb090a6b23..1f7d7e5096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/ANRWatchDog.java b/sentry-android-core/src/main/java/io/sentry/android/core/ANRWatchDog.java index 16211c1252..13fbebfd48 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/ANRWatchDog.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/ANRWatchDog.java @@ -106,8 +106,14 @@ public void run() { (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); if (am != null) { - final List processesInErrorState = - am.getProcessesInErrorState(); + List 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;