Skip to content

Why is the API 34+ importance-based app-start check not used below API 34? #8509

Description

@ankursamarya

Background

app_start being suppressed on API 34+ (#8103). The old timing-window heuristic was replaced on API 34+ by a RunningAppProcessInfo.importance read at first capture. The changelog says "Pre-API-34 behavior is unchanged."

So today there are two different signals:

  • Below 34StartFromBackgroundRunnable is posted to the main Looper from FirebasePerfEarly (FirebasePerfEarly.java:55). If it runs before the first onActivityCreated, the start is treated as background (AppStartTrace.java:350-356).
  • 34+ActivityManager.getMyMemoryState() importance is read once during registerActivityLifecycleCallbacks. Only IMPORTANCE_FOREGROUND allows the trace (AppStartTrace.java:360).

Question

ActivityManager.getMyMemoryState() has been available since API 16, and AppStartCause.readImportance() already runs on every API level (AppStartCause.java:79). Only the classification is gated:

if (apiLevel >= 34) {
    Cause cause = importance == IMPORTANCE_FOREGROUND
        ? Cause.FOREGROUND
        : Cause.UNKNOWN;
    return new AppStartCause(cause, importance, apiLevel);
}

// API < 34: legacy AppStartTrace logic owns the decision.
return new AppStartCause(Cause.UNKNOWN, importance, apiLevel);

What specifically blocks using the importance signal below API 34?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions