Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e608e21b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Cleanup app start info flag" into main

parents 9df81ff8 9f6c29da
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -4791,8 +4791,8 @@ 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 @FlaggedApi("android.app.app_start_info") public void addApplicationStartInfoCompletionListener(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.ApplicationStartInfo>);
    method @FlaggedApi("android.app.app_start_info") 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 addApplicationStartInfoCompletionListener(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.ApplicationStartInfo>);
    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 boolean clearApplicationUserData();
    method public void clearWatchHeapLimit();
@@ -4801,7 +4801,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 @FlaggedApi("android.app.app_start_info") @NonNull public java.util.List<android.app.ApplicationStartInfo> getHistoricalProcessStartReasons(@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();
@@ -4828,7 +4828,7 @@ package android.app {
    method @RequiresPermission(android.Manifest.permission.KILL_BACKGROUND_PROCESSES) public void killBackgroundProcesses(String);
    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 @FlaggedApi("android.app.app_start_info") public void removeApplicationStartInfoCompletionListener(@NonNull java.util.function.Consumer<android.app.ApplicationStartInfo>);
    method public void removeApplicationStartInfoCompletionListener(@NonNull java.util.function.Consumer<android.app.ApplicationStartInfo>);
    method @Deprecated public void restartPackage(String);
    method public void setProcessStateSummary(@Nullable byte[]);
    method public static void setVrThread(int);
@@ -5422,7 +5422,7 @@ package android.app {
    field public static final int REASON_USER_STOPPED = 11; // 0xb
  }
  @FlaggedApi("android.app.app_start_info") public final class ApplicationStartInfo implements android.os.Parcelable {
  public final class ApplicationStartInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int getDefiningUid();
    method @Nullable public android.content.Intent getIntent();
+1 −1
Original line number Diff line number Diff line
@@ -623,7 +623,7 @@ package android.app {
    method @RequiresPermission(android.Manifest.permission.FORCE_STOP_PACKAGES) public void forceStopPackage(String);
    method @FlaggedApi("android.app.get_binding_uid_importance") @RequiresPermission(android.Manifest.permission.GET_BINDING_UID_IMPORTANCE) public int getBindingUidImportance(int);
    method @RequiresPermission(anyOf={"android.permission.INTERACT_ACROSS_USERS", "android.permission.INTERACT_ACROSS_USERS_FULL"}) public static int getCurrentUser();
    method @FlaggedApi("android.app.app_start_info") @NonNull @RequiresPermission(android.Manifest.permission.DUMP) public java.util.List<android.app.ApplicationStartInfo> getExternalHistoricalProcessStartReasons(@NonNull String, @IntRange(from=0) int);
    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);
+0 −5
Original line number Diff line number Diff line
@@ -4312,7 +4312,6 @@ public class ActivityManager {
     *         the order from most recent to least recent.
     */
    @NonNull
    @FlaggedApi(Flags.FLAG_APP_START_INFO)
    public List<ApplicationStartInfo> getHistoricalProcessStartReasons(
            @IntRange(from = 0) int maxNum) {
        try {
@@ -4346,7 +4345,6 @@ public class ActivityManager {
     */
    @NonNull
    @SystemApi
    @FlaggedApi(Flags.FLAG_APP_START_INFO)
    @RequiresPermission(Manifest.permission.DUMP)
    public List<ApplicationStartInfo> getExternalHistoricalProcessStartReasons(
            @NonNull String packageName, @IntRange(from = 0) int maxNum) {
@@ -4399,7 +4397,6 @@ public class ActivityManager {
     *
     * @throws IllegalArgumentException if executor or listener are null.
     */
    @FlaggedApi(Flags.FLAG_APP_START_INFO)
    public void addApplicationStartInfoCompletionListener(@NonNull final Executor executor,
            @NonNull final Consumer<ApplicationStartInfo> listener) {
        Preconditions.checkNotNull(executor, "executor cannot be null");
@@ -4450,7 +4447,6 @@ public class ActivityManager {
    /**
     * Removes the provided callback set by {@link #addApplicationStartInfoCompletionListener}.
     */
    @FlaggedApi(Flags.FLAG_APP_START_INFO)
    public void removeApplicationStartInfoCompletionListener(
            @NonNull final Consumer<ApplicationStartInfo> listener) {
        Preconditions.checkNotNull(listener, "listener cannot be null");
@@ -4490,7 +4486,6 @@ public class ActivityManager {
     *                    Will thow {@link java.lang.IllegalArgumentException} if not in range.
     * @param timestampNs Clock monotonic time in nanoseconds of event to be recorded.
     */
    @FlaggedApi(Flags.FLAG_APP_START_INFO)
    public void addStartInfoTimestamp(@IntRange(
            from = ApplicationStartInfo.START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START,
            to = ApplicationStartInfo.START_TIMESTAMP_RESERVED_RANGE_DEVELOPER) int key,
+0 −1
Original line number Diff line number Diff line
@@ -72,7 +72,6 @@ import java.util.Objects;
 *      if requested after the startup is complete.
 * </p>
 */
@FlaggedApi(Flags.FLAG_APP_START_INFO)
public final class ApplicationStartInfo implements Parcelable {

    /**
+0 −78
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NA
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ApplicationStartInfo;
import android.app.Flags;
import android.app.IApplicationStartInfoCompleteListener;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -117,8 +116,6 @@ public final class AppStartInfoTracker {

    @VisibleForTesting final Object mLock = new Object();

    @VisibleForTesting boolean mEnabled = false;

    /**
     * Monotonic clock which does not reset on reboot.
     *
@@ -219,11 +216,6 @@ public final class AppStartInfoTracker {
    }

    void onSystemReady() {
        mEnabled = Flags.appStartInfo();
        if (!mEnabled) {
            return;
        }

        registerForUserRemoval();
        registerForPackageRemoval();
        IoThread.getHandler().post(() -> {
@@ -300,9 +292,6 @@ public final class AppStartInfoTracker {
     */
    void onActivityIntentStarted(@NonNull Intent intent, long timestampNanos) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            ApplicationStartInfo start = new ApplicationStartInfo(getMonotonicTimeMs());
            start.setStartupState(ApplicationStartInfo.STARTUP_STATE_STARTED);
            start.setIntent(intent);
@@ -331,9 +320,6 @@ public final class AppStartInfoTracker {
     */
    void onActivityIntentFailed(long id) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            int index = mInProgressRecords.indexOfKey(id);
            if (index < 0) {
                return;
@@ -354,9 +340,6 @@ public final class AppStartInfoTracker {
     */
    void onActivityLaunched(long id, ComponentName name, long temperature, ProcessRecord app) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            int index = mInProgressRecords.indexOfKey(id);
            if (index < 0) {
                return;
@@ -385,9 +368,6 @@ public final class AppStartInfoTracker {
     */
    void onActivityLaunchCancelled(long id) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            int index = mInProgressRecords.indexOfKey(id);
            if (index < 0) {
                return;
@@ -409,9 +389,6 @@ public final class AppStartInfoTracker {
    void onActivityLaunchFinished(long id, ComponentName name, long timestampNanos,
            int launchMode) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            int index = mInProgressRecords.indexOfKey(id);
            if (index < 0) {
                return;
@@ -436,9 +413,6 @@ public final class AppStartInfoTracker {
    @Nullable
    ApplicationStartInfo onActivityReportFullyDrawn(long id, long timestampNanos) {
        synchronized (mLock) {
            if (!mEnabled) {
                return null;
            }
            int index = mInProgressRecords.indexOfKey(id);
            if (index < 0) {
                return null;
@@ -458,9 +432,6 @@ public final class AppStartInfoTracker {
    public void handleProcessServiceStart(long startTimeNs, ProcessRecord app,
                ServiceRecord serviceRecord) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            ApplicationStartInfo start = new ApplicationStartInfo(getMonotonicTimeMs());
            addBaseFieldsFromProcessRecord(start, app);
            start.setStartupState(ApplicationStartInfo.STARTUP_STATE_STARTED);
@@ -488,9 +459,6 @@ public final class AppStartInfoTracker {
    public void handleProcessBroadcastStart(long startTimeNs, ProcessRecord app, Intent intent,
                boolean isAlarm) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            ApplicationStartInfo start = new ApplicationStartInfo(getMonotonicTimeMs());
            addBaseFieldsFromProcessRecord(start, app);
            start.setStartupState(ApplicationStartInfo.STARTUP_STATE_STARTED);
@@ -515,9 +483,6 @@ public final class AppStartInfoTracker {
    /** Process a content provider triggered app start. */
    public void handleProcessContentProviderStart(long startTimeNs, ProcessRecord app) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            ApplicationStartInfo start = new ApplicationStartInfo(getMonotonicTimeMs());
            addBaseFieldsFromProcessRecord(start, app);
            start.setStartupState(ApplicationStartInfo.STARTUP_STATE_STARTED);
@@ -537,9 +502,6 @@ public final class AppStartInfoTracker {
    public void handleProcessBackupStart(long startTimeNs, ProcessRecord app,
                BackupRecord backupRecord, boolean cold) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            ApplicationStartInfo start = new ApplicationStartInfo(getMonotonicTimeMs());
            addBaseFieldsFromProcessRecord(start, app);
            start.setStartupState(ApplicationStartInfo.STARTUP_STATE_STARTED);
@@ -588,10 +550,6 @@ public final class AppStartInfoTracker {
     */
    void configureDetailedMonitoring(PrintWriter pw, String packageName, int userId) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }

            forEachPackageLocked((name, records) -> {
                for (int i = 0; i < records.size(); i++) {
                    records.valueAt(i).disableAppMonitoringMode();
@@ -621,9 +579,6 @@ public final class AppStartInfoTracker {
    }

    void addTimestampToStart(String packageName, int uid, long timeNs, int key) {
        if (!mEnabled) {
            return;
        }
        synchronized (mLock) {
            AppStartInfoContainer container = mData.get(packageName, uid);
            if (container == null) {
@@ -696,9 +651,6 @@ public final class AppStartInfoTracker {

    void getStartInfo(String packageName, int filterUid, int filterPid,
            int maxNum, ArrayList<ApplicationStartInfo> results) {
        if (!mEnabled) {
            return;
        }
        if (maxNum == 0) {
            maxNum = APP_START_INFO_HISTORY_LIST_SIZE;
        }
@@ -781,9 +733,6 @@ public final class AppStartInfoTracker {
    void addStartInfoCompleteListener(
            final IApplicationStartInfoCompleteListener listener, final int uid) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            ArrayList<ApplicationStartInfoCompleteCallback> callbacks = mCallbacks.get(uid);
            if (callbacks == null) {
                mCallbacks.set(uid,
@@ -797,9 +746,6 @@ public final class AppStartInfoTracker {
            final IApplicationStartInfoCompleteListener listener, final int uid,
            boolean unlinkDeathRecipient) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            final ArrayList<ApplicationStartInfoCompleteCallback> callbacks = mCallbacks.get(uid);
            if (callbacks == null) {
                return;
@@ -896,9 +842,6 @@ public final class AppStartInfoTracker {
    @VisibleForTesting
    void onUserRemoved(int userId) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            removeByUserIdLocked(userId);
            schedulePersistProcessStartInfo(true);
        }
@@ -906,9 +849,6 @@ public final class AppStartInfoTracker {

    @VisibleForTesting
    void onPackageRemoved(String packageName, int uid, boolean allUsers) {
        if (!mEnabled) {
            return;
        }
        if (packageName != null) {
            final boolean removeUid =
                    TextUtils.isEmpty(mService.mPackageManagerInt.getNameForUid(uid));
@@ -968,9 +908,6 @@ public final class AppStartInfoTracker {
     */
    @VisibleForTesting
    void loadExistingProcessStartInfo() {
        if (!mEnabled) {
            return;
        }
        if (!mProcStartInfoFile.canRead()) {
            // If file can't be read, mark complete so we can begin accepting new records.
            mAppStartInfoLoaded.set(true);
@@ -1060,9 +997,6 @@ public final class AppStartInfoTracker {
    /** Persist the existing {@link android.app.ApplicationStartInfo} records to storage. */
    @VisibleForTesting
    void persistProcessStartInfo() {
        if (!mEnabled) {
            return;
        }
        AtomicFile af = new AtomicFile(mProcStartInfoFile);
        FileOutputStream out = null;
        boolean succeeded;
@@ -1127,9 +1061,6 @@ public final class AppStartInfoTracker {
    @VisibleForTesting
    void schedulePersistProcessStartInfo(boolean immediately) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            if (mAppStartInfoPersistTask == null || immediately) {
                if (mAppStartInfoPersistTask != null) {
                    IoThread.getHandler().removeCallbacks(mAppStartInfoPersistTask);
@@ -1147,9 +1078,6 @@ public final class AppStartInfoTracker {
    @VisibleForTesting
    void clearProcessStartInfo(boolean removeFile) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
            }
            if (mAppStartInfoPersistTask != null) {
                IoThread.getHandler().removeCallbacks(mAppStartInfoPersistTask);
                mAppStartInfoPersistTask = null;
@@ -1167,9 +1095,6 @@ public final class AppStartInfoTracker {
     * > adb shell dumpsys activity clear-start-info [package-name]
     */
    void clearHistoryProcessStartInfo(String packageName, int userId) {
        if (!mEnabled) {
            return;
        }
        Optional<Integer> appId = Optional.empty();
        if (TextUtils.isEmpty(packageName)) {
            synchronized (mLock) {
@@ -1192,9 +1117,6 @@ public final class AppStartInfoTracker {
     * > adb shell dumpsys activity start-info [package-name]
     */
    void dumpHistoryProcessStartInfo(PrintWriter pw, String packageName) {
        if (!mEnabled) {
            return;
        }
        pw.println("ACTIVITY MANAGER LRU PROCESSES (dumpsys activity start-info)");
        SimpleDateFormat sdf = new SimpleDateFormat();
        synchronized (mLock) {
Loading