diff options
| author | 2023-07-25 14:22:56 +0000 | |
|---|---|---|
| committer | 2023-07-25 14:22:56 +0000 | |
| commit | 7f0bf14c190e57fb1049092bc89103313b402cfd (patch) | |
| tree | 26c7ffe7d807211e8ebe073bd600a6d422a439e4 | |
| parent | b1f682d246d40fcb53f7c6f04c9e4b82098db22b (diff) | |
| parent | 1bbfec6e7479ee78c2269b96ead71ae2f4c19e03 (diff) | |
Merge "Update ApplicationStartInfo API" into main
| -rw-r--r-- | core/api/current.txt | 55 | ||||
| -rw-r--r-- | core/api/system-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/app/ActivityManager.java | 63 | ||||
| -rw-r--r-- | core/java/android/app/ApplicationStartInfo.java | 144 | ||||
| -rw-r--r-- | core/java/android/app/IActivityManager.aidl | 15 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerConstants.java | 22 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 27 |
7 files changed, 229 insertions, 98 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index e157571e2bac..1e2676c86b7a 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -4616,7 +4616,9 @@ package android.app { public class ActivityManager { method public int addAppTask(@NonNull android.app.Activity, @NonNull android.content.Intent, @Nullable android.app.ActivityManager.TaskDescription, @NonNull android.graphics.Bitmap); + method public void addStartInfoTimestamp(@IntRange(from=android.app.ApplicationStartInfo.START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START, to=android.app.ApplicationStartInfo.START_TIMESTAMP_RESERVED_RANGE_DEVELOPER) int, long); method public void appNotResponding(@NonNull String); + method public void clearApplicationStartInfoCompletionListener(); method public boolean clearApplicationUserData(); method public void clearWatchHeapLimit(); method @RequiresPermission(android.Manifest.permission.DUMP) public void dumpPackageState(java.io.FileDescriptor, String); @@ -4624,6 +4626,7 @@ package android.app { method public java.util.List<android.app.ActivityManager.AppTask> getAppTasks(); method public android.content.pm.ConfigurationInfo getDeviceConfigurationInfo(); method @NonNull public java.util.List<android.app.ApplicationExitInfo> getHistoricalProcessExitReasons(@Nullable String, @IntRange(from=0) int, @IntRange(from=0) int); + method @NonNull public java.util.List<android.app.ApplicationStartInfo> getHistoricalProcessStartReasons(@IntRange(from=0) int); method public int getLargeMemoryClass(); method public int getLauncherLargeIconDensity(); method public int getLauncherLargeIconSize(); @@ -4650,6 +4653,7 @@ package android.app { method @RequiresPermission(android.Manifest.permission.REORDER_TASKS) public void moveTaskToFront(int, int); method @RequiresPermission(android.Manifest.permission.REORDER_TASKS) public void moveTaskToFront(int, int, android.os.Bundle); method @Deprecated public void restartPackage(String); + method public void setApplicationStartInfoCompletionListener(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.ApplicationStartInfo>); method public void setProcessStateSummary(@Nullable byte[]); method public static void setVrThread(int); method public void setWatchHeapLimit(long); @@ -5230,6 +5234,57 @@ package android.app { field public static final int REASON_USER_STOPPED = 11; // 0xb } + public final class ApplicationStartInfo implements android.os.Parcelable { + method public int describeContents(); + method public int getDefiningUid(); + method @Nullable public android.content.Intent getIntent(); + method public int getLaunchMode(); + method public int getPackageUid(); + method public int getPid(); + method @NonNull public String getProcessName(); + method public int getRealUid(); + method public int getReason(); + method public int getStartType(); + method public int getStartupState(); + method @NonNull public java.util.Map<java.lang.Integer,java.lang.Long> getStartupTimestamps(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.app.ApplicationStartInfo> CREATOR; + field public static final int LAUNCH_MODE_SINGLE_INSTANCE = 2; // 0x2 + field public static final int LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK = 4; // 0x4 + field public static final int LAUNCH_MODE_SINGLE_TASK = 3; // 0x3 + field public static final int LAUNCH_MODE_SINGLE_TOP = 1; // 0x1 + field public static final int LAUNCH_MODE_STANDARD = 0; // 0x0 + 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 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 + field public static final int START_REASON_BROADCAST = 3; // 0x3 + field public static final int START_REASON_CONTENT_PROVIDER = 4; // 0x4 + field public static final int START_REASON_JOB = 5; // 0x5 + field public static final int START_REASON_LAUNCHER = 6; // 0x6 + field public static final int START_REASON_LAUNCHER_RECENTS = 7; // 0x7 + field public static final int START_REASON_OTHER = 8; // 0x8 + field public static final int START_REASON_PUSH = 9; // 0x9 + field public static final int START_REASON_SERVICE = 10; // 0xa + field public static final int START_REASON_START_ACTIVITY = 11; // 0xb + field public static final int START_TIMESTAMP_APPLICATION_ONCREATE = 2; // 0x2 + field public static final int START_TIMESTAMP_BIND_APPLICATION = 3; // 0x3 + field public static final int START_TIMESTAMP_FIRST_FRAME = 4; // 0x4 + field public static final int START_TIMESTAMP_FORK = 1; // 0x1 + field public static final int START_TIMESTAMP_FULLY_DRAWN = 5; // 0x5 + field public static final int START_TIMESTAMP_INITIAL_RENDERTHREAD_FRAME = 6; // 0x6 + field public static final int START_TIMESTAMP_LAUNCH = 0; // 0x0 + field public static final int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER = 30; // 0x1e + field public static final int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START = 21; // 0x15 + field public static final int START_TIMESTAMP_RESERVED_RANGE_SYSTEM = 20; // 0x14 + field public static final int START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE = 7; // 0x7 + field public static final int START_TYPE_COLD = 0; // 0x0 + field public static final int START_TYPE_HOT = 2; // 0x2 + field public static final int START_TYPE_WARM = 1; // 0x1 + } + public final class AsyncNotedAppOp implements android.os.Parcelable { method public int describeContents(); method @Nullable public String getAttributionTag(); diff --git a/core/api/system-current.txt b/core/api/system-current.txt index b18584becbb2..fbc759f790f3 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -535,6 +535,7 @@ package android.app { method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public void addOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener, int); method @RequiresPermission(android.Manifest.permission.FORCE_STOP_PACKAGES) public void forceStopPackage(String); method @RequiresPermission(anyOf={"android.permission.INTERACT_ACROSS_USERS", "android.permission.INTERACT_ACROSS_USERS_FULL"}) public static int getCurrentUser(); + method @NonNull @RequiresPermission(android.Manifest.permission.DUMP) public java.util.List<android.app.ApplicationStartInfo> getExternalHistoricalProcessStartReasons(@NonNull String, @IntRange(from=0) int); method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getPackageImportance(String); method @NonNull public java.util.Collection<java.util.Locale> getSupportedLocales(); method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getUidImportance(int); diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 37a1e62c8cc0..b4f6d6fe770d 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -72,6 +72,7 @@ import android.os.PowerExemptionManager.ReasonCode; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; @@ -107,6 +108,7 @@ import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.concurrent.Executor; +import java.util.function.Consumer; /** * <p> @@ -3978,8 +3980,6 @@ public class ActivityManager { * * @return a list of {@link ApplicationStartInfo} records matching the criteria, sorted in * the order from most recent to least recent. - * - * @hide */ @NonNull public List<ApplicationStartInfo> getHistoricalProcessStartReasons( @@ -4011,6 +4011,7 @@ public class ActivityManager { * @hide */ @NonNull + @SystemApi @RequiresPermission(Manifest.permission.DUMP) public List<ApplicationStartInfo> getExternalHistoricalProcessStartReasons( @NonNull String packageName, @IntRange(from = 0) int maxNum) { @@ -4024,18 +4025,6 @@ public class ActivityManager { } /** - * Callback to receive {@link ApplicationStartInfo} object once recording of startup related - * metrics is complete. - * Use with {@link #setApplicationStartInfoCompleteListener}. - * - * @hide - */ - public interface ApplicationStartInfoCompleteListener { - /** {@link ApplicationStartInfo} is complete, no more info will be added. */ - void onApplicationStartInfoComplete(@NonNull ApplicationStartInfo applicationStartInfo); - } - - /** * Sets a callback to be notified when the {@link ApplicationStartInfo} records of this startup * are complete. * @@ -4054,19 +4043,16 @@ public class ActivityManager { * complete. Will replace existing listener if one is already attached. * * @throws IllegalArgumentException if executor or listener are null. - * - * @hide */ - public void setApplicationStartInfoCompleteListener(@NonNull final Executor executor, - @NonNull final ApplicationStartInfoCompleteListener listener) { + public void setApplicationStartInfoCompletionListener(@NonNull final Executor executor, + @NonNull final Consumer<ApplicationStartInfo> listener) { Preconditions.checkNotNull(executor, "executor cannot be null"); Preconditions.checkNotNull(listener, "listener cannot be null"); IApplicationStartInfoCompleteListener callback = new IApplicationStartInfoCompleteListener.Stub() { @Override public void onApplicationStartInfoComplete(ApplicationStartInfo applicationStartInfo) { - executor.execute(() -> - listener.onApplicationStartInfoComplete(applicationStartInfo)); + executor.execute(() -> listener.accept(applicationStartInfo)); } }; try { @@ -4077,13 +4063,42 @@ public class ActivityManager { } /** - * Removes the callback set by {@link #setApplicationStartInfoCompleteListener} if there is one. + * Removes the callback set by {@link #setApplicationStartInfoCompletionListener} if there is one. + */ + public void clearApplicationStartInfoCompletionListener() { + try { + getService().clearApplicationStartInfoCompleteListener(mContext.getUserId()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Adds an optional developer supplied timestamp to the calling apps most recent + * {@link ApplicationStartInfo}. This is in addition to system recorded timestamps. * - * @hide + * <p class="note"> Note: timestamps added after {@link Activity#reportFullyDrawn} is called + * will be discarded.</p> + * + * <p class="note"> Note: will overwrite existing timestamp if called with same key.</p> + * + * @param key Unique key for timestamp. Must be greater than + * {@link ApplicationStartInfo#START_TIMESTAMP_RESERVED_RANGE_SYSTEM} and + * less than or equal to + * {@link ApplicationStartInfo#START_TIMESTAMP_RESERVED_RANGE_DEVELOPER}. + * Will thow {@link java.lang.IllegalArgumentException} if not in range. + * @param timestampNs Clock monotonic time in nanoseconds of event to be recorded. */ - public void removeApplicationStartInfoCompleteListener() { + public void addStartInfoTimestamp(@IntRange( + from = ApplicationStartInfo.START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START, + to = ApplicationStartInfo.START_TIMESTAMP_RESERVED_RANGE_DEVELOPER) int key, + long timestampNs) { + if (key <= ApplicationStartInfo.START_TIMESTAMP_RESERVED_RANGE_SYSTEM + || key > ApplicationStartInfo.START_TIMESTAMP_RESERVED_RANGE_DEVELOPER) { + throw new IllegalArgumentException("Key not in allowed range."); + } try { - getService().removeApplicationStartInfoCompleteListener(mContext.getUserId()); + getService().addStartInfoTimestamp(key, timestampNs, mContext.getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/app/ApplicationStartInfo.java b/core/java/android/app/ApplicationStartInfo.java index 5e2a4ca441a0..f5fb6edfcc04 100644 --- a/core/java/android/app/ApplicationStartInfo.java +++ b/core/java/android/app/ApplicationStartInfo.java @@ -21,20 +21,21 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.content.Intent; +import android.icu.text.SimpleDateFormat; import android.os.Parcel; import android.os.Parcelable; +import android.os.UserHandle; +import android.util.ArrayMap; -import java.lang.annotation.ElementType; +import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import java.util.Set; /** * Provide information related to a processes startup. - * - * @hide */ public final class ApplicationStartInfo implements Parcelable { @@ -78,14 +79,14 @@ public final class ApplicationStartInfo implements Parcelable { /** Process started due to click app icon or widget from launcher. */ public static final int START_REASON_LAUNCHER = 6; + /** Process started from launcher recents. */ + public static final int START_REASON_LAUNCHER_RECENTS = 7; + /** Process started not for any of the listed reasons. */ - public static final int START_REASON_OTHER = 7; + public static final int START_REASON_OTHER = 8; /** Process started due to push message. */ - public static final int START_REASON_PUSH = 8; - - /** Process started to resume activity. */ - public static final int START_REASON_RESUMED_ACTIVITY = 9; + public static final int START_REASON_PUSH = 9; /** Process service started. */ public static final int START_REASON_SERVICE = 10; @@ -136,11 +137,21 @@ public final class ApplicationStartInfo implements Parcelable { */ public static final int LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK = 4; + /** The end of the range, beginning with 0, reserved for system timestamps.*/ + public static final int START_TIMESTAMP_RESERVED_RANGE_SYSTEM = 20; + + /** The beginning of the range reserved for developer supplied timestamps.*/ + public static final int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START = + START_TIMESTAMP_RESERVED_RANGE_SYSTEM + 1; + + /** The end of the range reserved for developer supplied timestamps.*/ + public static final int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER = 30; + /** Clock monotonic timestamp of launch started. */ public static final int START_TIMESTAMP_LAUNCH = 0; - /** Clock monotonic timestamp of finish java classloading. */ - public static final int START_TIMESTAMP_JAVA_CLASSLOADING_COMPLETE = 1; + /** Clock monotonic timestamp of process fork. */ + public static final int START_TIMESTAMP_FORK = 1; /** Clock monotonic timestamp of Application onCreate called. */ public static final int START_TIMESTAMP_APPLICATION_ONCREATE = 2; @@ -154,6 +165,12 @@ public final class ApplicationStartInfo implements Parcelable { /** Clock monotonic timestamp of reportFullyDrawn called by application. */ public static final int START_TIMESTAMP_FULLY_DRAWN = 5; + /** Clock monotonic timestamp of initial renderthread frame. */ + public static final int START_TIMESTAMP_INITIAL_RENDERTHREAD_FRAME = 6; + + /** Clock monotonic timestamp of surfaceflinger composition complete. */ + public static final int START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE = 7; + /** * @see #getStartupState */ @@ -192,7 +209,7 @@ public final class ApplicationStartInfo implements Parcelable { /** * @see #getStartupTimestamps */ - private Map<@StartupTimestamp Integer, Long> mStartupTimestampsNs; + private ArrayMap<Integer, Long> mStartupTimestampsNs; /** * @see #getStartType @@ -235,9 +252,9 @@ public final class ApplicationStartInfo implements Parcelable { START_REASON_CONTENT_PROVIDER, START_REASON_JOB, START_REASON_LAUNCHER, + START_REASON_LAUNCHER_RECENTS, START_REASON_OTHER, START_REASON_PUSH, - START_REASON_RESUMED_ACTIVITY, START_REASON_SERVICE, START_REASON_START_ACTIVITY, }) @@ -273,22 +290,6 @@ public final class ApplicationStartInfo implements Parcelable { public @interface LaunchMode {} /** - * @hide * - */ - @IntDef( - prefix = {"START_TIMESTAMP_"}, - value = { - START_TIMESTAMP_LAUNCH, - START_TIMESTAMP_JAVA_CLASSLOADING_COMPLETE, - START_TIMESTAMP_APPLICATION_ONCREATE, - START_TIMESTAMP_BIND_APPLICATION, - START_TIMESTAMP_FULLY_DRAWN, - }) - @Retention(RetentionPolicy.SOURCE) - @Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE}) - public @interface StartupTimestamp {} - - /** * @see #getStartupState * @hide */ @@ -348,9 +349,12 @@ public final class ApplicationStartInfo implements Parcelable { * @see #getStartupTimestamps * @hide */ - public void addStartupTimestamp(@StartupTimestamp int key, long timestampNs) { + public void addStartupTimestamp(int key, long timestampNs) { + if (key < 0 || key > START_TIMESTAMP_RESERVED_RANGE_DEVELOPER) { + return; + } if (mStartupTimestampsNs == null) { - mStartupTimestampsNs = new HashMap<@StartupTimestamp Integer, Long>(); + mStartupTimestampsNs = new ArrayMap<Integer, Long>(); } mStartupTimestampsNs.put(key, timestampNs); } @@ -475,9 +479,9 @@ public final class ApplicationStartInfo implements Parcelable { * dependant on devloper calling {@link Activity#reportFullyDrawn}. * </p> */ - public @NonNull Map<@StartupTimestamp Integer, Long> getStartupTimestamps() { + public @NonNull Map<Integer, Long> getStartupTimestamps() { if (mStartupTimestampsNs == null) { - mStartupTimestampsNs = new HashMap<@StartupTimestamp Integer, Long>(); + mStartupTimestampsNs = new ArrayMap<Integer, Long>(); } return mStartupTimestampsNs; } @@ -536,9 +540,12 @@ public final class ApplicationStartInfo implements Parcelable { dest.writeString(mProcessName); dest.writeInt(mReason); dest.writeInt(mStartupTimestampsNs.size()); - for (@StartupTimestamp int key : mStartupTimestampsNs.keySet()) { - dest.writeInt(key); - dest.writeLong(mStartupTimestampsNs.get(key)); + Set<Map.Entry<Integer, Long>> timestampEntrySet = mStartupTimestampsNs.entrySet(); + Iterator<Map.Entry<Integer, Long>> iter = timestampEntrySet.iterator(); + while (iter.hasNext()) { + Map.Entry<Integer, Long> entry = iter.next(); + dest.writeInt(entry.getKey()); + dest.writeLong(entry.getValue()); } dest.writeInt(mStartType); dest.writeParcelable(mStartIntent, flags); @@ -599,4 +606,67 @@ public final class ApplicationStartInfo implements Parcelable { return new ApplicationStartInfo[size]; } }; + + /** @hide */ + public void dump(@NonNull PrintWriter pw, @Nullable String prefix, @Nullable String seqSuffix, + @NonNull SimpleDateFormat sdf) { + StringBuilder sb = new StringBuilder(); + sb.append(prefix) + .append("ApplicationStartInfo ").append(seqSuffix).append(':') + .append('\n') + .append(" pid=").append(mPid) + .append(" realUid=").append(mRealUid) + .append(" packageUid=").append(mPackageUid) + .append(" definingUid=").append(mDefiningUid) + .append(" user=").append(UserHandle.getUserId(mPackageUid)) + .append('\n') + .append(" process=").append(mProcessName) + .append(" startupState=").append(mStartupState) + .append(" reason=").append(reasonToString(mReason)) + .append(" startType=").append(startTypeToString(mStartType)) + .append(" launchMode=").append(mLaunchMode) + .append('\n'); + if (mStartIntent != null) { + sb.append(" intent=").append(mStartIntent.toString()) + .append('\n'); + } + if (mStartupTimestampsNs.size() > 0) { + sb.append(" timestamps: "); + Set<Map.Entry<Integer, Long>> timestampEntrySet = mStartupTimestampsNs.entrySet(); + Iterator<Map.Entry<Integer, Long>> iter = timestampEntrySet.iterator(); + while (iter.hasNext()) { + Map.Entry<Integer, Long> entry = iter.next(); + sb.append(entry.getKey()).append("=").append(entry.getValue()).append(" "); + } + sb.append('\n'); + } + pw.print(sb.toString()); + } + + private static String reasonToString(@StartReason int reason) { + return switch (reason) { + case START_REASON_ALARM -> "ALARM"; + case START_REASON_BACKUP -> "BACKUP"; + case START_REASON_BOOT_COMPLETE -> "BOOT COMPLETE"; + case START_REASON_BROADCAST -> "BROADCAST"; + case START_REASON_CONTENT_PROVIDER -> "CONTENT PROVIDER"; + case START_REASON_JOB -> "JOB"; + case START_REASON_LAUNCHER -> "LAUNCHER"; + case START_REASON_LAUNCHER_RECENTS -> "LAUNCHER RECENTS"; + case START_REASON_OTHER -> "OTHER"; + case START_REASON_PUSH -> "PUSH"; + case START_REASON_SERVICE -> "SERVICE"; + case START_REASON_START_ACTIVITY -> "START ACTIVITY"; + default -> ""; + }; + } + + private static String startTypeToString(@StartType int startType) { + return switch (startType) { + case START_TYPE_COLD -> "COLD"; + case START_TYPE_WARM -> "WARM"; + case START_TYPE_HOT -> "HOT"; + default -> ""; + }; + } } diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index a8b1688cc43b..03baf2671314 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -724,7 +724,20 @@ interface IActivityManager { * * @param userId The userId in the multi-user environment. */ - void removeApplicationStartInfoCompleteListener(int userId); + void clearApplicationStartInfoCompleteListener(int userId); + + + /** + * Adds a timestamp of the moment called to the calling apps most recent + * {@link ApplicationStartInfo}. + * + * + * @param key Unique key for timestamp. + * @param timestampNs Clock monotonic time in nanoseconds of event to be + * recorded. + * @param userId The userId in the multi-user environment. + */ + void addStartInfoTimestamp(int key, long timestampNs, int userId); /** * Return a list of {@link ApplicationExitInfo} records. diff --git a/services/core/java/com/android/server/am/ActivityManagerConstants.java b/services/core/java/com/android/server/am/ActivityManagerConstants.java index 03e86914e121..bef53c7f31ee 100644 --- a/services/core/java/com/android/server/am/ActivityManagerConstants.java +++ b/services/core/java/com/android/server/am/ActivityManagerConstants.java @@ -287,10 +287,6 @@ final class ActivityManagerConstants extends ContentObserver { */ private static final String KEY_LOW_SWAP_THRESHOLD_PERCENT = "low_swap_threshold_percent"; - /** Default value for mFlagApplicationStartInfoEnabled. Defaults to false. */ - private static final String KEY_DEFAULT_APPLICATION_START_INFO_ENABLED = - "enable_app_start_info"; - /** * Default value for mFlagBackgroundActivityStartsEnabled if not explicitly set in * Settings.Global. This allows it to be set experimentally unless it has been @@ -596,9 +592,6 @@ final class ActivityManagerConstants extends ContentObserver { // Controlled by Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED volatile boolean mFlagActivityStartsLoggingEnabled; - // Indicates whether ApplicationStartInfo is enabled. - volatile boolean mFlagApplicationStartInfoEnabled; - // Indicates whether the background activity starts is enabled. // Controlled by Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED. // If not set explicitly the default is controlled by DeviceConfig. @@ -1070,9 +1063,6 @@ final class ActivityManagerConstants extends ContentObserver { case KEY_MAX_CACHED_PROCESSES: updateMaxCachedProcesses(); break; - case KEY_DEFAULT_APPLICATION_START_INFO_ENABLED: - updateApplicationStartInfoEnabled(); - break; case KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED: updateBackgroundActivityStarts(); break; @@ -1493,14 +1483,6 @@ final class ActivityManagerConstants extends ContentObserver { Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED, 1) == 1; } - private void updateApplicationStartInfoEnabled() { - mFlagApplicationStartInfoEnabled = - DeviceConfig.getBoolean( - DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, - KEY_DEFAULT_APPLICATION_START_INFO_ENABLED, - /*defaultValue*/ false); - } - private void updateBackgroundActivityStarts() { mFlagBackgroundActivityStartsEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, @@ -2125,10 +2107,6 @@ final class ActivityManagerConstants extends ContentObserver { pw.println(mFgToBgFgsGraceDuration); pw.print(" "); pw.print(KEY_FGS_START_FOREGROUND_TIMEOUT); pw.print("="); pw.println(mFgsStartForegroundTimeoutMs); - pw.print(" "); - pw.print(KEY_DEFAULT_APPLICATION_START_INFO_ENABLED); - pw.print("="); - pw.println(mFlagApplicationStartInfoEnabled); pw.print(" "); pw.print(KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED); pw.print("="); pw.println(mFlagBackgroundActivityStartsEnabled); pw.print(" "); pw.print(KEY_DEFAULT_BACKGROUND_FGS_STARTS_RESTRICTION_ENABLED); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 132d6a9d743f..a0fae26fcac1 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -9563,14 +9563,9 @@ public class ActivityManagerService extends IActivityManager.Stub return retList; } - /* @hide */ @Override public ParceledListSlice<ApplicationStartInfo> getHistoricalProcessStartReasons( String packageName, int maxNum, int userId) { - if (!mConstants.mFlagApplicationStartInfoEnabled) { - return new ParceledListSlice<ApplicationStartInfo>( - new ArrayList<ApplicationStartInfo>()); - } enforceNotIsolatedCaller("getHistoricalProcessStartReasons"); final ArrayList<ApplicationStartInfo> results = new ArrayList<ApplicationStartInfo>(); @@ -9579,24 +9574,28 @@ public class ActivityManagerService extends IActivityManager.Stub } - /* @hide */ @Override public void setApplicationStartInfoCompleteListener( IApplicationStartInfoCompleteListener listener, int userId) { - if (!mConstants.mFlagApplicationStartInfoEnabled) { - return; - } enforceNotIsolatedCaller("setApplicationStartInfoCompleteListener"); } - /* @hide */ @Override - public void removeApplicationStartInfoCompleteListener(int userId) { - if (!mConstants.mFlagApplicationStartInfoEnabled) { - return; + public void clearApplicationStartInfoCompleteListener(int userId) { + enforceNotIsolatedCaller("clearApplicationStartInfoCompleteListener"); + + // For the simplification, we don't support USER_ALL nor USER_CURRENT here. + if (userId == UserHandle.USER_ALL || userId == UserHandle.USER_CURRENT) { + throw new IllegalArgumentException("Unsupported userId"); } - enforceNotIsolatedCaller("removeApplicationStartInfoCompleteListener"); + + final int callingUid = Binder.getCallingUid(); + } + + @Override + public void addStartInfoTimestamp(int key, long timestampNs, int userId) { + enforceNotIsolatedCaller("addStartInfoTimestamp"); } @Override |