ApplicationStartInfo


public final class ApplicationStartInfo
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.ApplicationStartInfo


Describes information related to an application process's startup.

Many aspects concerning why and how an applications process was started are valuable for apps both for logging and for potential behavior changes. Reason for process start, start type, start times, throttling, and other useful diagnostic data can be obtained from ApplicationStartInfo records.

Summary

Constants

int LAUNCH_MODE_SINGLE_INSTANCE

The system creates the activity at the root of a new task or locates the activity on an existing task with the same affinity.

int LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

The activity can only be running as the root activity of the task, the first activity that created the task, and therefore there will only be one instance of this activity in a task; but activity can be instantiated multiple times in different tasks.

int LAUNCH_MODE_SINGLE_TASK

Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance.

int LAUNCH_MODE_SINGLE_TOP

If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity.

int LAUNCH_MODE_STANDARD

Default.

int STARTUP_STATE_ERROR

State indicating process startup has failed.

int STARTUP_STATE_FIRST_FRAME_DRAWN

State indicating process startup has made it to first frame draw.

int STARTUP_STATE_STARTED

State indicating process startup has started.

int START_REASON_ALARM

Process started due to alarm.

int START_REASON_BACKUP

Process started to run backup.

int START_REASON_BOOT_COMPLETE

Process started due to boot complete.

int START_REASON_BROADCAST

Process started due to broadcast received.

int START_REASON_CONTENT_PROVIDER

Process started due to access of ContentProvider

int START_REASON_JOB

* Process started to run scheduled job.

int START_REASON_LAUNCHER

Process started due to click app icon or widget from launcher.

int START_REASON_LAUNCHER_RECENTS

Process started from launcher recents.

int START_REASON_OTHER

Process started not for any of the listed reasons.

int START_REASON_PUSH

Process started due to push message.

int START_REASON_SERVICE

Process service started.

int START_REASON_START_ACTIVITY

Process started due to Activity started for any reason not explicitly listed.

int START_TIMESTAMP_APPLICATION_ONCREATE

Clock monotonic timestamp of Application onCreate called.

int START_TIMESTAMP_BIND_APPLICATION

Clock monotonic timestamp of bindApplication called.

int START_TIMESTAMP_FIRST_FRAME

Clock monotonic timestamp of first frame drawn.

int START_TIMESTAMP_FORK

Clock monotonic timestamp of process fork.

int START_TIMESTAMP_FULLY_DRAWN

Clock monotonic timestamp of reportFullyDrawn called by application.

int START_TIMESTAMP_INITIAL_RENDERTHREAD_FRAME

Clock monotonic timestamp of initial renderthread frame.

int START_TIMESTAMP_LAUNCH

Clock monotonic timestamp of launch started.

int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER

The end of the range reserved for developer supplied timestamps.

int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START

The beginning of the range reserved for developer supplied timestamps.

int START_TIMESTAMP_RESERVED_RANGE_SYSTEM

The end of the range, beginning with 0, reserved for system timestamps.

int START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE

Clock monotonic timestamp of surfaceflinger composition complete.

int START_TYPE_COLD

Process started from scratch.

int START_TYPE_HOT

Process brought back to foreground.

int START_TYPE_UNSET

Start type not yet set.

int START_TYPE_WARM

Process retained minimally SavedInstanceState.

Inherited constants

Fields

public static final Creator<ApplicationStartInfo> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getDefiningUid()

Return the defining kernel user identifier, maybe different from getRealUid() and getPackageUid(), if an external service has the android:useAppZygote set to true and was bound with the flag Context.BIND_EXTERNAL_SERVICE - in this case, this field here will be the kernel user identifier of the external service provider.

Intent getIntent()

The intent used to launch the application.

int getLaunchMode()

An instruction on how the activity should be launched.

int getPackageUid()

Similar to getRealUid(), it's the kernel user identifier that is assigned at the package installation time.

int getPid()

The process id.

String getProcessName()

The actual process name it was running with.

int getRealUid()

The kernel user identifier of the process, most of the time the system uses this to do access control checks.

int getReason()

The reason code of what triggered the process's start.

int getStartType()

The state of the app at startup.

int getStartupState()

Current state of startup.

Map<IntegerLong> getStartupTimestamps()

Various clock monotonic timestamps in nanoseconds throughout the startup process.

int hashCode()

Returns a hash code value for the object.

boolean wasForceStopped()

Informs whether this is the first process launch for an app since it was force-stopped for some reason.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

LAUNCH_MODE_SINGLE_INSTANCE

public static final int LAUNCH_MODE_SINGLE_INSTANCE

The system creates the activity at the root of a new task or locates the activity on an existing task with the same affinity. If an instance of the activity already exists and is at the root of the task, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one.

Constant Value: 2 (0x00000002)

LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

public static final int LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

The activity can only be running as the root activity of the task, the first activity that created the task, and therefore there will only be one instance of this activity in a task; but activity can be instantiated multiple times in different tasks.

Constant Value: 4 (0x00000004)

LAUNCH_MODE_SINGLE_TASK

public static final int LAUNCH_MODE_SINGLE_TASK

Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task.

Constant Value: 3 (0x00000003)

LAUNCH_MODE_SINGLE_TOP

public static final int LAUNCH_MODE_SINGLE_TOP

If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity.

Constant Value: 1 (0x00000001)

LAUNCH_MODE_STANDARD

public static final int LAUNCH_MODE_STANDARD

Default. The system always creates a new instance of the activity in the target task and routes the intent to it.

Constant Value: 0 (0x00000000)

STARTUP_STATE_ERROR

public static final int STARTUP_STATE_ERROR

State indicating process startup has failed. Startup information in ApplicationStartInfo is incomplete, but no more will be added.

Constant Value: 1 (0x00000001)

STARTUP_STATE_FIRST_FRAME_DRAWN

public static final int STARTUP_STATE_FIRST_FRAME_DRAWN

State indicating process startup has made it to first frame draw. Startup information in ApplicationStartInfo is complete with potential exception of fully drawn timestamp which is not guaranteed to be set.

Constant Value: 2 (0x00000002)

STARTUP_STATE_STARTED

public static final int STARTUP_STATE_STARTED

State indicating process startup has started. Some information is available in ApplicationStartInfo and more will be added.

Constant Value: 0 (0x00000000)

START_REASON_ALARM

public static final int START_REASON_ALARM

Process started due to alarm.

Constant Value: 0 (0x00000000)

START_REASON_BACKUP

public static final int START_REASON_BACKUP

Process started to run backup.

Constant Value: 1 (0x00000001)

START_REASON_BOOT_COMPLETE

public static final int START_REASON_BOOT_COMPLETE

Process started due to boot complete.

Constant Value: 2 (0x00000002)

START_REASON_BROADCAST

public static final int START_REASON_BROADCAST

Process started due to broadcast received.

Constant Value: 3 (0x00000003)

START_REASON_CONTENT_PROVIDER

public static final int START_REASON_CONTENT_PROVIDER

Process started due to access of ContentProvider

Constant Value: 4 (0x00000004)

START_REASON_JOB

public static final int START_REASON_JOB

* Process started to run scheduled job.

Constant Value: 5 (0x00000005)

START_REASON_LAUNCHER

public static final int START_REASON_LAUNCHER

Process started due to click app icon or widget from launcher.

Constant Value: 6 (0x00000006)

START_REASON_LAUNCHER_RECENTS

public static final int START_REASON_LAUNCHER_RECENTS

Process started from launcher recents.

Constant Value: 7 (0x00000007)

START_REASON_OTHER

public static final int START_REASON_OTHER

Process started not for any of the listed reasons.

Constant Value: 8 (0x00000008)

START_REASON_PUSH

public static final int START_REASON_PUSH

Process started due to push message.

Constant Value: 9 (0x00000009)

START_REASON_SERVICE

public static final int START_REASON_SERVICE

Process service started.

Constant Value: 10 (0x0000000a)

START_REASON_START_ACTIVITY

public static final int START_REASON_START_ACTIVITY

Process started due to Activity started for any reason not explicitly listed.

Constant Value: 11 (0x0000000b)

START_TIMESTAMP_APPLICATION_ONCREATE

public static final int START_TIMESTAMP_APPLICATION_ONCREATE

Clock monotonic timestamp of Application onCreate called.

Constant Value: 2 (0x00000002)

START_TIMESTAMP_BIND_APPLICATION

public static final int START_TIMESTAMP_BIND_APPLICATION

Clock monotonic timestamp of bindApplication called.

Constant Value: 3 (0x00000003)

START_TIMESTAMP_FIRST_FRAME

public static final int START_TIMESTAMP_FIRST_FRAME

Clock monotonic timestamp of first frame drawn.

Constant Value: 4 (0x00000004)

START_TIMESTAMP_FORK

public static final int START_TIMESTAMP_FORK

Clock monotonic timestamp of process fork.

Constant Value: 1 (0x00000001)

START_TIMESTAMP_FULLY_DRAWN

public static final int START_TIMESTAMP_FULLY_DRAWN

Clock monotonic timestamp of reportFullyDrawn called by application.

Constant Value: 5 (0x00000005)

START_TIMESTAMP_INITIAL_RENDERTHREAD_FRAME

public static final int START_TIMESTAMP_INITIAL_RENDERTHREAD_FRAME

Clock monotonic timestamp of initial renderthread frame.

Constant Value: 6 (0x00000006)

START_TIMESTAMP_LAUNCH

public static final int START_TIMESTAMP_LAUNCH

Clock monotonic timestamp of launch started.

Constant Value: 0 (0x00000000)

START_TIMESTAMP_RESERVED_RANGE_DEVELOPER

public static final int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER

The end of the range reserved for developer supplied timestamps.

Constant Value: 30 (0x0000001e)

START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START

public static final int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START

The beginning of the range reserved for developer supplied timestamps.

Constant Value: 21 (0x00000015)

START_TIMESTAMP_RESERVED_RANGE_SYSTEM

public static final int START_TIMESTAMP_RESERVED_RANGE_SYSTEM

The end of the range, beginning with 0, reserved for system timestamps.

Constant Value: 20 (0x00000014)

START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE

public static final int START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE

Clock monotonic timestamp of surfaceflinger composition complete.

Constant Value: 7 (0x00000007)

START_TYPE_COLD

public static final int START_TYPE_COLD

Process started from scratch.

Constant Value: 1 (0x00000001)

START_TYPE_HOT

public static final int START_TYPE_HOT

Process brought back to foreground.

Constant Value: 3 (0x00000003)

START_TYPE_UNSET

public static final int START_TYPE_UNSET

Start type not yet set.

Constant Value: 0 (0x00000000)

START_TYPE_WARM

public static final int START_TYPE_WARM

Process retained minimally SavedInstanceState.

Constant Value: 2 (0x00000002)

Fields

CREATOR

public static final Creator<ApplicationStartInfo> CREATOR

Public methods

describeContents

public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getDefiningUid

public int getDefiningUid ()

Return the defining kernel user identifier, maybe different from getRealUid() and getPackageUid(), if an external service has the android:useAppZygote set to true and was bound with the flag Context.BIND_EXTERNAL_SERVICE - in this case, this field here will be the kernel user identifier of the external service provider.

Note: field will be set for any getStartupState() value.

Returns
int

getIntent

public Intent getIntent ()

The intent used to launch the application.

Note: Intent is stripped and does not include extras.

Note: field will be set for any getStartupState() value.

Returns
Intent This value may be null.

getLaunchMode

public int getLaunchMode ()

An instruction on how the activity should be launched. There are five modes that work in conjunction with activity flags in Intent objects to determine what should happen when the activity is called upon to handle an intent. Modes: LAUNCH_MODE_STANDARD LAUNCH_MODE_SINGLE_TOP LAUNCH_MODE_SINGLE_INSTANCE LAUNCH_MODE_SINGLE_TASK LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

Note: field will be set for any getStartupState() value.

Returns
int Value is LAUNCH_MODE_STANDARD, LAUNCH_MODE_SINGLE_TOP, LAUNCH_MODE_SINGLE_INSTANCE, LAUNCH_MODE_SINGLE_TASK, or LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

getPackageUid

public int getPackageUid ()

Similar to getRealUid(), it's the kernel user identifier that is assigned at the package installation time.

Note: field will be set for any getStartupState() value.

Returns
int

getPid

public int getPid ()

The process id.

Note: field will be set for any getStartupState() value.

Returns
int

getProcessName

public String getProcessName ()

The actual process name it was running with.

Note: field will be set for any getStartupState() value.

Returns
String This value cannot be null.

getRealUid

public int getRealUid ()

The kernel user identifier of the process, most of the time the system uses this to do access control checks. It's typically the uid of the package where the component is running from, except the case of isolated process, where this field identifies the kernel user identifier that this process is actually running with, while the getPackageUid() identifies the kernel user identifier that is assigned at the package installation time.

Note: field will be set for any getStartupState() value.

Returns
int

getStartType

public int getStartType ()

The state of the app at startup.

Note: field will be set for getStartupState() value STARTUP_STATE_FIRST_FRAME_DRAWN. Not guaranteed for other states.

Returns
int Value is START_TYPE_UNSET, START_TYPE_COLD, START_TYPE_WARM, or START_TYPE_HOT

getStartupState

public int getStartupState ()

Current state of startup. Can be used to determine whether the object will have additional fields added as it may be queried before all data is collected.

Note: field will always be set and available.

Returns
int Value is STARTUP_STATE_STARTED, STARTUP_STATE_ERROR, or STARTUP_STATE_FIRST_FRAME_DRAWN

getStartupTimestamps

public Map<IntegerLong> getStartupTimestamps ()

Various clock monotonic timestamps in nanoseconds throughout the startup process.

Note: different timestamps will be available for different values of getStartupState(): (Subsequent rows contain all timestamps of proceding states.) For STARTUP_STATE_STARTED, timestamp START_TIMESTAMP_LAUNCH will be available. For STARTUP_STATE_ERROR, no additional timestamps are guaranteed available. For STARTUP_STATE_FIRST_FRAME_DRAWN, timestamps START_TIMESTAMP_APPLICATION_ONCREATE, START_TIMESTAMP_BIND_APPLICATION, and START_TIMESTAMP_FIRST_FRAME will additionally be available. Timestamp START_TIMESTAMP_FULLY_DRAWN is never guaranteed to be available as it is dependant on devloper calling Activity#reportFullyDrawn.

Returns
Map<IntegerLong> This value cannot be null.

hashCode

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

Returns
int a hash code value for this object.

wasForceStopped

public boolean wasForceStopped ()

Informs whether this is the first process launch for an app since it was force-stopped for some reason. This allows the app to know if it should re-register for any alarms, jobs and other callbacks that were cleared when the app was force-stopped.

Returns
boolean true if this is the first process launch of the app after having been stopped, false otherwise.

writeToParcel

public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES