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

Avoid reporting false-positive background ANRs #1429

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## TBD

### Bug fixes

* Avoid reporting false-positive background ANRs with improved foreground detection
[#1429](https://github.com/bugsnag/bugsnag-android/pull/1429)

## 5.14.0 (2021-09-29)

### Enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

class ForegroundDetector {

private static final int IMPORTANCE_FOREGROUND_SERVICE = 125;

@Nullable
private final ActivityManager activityManager;

Expand All @@ -36,8 +38,7 @@ Boolean isInForeground() {
ActivityManager.RunningAppProcessInfo info = getProcessInfo();

if (info != null) {
return info.importance
<= ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
return info.importance <= IMPORTANCE_FOREGROUND_SERVICE;
} else {
return null;
}
Expand Down