Added in API level 36

ProfilingTrigger


class ProfilingTrigger
kotlin.Any
   ↳ android.os.ProfilingTrigger

Encapsulates a single profiling trigger.

Summary

Nested classes

Builder class to create a ProfilingTrigger object.

Constants
static Int

Trigger occurs after an ANR has been identified, but before the system would attempt to kill the app.

static Int

Trigger occurs after android.app.Activity#reportFullyDrawn is called for a cold start.

static Int

Trigger occurs when an app requests the actively running trace by calling ProfilingManager.requestRunningSystemTrace.

static Int

Trigger occurs as early as possible when an app cold starts.

static Int

Trigger occurs when an app is killed due to excessive CPU usage with an android.app.ApplicationExitInfo#getReason of android.app.ApplicationExitInfo#REASON_EXCESSIVE_RESOURCE_USAGE.

static Int

Trigger occurs when an app is killed due to the user clicking the "Force stop" button of the App info page in Settings.

static Int

Trigger occurs when an app is killed due to the user removing it in the Recents screen.

static Int

Trigger occurs when an app is killed due to the user clicking the "Stop" button for the application in Task Manager.

static Int

No trigger.

static Int

Trigger occurs when an app has an Out Of Memory Exception.

Public methods
Int

The requester set rate limiting period in hours.

Int

The trigger type indicates which event should trigger the requested profiling.

Constants

TRIGGER_TYPE_ANR

Added in API level 36
static val TRIGGER_TYPE_ANR: Int

Trigger occurs after an ANR has been identified, but before the system would attempt to kill the app. The trigger does not necessarily indicate that the app was killed due to the ANR.

System will provide a snapshot of a running system trace in response to this trigger.

Value: 2

TRIGGER_TYPE_APP_FULLY_DRAWN

Added in API level 36
static val TRIGGER_TYPE_APP_FULLY_DRAWN: Int

Trigger occurs after android.app.Activity#reportFullyDrawn is called for a cold start.

System will provide a snapshot of a running system trace in response to this trigger.

Value: 1

TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE

static val TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE: Int

Trigger occurs when an app requests the actively running trace by calling ProfilingManager.requestRunningSystemTrace.

System will provide a snapshot of a running system trace in response to this trigger.

Value: 3

TRIGGER_TYPE_COLD_START

Added in API level 36
static val TRIGGER_TYPE_COLD_START: Int

Trigger occurs as early as possible when an app cold starts.

This happens when the android.app.ApplicationStartInfo#getStartType start type is android.app.ApplicationStartInfo#START_TYPE_COLD.

The system will provide a newly started system trace and stack sampling profile in response to this trigger. Profiling will continue until the app calls android.app.Activity#reportFullyDrawn; otherwise, it will stop after a default period of 5 seconds.

The system uses a discard buffer for this trigger. This means that if the buffer fills up, newer events are discarded. This ensures that the earliest available tracepoints are always retained.

Note: There might be a delay before profiling begins, similar to when ProfilingManager.requestProfiling is used.

Value: 10

TRIGGER_TYPE_KILL_EXCESSIVE_CPU_USAGE

Added in API level 36
static val TRIGGER_TYPE_KILL_EXCESSIVE_CPU_USAGE: Int

Trigger occurs when an app is killed due to excessive CPU usage with an android.app.ApplicationExitInfo#getReason of android.app.ApplicationExitInfo#REASON_EXCESSIVE_RESOURCE_USAGE.

System will provide a snapshot of a running system trace in response to this trigger.

Value: 9

TRIGGER_TYPE_KILL_FORCE_STOP

static val TRIGGER_TYPE_KILL_FORCE_STOP: Int

Trigger occurs when an app is killed due to the user clicking the "Force stop" button of the App info page in Settings.

System will provide a snapshot of a running system trace in response to this trigger.

Value: 4

TRIGGER_TYPE_KILL_RECENTS

static val TRIGGER_TYPE_KILL_RECENTS: Int

Trigger occurs when an app is killed due to the user removing it in the Recents screen.

System will provide a snapshot of a running system trace in response to this trigger.

Value: 5

TRIGGER_TYPE_KILL_TASK_MANAGER

static val TRIGGER_TYPE_KILL_TASK_MANAGER: Int

Trigger occurs when an app is killed due to the user clicking the "Stop" button for the application in Task Manager.

System will provide a snapshot of a running system trace in response to this trigger.

Value: 6

TRIGGER_TYPE_NONE

Added in API level 36
static val TRIGGER_TYPE_NONE: Int

No trigger. Used in ProfilingResult for non trigger caused results.

Value: 0

TRIGGER_TYPE_OOM

Added in API level 36
static val TRIGGER_TYPE_OOM: Int

Trigger occurs when an app has an Out Of Memory Exception.

System will provide a Java heap dump in response to this trigger.

Use of this trigger requires that any custom java.lang.Thread.UncaughtExceptionHandler call through to the default uncaught exception handler (java.lang.Thread#getDefaultUncaughtExceptionHandler). If the default uncaught exception handler is not called, then this trigger cannot be used. The app can still obtain a Java heap dump in this case, but will have to request the profiling itself using ProfilingManager.requestProfiling.

Value: 7

Public methods

getRateLimitingPeriodHours

Added in API level 36
fun getRateLimitingPeriodHours(): Int

The requester set rate limiting period in hours.

The period is the minimum time the system should wait before providing another profiling result for the same trigger; actual time between events may be longer.

If the rate limiting period is set to 0, no app-provided rate limiting will be used.

This rate limiting is in addition to any system level rate limiting that may be applied.