Loading core/api/current.txt +6 −0 Original line number Diff line number Diff line Loading @@ -5333,6 +5333,7 @@ package android.app { method @NonNull public String getProcessName(); method public int getRealUid(); method public int getReason(); method @FlaggedApi("android.app.app_start_info_component") public int getStartComponent(); method public int getStartType(); method public int getStartupState(); method @NonNull public java.util.Map<java.lang.Integer,java.lang.Long> getStartupTimestamps(); Loading @@ -5347,6 +5348,11 @@ package android.app { field public static final int STARTUP_STATE_ERROR = 1; // 0x1 field public static final int STARTUP_STATE_FIRST_FRAME_DRAWN = 2; // 0x2 field public static final int STARTUP_STATE_STARTED = 0; // 0x0 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_ACTIVITY = 1; // 0x1 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_BROADCAST = 2; // 0x2 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_CONTENT_PROVIDER = 3; // 0x3 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_OTHER = 5; // 0x5 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_SERVICE = 4; // 0x4 field public static final int START_REASON_ALARM = 0; // 0x0 field public static final int START_REASON_BACKUP = 1; // 0x1 field public static final int START_REASON_BOOT_COMPLETE = 2; // 0x2 core/java/android/app/ApplicationStartInfo.java +103 −11 Original line number Diff line number Diff line Loading @@ -102,10 +102,10 @@ public final class ApplicationStartInfo implements Parcelable { /** Process started due to boot complete. */ public static final int START_REASON_BOOT_COMPLETE = 2; /** Process started due to broadcast received. */ /** Process started due to broadcast received for any reason not explicitly listed. */ public static final int START_REASON_BROADCAST = 3; /** Process started due to access of ContentProvider */ /** Process started due to access of ContentProvider for any reason not explicitly listed. */ public static final int START_REASON_CONTENT_PROVIDER = 4; /** * Process started to run scheduled job. */ Loading @@ -123,7 +123,7 @@ public final class ApplicationStartInfo implements Parcelable { /** Process started due to push message. */ public static final int START_REASON_PUSH = 9; /** Process service started. */ /** Process started due to Service started for any reason not explicitly listed.. */ public static final int START_REASON_SERVICE = 10; /** Process started due to Activity started for any reason not explicitly listed. */ Loading Loading @@ -209,6 +209,26 @@ public final class ApplicationStartInfo implements Parcelable { /** Clock monotonic timestamp of surfaceflinger composition complete. */ public static final int START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE = 7; /** Process was started for an activity component. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_ACTIVITY = 1; /** Process was started for a broadcast component. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_BROADCAST = 2; /** Process was started for a content provider component. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_CONTENT_PROVIDER = 3; /** Process was started for a service component. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_SERVICE = 4; /** Process was started not for one of the four standard components. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_OTHER = 5; /** * @see #getMonoticCreationTimeMs */ Loading Loading @@ -279,6 +299,11 @@ public final class ApplicationStartInfo implements Parcelable { */ private boolean mWasForceStopped; /** * @see #getStartComponent() */ private @StartComponent int mStartComponent; /** * @hide * */ Loading Loading @@ -343,6 +368,21 @@ public final class ApplicationStartInfo implements Parcelable { @Retention(RetentionPolicy.SOURCE) public @interface LaunchMode {} /** * @hide * */ @IntDef( prefix = {"START_COMPONENT_"}, value = { START_COMPONENT_ACTIVITY, START_COMPONENT_BROADCAST, START_COMPONENT_CONTENT_PROVIDER, START_COMPONENT_SERVICE, START_COMPONENT_OTHER, }) @Retention(RetentionPolicy.SOURCE) public @interface StartComponent {} /** * @see #getStartupState * @hide Loading Loading @@ -479,6 +519,14 @@ public final class ApplicationStartInfo implements Parcelable { mWasForceStopped = wasForceStopped; } /** * @see #getStartComponent() * @hide */ public void setStartComponent(@StartComponent int startComponent) { mStartComponent = startComponent; } /** * Current state of startup. * Loading Loading @@ -567,6 +615,11 @@ public final class ApplicationStartInfo implements Parcelable { /** * The reason code of what triggered the process's start. * * Start reason provides granular reasoning on why the app is being started. Start reason should * not be used for distinguishing between the component the app is being started for as some * reasons may overlap with multiple components, see {@link #getStartComponent} for this * functionality instead. * * <p class="note"> Note: field will be set for any {@link #getStartupState} value.</p> */ public @StartReason int getReason() { Loading Loading @@ -654,6 +707,22 @@ public final class ApplicationStartInfo implements Parcelable { return mWasForceStopped; } /** * The component type that was being started which triggered the start. * * Start component should be used to accurately distinguish between the 4 component types: * activity, service, broadcast, and content provider. This can be useful for optimizing * startup flow by enabling the caller to only load the necessary dependencies for a specific * component type. For more granular information on why the app is being started, see * {@link #getReason}. * * <p class="note"> Note: field will be set for any {@link #getStartupState} value.</p> */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public @StartComponent int getStartComponent() { return mStartComponent; } @Override public int describeContents() { return 0; Loading Loading @@ -681,6 +750,7 @@ public final class ApplicationStartInfo implements Parcelable { dest.writeInt(mLaunchMode); dest.writeBoolean(mWasForceStopped); dest.writeLong(mMonoticCreationTimeMs); dest.writeInt(mStartComponent); } /** @hide */ Loading @@ -704,6 +774,7 @@ public final class ApplicationStartInfo implements Parcelable { mLaunchMode = other.mLaunchMode; mWasForceStopped = other.mWasForceStopped; mMonoticCreationTimeMs = other.mMonoticCreationTimeMs; mStartComponent = other.mStartComponent; } private ApplicationStartInfo(@NonNull Parcel in) { Loading @@ -727,6 +798,7 @@ public final class ApplicationStartInfo implements Parcelable { mLaunchMode = in.readInt(); mWasForceStopped = in.readBoolean(); mMonoticCreationTimeMs = in.readLong(); mStartComponent = in.readInt(); } private static String intern(@Nullable String source) { Loading Loading @@ -806,6 +878,7 @@ public final class ApplicationStartInfo implements Parcelable { proto.write(ApplicationStartInfoProto.LAUNCH_MODE, mLaunchMode); proto.write(ApplicationStartInfoProto.WAS_FORCE_STOPPED, mWasForceStopped); proto.write(ApplicationStartInfoProto.MONOTONIC_CREATION_TIME_MS, mMonoticCreationTimeMs); proto.write(ApplicationStartInfoProto.START_COMPONENT, mStartComponent); proto.end(token); } Loading Loading @@ -893,6 +966,9 @@ public final class ApplicationStartInfo implements Parcelable { mMonoticCreationTimeMs = proto.readLong( ApplicationStartInfoProto.MONOTONIC_CREATION_TIME_MS); break; case (int) ApplicationStartInfoProto.START_COMPONENT: mStartComponent = proto.readInt(ApplicationStartInfoProto.START_COMPONENT); break; } } proto.end(token); Loading @@ -919,8 +995,11 @@ public final class ApplicationStartInfo implements Parcelable { .append(" reason=").append(reasonToString(mReason)) .append(" startType=").append(startTypeToString(mStartType)) .append(" launchMode=").append(mLaunchMode) .append(" wasForceStopped=").append(mWasForceStopped) .append('\n'); .append(" wasForceStopped=").append(mWasForceStopped); if (Flags.appStartInfoComponent()) { sb.append(" startComponent=").append(startComponentToString(mStartComponent)); } sb.append('\n'); if (mStartIntent != null) { sb.append(" intent=").append(mStartIntent.toString()) .append('\n'); Loading Loading @@ -964,6 +1043,18 @@ public final class ApplicationStartInfo implements Parcelable { }; } @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) private static String startComponentToString(@StartComponent int startComponent) { return switch (startComponent) { case START_COMPONENT_ACTIVITY -> "ACTIVITY"; case START_COMPONENT_BROADCAST -> "SERVICE"; case START_COMPONENT_CONTENT_PROVIDER -> "CONTENT PROVIDER"; case START_COMPONENT_SERVICE -> "SERVICE"; case START_COMPONENT_OTHER -> "OTHER"; default -> ""; }; } /** @hide */ @Override public boolean equals(@Nullable Object other) { Loading @@ -976,14 +1067,15 @@ public final class ApplicationStartInfo implements Parcelable { && mStartupState == o.mStartupState && mStartType == o.mStartType && mLaunchMode == o.mLaunchMode && TextUtils.equals(mProcessName, o.mProcessName) && timestampsEquals(o) && mWasForceStopped == o.mWasForceStopped && mMonoticCreationTimeMs == o.mMonoticCreationTimeMs; && mMonoticCreationTimeMs == o.mMonoticCreationTimeMs && mStartComponent == o.mStartComponent; } @Override public int hashCode() { return Objects.hash(mPid, mRealUid, mPackageUid, mDefiningUid, mReason, mStartupState, mStartType, mLaunchMode, mProcessName, mStartupTimestampsNs, mMonoticCreationTimeMs); mMonoticCreationTimeMs, mStartComponent); } private boolean timestampsEquals(@NonNull ApplicationStartInfo other) { Loading core/java/android/app/activity_manager.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -158,3 +158,10 @@ flag { purpose: PURPOSE_BUGFIX } } flag { namespace: "system_performance" name: "app_start_info_component" description: "Control ApplicationStartInfo component field and API" bug: "362537357" } core/proto/android/app/appstartinfo.proto +1 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,5 @@ message ApplicationStartInfoProto { optional AppStartLaunchMode launch_mode = 11; optional bool was_force_stopped = 12; optional int64 monotonic_creation_time_ms = 13; optional int32 start_component = 14; } services/core/java/com/android/server/am/ActivityManagerService.java +4 −3 Original line number Diff line number Diff line Loading @@ -1038,13 +1038,14 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public void onIntentStarted(@NonNull Intent intent, long timestampNanos) { synchronized (this) { mProcessList.getAppStartInfoTracker().onIntentStarted(intent, timestampNanos); mProcessList.getAppStartInfoTracker() .onActivityIntentStarted(intent, timestampNanos); } } @Override public void onIntentFailed(long id) { mProcessList.getAppStartInfoTracker().onIntentFailed(id); mProcessList.getAppStartInfoTracker().onActivityIntentFailed(id); } @Override Loading Loading @@ -1078,7 +1079,7 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public void onReportFullyDrawn(long id, long timestampNanos) { mProcessList.getAppStartInfoTracker().onReportFullyDrawn(id, timestampNanos); mProcessList.getAppStartInfoTracker().onActivityReportFullyDrawn(id, timestampNanos); } }; Loading Loading
core/api/current.txt +6 −0 Original line number Diff line number Diff line Loading @@ -5333,6 +5333,7 @@ package android.app { method @NonNull public String getProcessName(); method public int getRealUid(); method public int getReason(); method @FlaggedApi("android.app.app_start_info_component") public int getStartComponent(); method public int getStartType(); method public int getStartupState(); method @NonNull public java.util.Map<java.lang.Integer,java.lang.Long> getStartupTimestamps(); Loading @@ -5347,6 +5348,11 @@ package android.app { field public static final int STARTUP_STATE_ERROR = 1; // 0x1 field public static final int STARTUP_STATE_FIRST_FRAME_DRAWN = 2; // 0x2 field public static final int STARTUP_STATE_STARTED = 0; // 0x0 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_ACTIVITY = 1; // 0x1 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_BROADCAST = 2; // 0x2 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_CONTENT_PROVIDER = 3; // 0x3 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_OTHER = 5; // 0x5 field @FlaggedApi("android.app.app_start_info_component") public static final int START_COMPONENT_SERVICE = 4; // 0x4 field public static final int START_REASON_ALARM = 0; // 0x0 field public static final int START_REASON_BACKUP = 1; // 0x1 field public static final int START_REASON_BOOT_COMPLETE = 2; // 0x2
core/java/android/app/ApplicationStartInfo.java +103 −11 Original line number Diff line number Diff line Loading @@ -102,10 +102,10 @@ public final class ApplicationStartInfo implements Parcelable { /** Process started due to boot complete. */ public static final int START_REASON_BOOT_COMPLETE = 2; /** Process started due to broadcast received. */ /** Process started due to broadcast received for any reason not explicitly listed. */ public static final int START_REASON_BROADCAST = 3; /** Process started due to access of ContentProvider */ /** Process started due to access of ContentProvider for any reason not explicitly listed. */ public static final int START_REASON_CONTENT_PROVIDER = 4; /** * Process started to run scheduled job. */ Loading @@ -123,7 +123,7 @@ public final class ApplicationStartInfo implements Parcelable { /** Process started due to push message. */ public static final int START_REASON_PUSH = 9; /** Process service started. */ /** Process started due to Service started for any reason not explicitly listed.. */ public static final int START_REASON_SERVICE = 10; /** Process started due to Activity started for any reason not explicitly listed. */ Loading Loading @@ -209,6 +209,26 @@ public final class ApplicationStartInfo implements Parcelable { /** Clock monotonic timestamp of surfaceflinger composition complete. */ public static final int START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE = 7; /** Process was started for an activity component. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_ACTIVITY = 1; /** Process was started for a broadcast component. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_BROADCAST = 2; /** Process was started for a content provider component. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_CONTENT_PROVIDER = 3; /** Process was started for a service component. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_SERVICE = 4; /** Process was started not for one of the four standard components. */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public static final int START_COMPONENT_OTHER = 5; /** * @see #getMonoticCreationTimeMs */ Loading Loading @@ -279,6 +299,11 @@ public final class ApplicationStartInfo implements Parcelable { */ private boolean mWasForceStopped; /** * @see #getStartComponent() */ private @StartComponent int mStartComponent; /** * @hide * */ Loading Loading @@ -343,6 +368,21 @@ public final class ApplicationStartInfo implements Parcelable { @Retention(RetentionPolicy.SOURCE) public @interface LaunchMode {} /** * @hide * */ @IntDef( prefix = {"START_COMPONENT_"}, value = { START_COMPONENT_ACTIVITY, START_COMPONENT_BROADCAST, START_COMPONENT_CONTENT_PROVIDER, START_COMPONENT_SERVICE, START_COMPONENT_OTHER, }) @Retention(RetentionPolicy.SOURCE) public @interface StartComponent {} /** * @see #getStartupState * @hide Loading Loading @@ -479,6 +519,14 @@ public final class ApplicationStartInfo implements Parcelable { mWasForceStopped = wasForceStopped; } /** * @see #getStartComponent() * @hide */ public void setStartComponent(@StartComponent int startComponent) { mStartComponent = startComponent; } /** * Current state of startup. * Loading Loading @@ -567,6 +615,11 @@ public final class ApplicationStartInfo implements Parcelable { /** * The reason code of what triggered the process's start. * * Start reason provides granular reasoning on why the app is being started. Start reason should * not be used for distinguishing between the component the app is being started for as some * reasons may overlap with multiple components, see {@link #getStartComponent} for this * functionality instead. * * <p class="note"> Note: field will be set for any {@link #getStartupState} value.</p> */ public @StartReason int getReason() { Loading Loading @@ -654,6 +707,22 @@ public final class ApplicationStartInfo implements Parcelable { return mWasForceStopped; } /** * The component type that was being started which triggered the start. * * Start component should be used to accurately distinguish between the 4 component types: * activity, service, broadcast, and content provider. This can be useful for optimizing * startup flow by enabling the caller to only load the necessary dependencies for a specific * component type. For more granular information on why the app is being started, see * {@link #getReason}. * * <p class="note"> Note: field will be set for any {@link #getStartupState} value.</p> */ @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) public @StartComponent int getStartComponent() { return mStartComponent; } @Override public int describeContents() { return 0; Loading Loading @@ -681,6 +750,7 @@ public final class ApplicationStartInfo implements Parcelable { dest.writeInt(mLaunchMode); dest.writeBoolean(mWasForceStopped); dest.writeLong(mMonoticCreationTimeMs); dest.writeInt(mStartComponent); } /** @hide */ Loading @@ -704,6 +774,7 @@ public final class ApplicationStartInfo implements Parcelable { mLaunchMode = other.mLaunchMode; mWasForceStopped = other.mWasForceStopped; mMonoticCreationTimeMs = other.mMonoticCreationTimeMs; mStartComponent = other.mStartComponent; } private ApplicationStartInfo(@NonNull Parcel in) { Loading @@ -727,6 +798,7 @@ public final class ApplicationStartInfo implements Parcelable { mLaunchMode = in.readInt(); mWasForceStopped = in.readBoolean(); mMonoticCreationTimeMs = in.readLong(); mStartComponent = in.readInt(); } private static String intern(@Nullable String source) { Loading Loading @@ -806,6 +878,7 @@ public final class ApplicationStartInfo implements Parcelable { proto.write(ApplicationStartInfoProto.LAUNCH_MODE, mLaunchMode); proto.write(ApplicationStartInfoProto.WAS_FORCE_STOPPED, mWasForceStopped); proto.write(ApplicationStartInfoProto.MONOTONIC_CREATION_TIME_MS, mMonoticCreationTimeMs); proto.write(ApplicationStartInfoProto.START_COMPONENT, mStartComponent); proto.end(token); } Loading Loading @@ -893,6 +966,9 @@ public final class ApplicationStartInfo implements Parcelable { mMonoticCreationTimeMs = proto.readLong( ApplicationStartInfoProto.MONOTONIC_CREATION_TIME_MS); break; case (int) ApplicationStartInfoProto.START_COMPONENT: mStartComponent = proto.readInt(ApplicationStartInfoProto.START_COMPONENT); break; } } proto.end(token); Loading @@ -919,8 +995,11 @@ public final class ApplicationStartInfo implements Parcelable { .append(" reason=").append(reasonToString(mReason)) .append(" startType=").append(startTypeToString(mStartType)) .append(" launchMode=").append(mLaunchMode) .append(" wasForceStopped=").append(mWasForceStopped) .append('\n'); .append(" wasForceStopped=").append(mWasForceStopped); if (Flags.appStartInfoComponent()) { sb.append(" startComponent=").append(startComponentToString(mStartComponent)); } sb.append('\n'); if (mStartIntent != null) { sb.append(" intent=").append(mStartIntent.toString()) .append('\n'); Loading Loading @@ -964,6 +1043,18 @@ public final class ApplicationStartInfo implements Parcelable { }; } @FlaggedApi(Flags.FLAG_APP_START_INFO_COMPONENT) private static String startComponentToString(@StartComponent int startComponent) { return switch (startComponent) { case START_COMPONENT_ACTIVITY -> "ACTIVITY"; case START_COMPONENT_BROADCAST -> "SERVICE"; case START_COMPONENT_CONTENT_PROVIDER -> "CONTENT PROVIDER"; case START_COMPONENT_SERVICE -> "SERVICE"; case START_COMPONENT_OTHER -> "OTHER"; default -> ""; }; } /** @hide */ @Override public boolean equals(@Nullable Object other) { Loading @@ -976,14 +1067,15 @@ public final class ApplicationStartInfo implements Parcelable { && mStartupState == o.mStartupState && mStartType == o.mStartType && mLaunchMode == o.mLaunchMode && TextUtils.equals(mProcessName, o.mProcessName) && timestampsEquals(o) && mWasForceStopped == o.mWasForceStopped && mMonoticCreationTimeMs == o.mMonoticCreationTimeMs; && mMonoticCreationTimeMs == o.mMonoticCreationTimeMs && mStartComponent == o.mStartComponent; } @Override public int hashCode() { return Objects.hash(mPid, mRealUid, mPackageUid, mDefiningUid, mReason, mStartupState, mStartType, mLaunchMode, mProcessName, mStartupTimestampsNs, mMonoticCreationTimeMs); mMonoticCreationTimeMs, mStartComponent); } private boolean timestampsEquals(@NonNull ApplicationStartInfo other) { Loading
core/java/android/app/activity_manager.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -158,3 +158,10 @@ flag { purpose: PURPOSE_BUGFIX } } flag { namespace: "system_performance" name: "app_start_info_component" description: "Control ApplicationStartInfo component field and API" bug: "362537357" }
core/proto/android/app/appstartinfo.proto +1 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,5 @@ message ApplicationStartInfoProto { optional AppStartLaunchMode launch_mode = 11; optional bool was_force_stopped = 12; optional int64 monotonic_creation_time_ms = 13; optional int32 start_component = 14; }
services/core/java/com/android/server/am/ActivityManagerService.java +4 −3 Original line number Diff line number Diff line Loading @@ -1038,13 +1038,14 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public void onIntentStarted(@NonNull Intent intent, long timestampNanos) { synchronized (this) { mProcessList.getAppStartInfoTracker().onIntentStarted(intent, timestampNanos); mProcessList.getAppStartInfoTracker() .onActivityIntentStarted(intent, timestampNanos); } } @Override public void onIntentFailed(long id) { mProcessList.getAppStartInfoTracker().onIntentFailed(id); mProcessList.getAppStartInfoTracker().onActivityIntentFailed(id); } @Override Loading Loading @@ -1078,7 +1079,7 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public void onReportFullyDrawn(long id, long timestampNanos) { mProcessList.getAppStartInfoTracker().onReportFullyDrawn(id, timestampNanos); mProcessList.getAppStartInfoTracker().onActivityReportFullyDrawn(id, timestampNanos); } }; Loading