diff options
| author | 2017-04-26 15:14:26 +0100 | |
|---|---|---|
| committer | 2017-04-27 13:31:09 +0100 | |
| commit | a22d9fbe8c1cf3cb47db0bfecbd4fd84c59b6ec0 (patch) | |
| tree | dcf548d6c4f31d39486a29a6f807db13dbef1a45 | |
| parent | fc513f98d7086605e9b3499d90a88d3b4592c2b6 (diff) | |
AppErrors: Refine notion of "interesting" processes for b/g ANRs.
- SystemUI is always interesting, regardless of whether it's currently
  displaying any interesting activities or not.
- Any process that hasOverlayUI or hasTopUI is considered interesting.
- Any process that hosts an active foreground service is considered
  interesting.
Bug: 36383925
Test: manual
Change-Id: I852a00344f913200020c4f80500e38ff101fe05d
| -rw-r--r-- | services/core/java/com/android/server/am/AppErrors.java | 22 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ProcessRecord.java | 8 | 
2 files changed, 29 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java index ba72dcf23c98..d6bfb35b1935 100644 --- a/services/core/java/com/android/server/am/AppErrors.java +++ b/services/core/java/com/android/server/am/AppErrors.java @@ -751,6 +751,26 @@ class AppErrors {          mAppsNotReportingCrashes.add(proc.info.packageName);      } +    static boolean isInterestingForBackgroundTraces(ProcessRecord app) { +        // The system_server is always considered interesting. +        if (app.pid == MY_PID) { +            return true; +        } + +        // A package is considered interesting if any of the following is true : +        // +        // - It's displaying an activity. +        // - It's the SystemUI. +        // - It has an overlay or a top UI visible. +        // +        // NOTE: The check whether a given ProcessRecord belongs to the systemui +        // process is a bit of a kludge, but the same pattern seems repeated at +        // several places in the system server. +        return app.isInterestingToUserLocked() || +            (app.info != null && "com.android.systemui".equals(app.info.packageName)) || +            (app.hasTopUi || app.hasOverlayUi); +    } +      final void appNotResponding(ProcessRecord app, ActivityRecord activity,              ActivityRecord parent, boolean aboveSystem, final String annotation) {          ArrayList<Integer> firstPids = new ArrayList<Integer>(5); @@ -812,7 +832,7 @@ class AppErrors {              firstPids.add(app.pid);              // Don't dump other PIDs if it's a background ANR -            isSilentANR = !showBackground && !app.isInterestingToUserLocked() && app.pid != MY_PID; +            isSilentANR = !showBackground && !isInterestingForBackgroundTraces(app);              if (!isSilentANR) {                  int parentPid = app.pid;                  if (parent != null && parent.app != null && parent.app.pid > 0) { diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java index 3c5c5fd0cfe4..b025385413ea 100644 --- a/services/core/java/com/android/server/am/ProcessRecord.java +++ b/services/core/java/com/android/server/am/ProcessRecord.java @@ -520,6 +520,14 @@ final class ProcessRecord {                  return true;              }          } + +        final int servicesSize = services.size(); +        for (int i = 0; i < servicesSize; i++) { +            ServiceRecord r = services.valueAt(i); +            if (r.isForeground) { +                return true; +            } +        }          return false;      }  |