ProfilingTrigger


public final class ProfilingTrigger
extends Object

java.lang.Object
   ↳ android.os.ProfilingTrigger


Encapsulates a single profiling trigger.

Summary

Nested classes

class ProfilingTrigger.Builder

Builder class to create a ProfilingTrigger object. 

Constants

int TRIGGER_TYPE_ANR

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

int TRIGGER_TYPE_APP_FULLY_DRAWN

Trigger occurs after Activity.reportFullyDrawn() is called for a cold start.

int TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE

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

int TRIGGER_TYPE_COLD_START

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

int TRIGGER_TYPE_KILL_EXCESSIVE_CPU_USAGE

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

int TRIGGER_TYPE_KILL_FORCE_STOP

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

int TRIGGER_TYPE_KILL_RECENTS

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

int TRIGGER_TYPE_KILL_TASK_MANAGER

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

int TRIGGER_TYPE_NONE

No trigger.

int TRIGGER_TYPE_OOM

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

Public methods

int getRateLimitingPeriodHours()

The requester set rate limiting period in hours.

int getTriggerType()

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

Inherited methods

Constants

TRIGGER_TYPE_ANR

Added in API level 36
public static final int TRIGGER_TYPE_ANR

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.

Constant Value: 2 (0x00000002)

TRIGGER_TYPE_APP_FULLY_DRAWN

Added in API level 36
public static final int TRIGGER_TYPE_APP_FULLY_DRAWN

Trigger occurs after Activity.reportFullyDrawn() is called for a cold start.

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

Constant Value: 1 (0x00000001)

TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE

Added in version 36.1
public static final int TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE

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.

Constant Value: 3 (0x00000003)

TRIGGER_TYPE_COLD_START

Added in API level 36
public static final int TRIGGER_TYPE_COLD_START

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

This happens when the ApplicationStartInfo.getStartType() start type is 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 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.

Constant Value: 10 (0x0000000a)

TRIGGER_TYPE_KILL_EXCESSIVE_CPU_USAGE

Added in API level 36
public static final int TRIGGER_TYPE_KILL_EXCESSIVE_CPU_USAGE

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

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

Constant Value: 9 (0x00000009)

TRIGGER_TYPE_KILL_FORCE_STOP

Added in version 36.1
public static final int TRIGGER_TYPE_KILL_FORCE_STOP

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.

Constant Value: 4 (0x00000004)

TRIGGER_TYPE_KILL_RECENTS

Added in version 36.1
public static final int TRIGGER_TYPE_KILL_RECENTS

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.

Constant Value: 5 (0x00000005)

TRIGGER_TYPE_KILL_TASK_MANAGER

Added in version 36.1
public static final int TRIGGER_TYPE_KILL_TASK_MANAGER

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.

Constant Value: 6 (0x00000006)

TRIGGER_TYPE_NONE

Added in API level 36
public static final int TRIGGER_TYPE_NONE

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

Constant Value: 0 (0x00000000)

TRIGGER_TYPE_OOM

Added in API level 36
public static final int TRIGGER_TYPE_OOM

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 Thread.UncaughtExceptionHandler call through to the default uncaught exception handler (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.

Constant Value: 7 (0x00000007)

Public methods

getRateLimitingPeriodHours

Added in API level 36
public int getRateLimitingPeriodHours ()

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.

Returns
int

getTriggerType

Added in API level 36
public int getTriggerType ()

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

Returns
int Value is one of the following: