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

Commit 36d58260 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Remove unused launch tick" into main

parents 87254782 b4d5f02e
Loading
Loading
Loading
Loading
+0 −57
Original line number Original line Diff line number Diff line
@@ -433,9 +433,6 @@ final class ActivityRecord extends WindowToken {
    // next activity.
    // next activity.
    private static final int PAUSE_TIMEOUT = 500;
    private static final int PAUSE_TIMEOUT = 500;


    // Ticks during which we check progress while waiting for an app to launch.
    private static final int LAUNCH_TICK = 500;

    // How long we wait for the activity to tell us it has stopped before
    // How long we wait for the activity to tell us it has stopped before
    // giving up.  This is a good amount of time because we really need this
    // giving up.  This is a good amount of time because we really need this
    // from the application in order to get its saved state. Once the stop
    // from the application in order to get its saved state. Once the stop
@@ -491,7 +488,6 @@ final class ActivityRecord extends WindowToken {
    long lastVisibleTime;         // last time this activity became visible
    long lastVisibleTime;         // last time this activity became visible
    long pauseTime;               // last time we started pausing the activity
    long pauseTime;               // last time we started pausing the activity
    long mStoppedTime;            // last time we completely stopped the activity
    long mStoppedTime;            // last time we completely stopped the activity
    long launchTickTime;          // base time for launch tick messages
    long topResumedStateLossTime; // last time we reported top resumed state loss to an activity
    long topResumedStateLossTime; // last time we reported top resumed state loss to an activity
    // Last configuration reported to the activity in the client process.
    // Last configuration reported to the activity in the client process.
    private final MergedConfiguration mLastReportedConfiguration;
    private final MergedConfiguration mLastReportedConfiguration;
@@ -940,24 +936,11 @@ final class ActivityRecord extends WindowToken {
                if (!hasProcess()) {
                if (!hasProcess()) {
                    return;
                    return;
                }
                }
                mAtmService.logAppTooSlow(app, pauseTime, "pausing " + ActivityRecord.this);
                activityPaused(true);
                activityPaused(true);
            }
            }
        }
        }
    };
    };


    private final Runnable mLaunchTickRunnable = new Runnable() {
        @Override
        public void run() {
            synchronized (mAtmService.mGlobalLock) {
                if (continueLaunchTicking()) {
                    mAtmService.logAppTooSlow(
                            app, launchTickTime, "launching " + ActivityRecord.this);
                }
            }
        }
    };

    private final Runnable mDestroyTimeoutRunnable = new Runnable() {
    private final Runnable mDestroyTimeoutRunnable = new Runnable() {
        @Override
        @Override
        public void run() {
        public void run() {
@@ -6334,7 +6317,6 @@ final class ActivityRecord extends WindowToken {
        removePauseTimeout();
        removePauseTimeout();
        removeStopTimeout();
        removeStopTimeout();
        removeDestroyTimeout();
        removeDestroyTimeout();
        finishLaunchTickingLocked();
    }
    }


    void stopIfPossible() {
    void stopIfPossible() {
@@ -6475,44 +6457,6 @@ final class ActivityRecord extends WindowToken {
        }
        }
    }
    }


    void startLaunchTickingLocked() {
        if (Build.IS_USER) {
            return;
        }
        if (launchTickTime == 0) {
            launchTickTime = SystemClock.uptimeMillis();
            continueLaunchTicking();
        }
    }

    private boolean continueLaunchTicking() {
        if (launchTickTime == 0) {
            return false;
        }

        final Task rootTask = getRootTask();
        if (rootTask == null) {
            return false;
        }

        rootTask.removeLaunchTickMessages();
        mAtmService.mH.postDelayed(mLaunchTickRunnable, LAUNCH_TICK);
        return true;
    }

    void removeLaunchTickRunnable() {
        mAtmService.mH.removeCallbacks(mLaunchTickRunnable);
    }

    void finishLaunchTickingLocked() {
        launchTickTime = 0;
        final Task rootTask = getRootTask();
        if (rootTask == null) {
            return;
        }
        rootTask.removeLaunchTickMessages();
    }

    void onFirstWindowDrawn(WindowState win) {
    void onFirstWindowDrawn(WindowState win) {
        firstWindowDrawn = true;
        firstWindowDrawn = true;
        // stop tracking
        // stop tracking
@@ -6600,7 +6544,6 @@ final class ActivityRecord extends WindowToken {
            mTaskSupervisor.reportActivityLaunched(false /* timeout */, this,
            mTaskSupervisor.reportActivityLaunched(false /* timeout */, this,
                    windowsDrawnDelayMs, launchState);
                    windowsDrawnDelayMs, launchState);
        }
        }
        finishLaunchTickingLocked();
        if (task != null) {
        if (task != null) {
            setTaskHasBeenVisible();
            setTaskHasBeenVisible();
        }
        }
+0 −65
Original line number Original line Diff line number Diff line
@@ -96,7 +96,6 @@ import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.Scr
import static com.android.server.am.EventLogTags.writeBootProgressEnableScreen;
import static com.android.server.am.EventLogTags.writeBootProgressEnableScreen;
import static com.android.server.am.EventLogTags.writeConfigurationChanged;
import static com.android.server.am.EventLogTags.writeConfigurationChanged;
import static com.android.server.am.StackTracesDumpHelper.ANR_TRACE_DIR;
import static com.android.server.am.StackTracesDumpHelper.ANR_TRACE_DIR;
import static com.android.server.am.StackTracesDumpHelper.dumpStackTraces;
import static com.android.server.wm.ActivityInterceptorCallback.MAINLINE_FIRST_ORDERED_ID;
import static com.android.server.wm.ActivityInterceptorCallback.MAINLINE_FIRST_ORDERED_ID;
import static com.android.server.wm.ActivityInterceptorCallback.MAINLINE_LAST_ORDERED_ID;
import static com.android.server.wm.ActivityInterceptorCallback.MAINLINE_LAST_ORDERED_ID;
import static com.android.server.wm.ActivityInterceptorCallback.SYSTEM_FIRST_ORDERED_ID;
import static com.android.server.wm.ActivityInterceptorCallback.SYSTEM_FIRST_ORDERED_ID;
@@ -199,7 +198,6 @@ import android.os.Binder;
import android.os.Build;
import android.os.Build;
import android.os.Bundle;
import android.os.Bundle;
import android.os.FactoryTest;
import android.os.FactoryTest;
import android.os.FileUtils;
import android.os.Handler;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
import android.os.IUserManager;
import android.os.IUserManager;
@@ -213,7 +211,6 @@ import android.os.Process;
import android.os.RemoteCallback;
import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.Trace;
@@ -227,7 +224,6 @@ import android.service.voice.IVoiceInteractionSession;
import android.service.voice.VoiceInteractionManagerInternal;
import android.service.voice.VoiceInteractionManagerInternal;
import android.sysprop.DisplayProperties;
import android.sysprop.DisplayProperties;
import android.telecom.TelecomManager;
import android.telecom.TelecomManager;
import android.text.format.TimeMigrationUtils;
import android.util.ArrayMap;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.ArraySet;
import android.util.IntArray;
import android.util.IntArray;
@@ -292,7 +288,6 @@ import com.android.wm.shell.Flags;
import java.io.BufferedReader;
import java.io.BufferedReader;
import java.io.File;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -310,7 +305,6 @@ import java.util.Collections;
import java.util.Date;
import java.util.Date;
import java.util.HashSet;
import java.util.HashSet;
import java.util.List;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map;
import java.util.Objects;
import java.util.Objects;
import java.util.Set;
import java.util.Set;
@@ -5790,65 +5784,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        mLastANRState = sw.toString();
        mLastANRState = sw.toString();
    }
    }


    void logAppTooSlow(WindowProcessController app, long startTime, String msg) {
        if (true || Build.IS_USER) {
            return;
        }

        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        StrictMode.allowThreadDiskWrites();
        try {
            File tracesDir = new File("/data/anr");
            File tracesFile = null;
            try {
                tracesFile = File.createTempFile("app_slow", null, tracesDir);

                StringBuilder sb = new StringBuilder();
                String timeString =
                        TimeMigrationUtils.formatMillisWithFixedFormat(System.currentTimeMillis());
                sb.append(timeString);
                sb.append(": ");
                TimeUtils.formatDuration(SystemClock.uptimeMillis() - startTime, sb);
                sb.append(" since ");
                sb.append(msg);
                FileOutputStream fos = new FileOutputStream(tracesFile);
                fos.write(sb.toString().getBytes());
                if (app == null) {
                    fos.write("\n*** No application process!".getBytes());
                }
                fos.close();
                FileUtils.setPermissions(tracesFile.getPath(), 0666, -1, -1); // -rw-rw-rw-
            } catch (IOException e) {
                Slog.w(TAG, "Unable to prepare slow app traces file: " + tracesFile, e);
                return;
            }

            if (app != null && app.getPid() > 0) {
                ArrayList<Integer> firstPids = new ArrayList<Integer>();
                firstPids.add(app.getPid());
                dumpStackTraces(tracesFile.getAbsolutePath(), firstPids, null, null, null, null);
            }

            File lastTracesFile = null;
            File curTracesFile = null;
            for (int i = 9; i >= 0; i--) {
                String name = String.format(Locale.US, "slow%02d.txt", i);
                curTracesFile = new File(tracesDir, name);
                if (curTracesFile.exists()) {
                    if (lastTracesFile != null) {
                        curTracesFile.renameTo(lastTracesFile);
                    } else {
                        curTracesFile.delete();
                    }
                }
                lastTracesFile = curTracesFile;
            }
            tracesFile.renameTo(curTracesFile);
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }
    }

    boolean isAssociatedCompanionApp(int userId, int uid) {
    boolean isAssociatedCompanionApp(int userId, int uid) {
        final Set<Integer> allUids = mCompanionAppUidsMap.get(userId);
        final Set<Integer> allUids = mCompanionAppUidsMap.get(userId);
        if (allUids == null) {
        if (allUids == null) {
+0 −7
Original line number Original line Diff line number Diff line
@@ -840,8 +840,6 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        proc.pauseConfigurationDispatch();
        proc.pauseConfigurationDispatch();


        try {
        try {
            // schedule launch ticks to collect information about slow apps.
            r.startLaunchTickingLocked();
            r.lastLaunchTime = SystemClock.uptimeMillis();
            r.lastLaunchTime = SystemClock.uptimeMillis();
            r.setProcess(proc);
            r.setProcess(proc);


@@ -1485,7 +1483,6 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
            if (DEBUG_IDLE) Slog.d(TAG_IDLE, "activityIdleInternal: Callers="
            if (DEBUG_IDLE) Slog.d(TAG_IDLE, "activityIdleInternal: Callers="
                    + Debug.getCallers(4));
                    + Debug.getCallers(4));
            mHandler.removeMessages(IDLE_TIMEOUT_MSG, r);
            mHandler.removeMessages(IDLE_TIMEOUT_MSG, r);
            r.finishLaunchTickingLocked();
            if (fromTimeout) {
            if (fromTimeout) {
                reportActivityLaunched(fromTimeout, r, INVALID_DELAY, -1 /* launchState */);
                reportActivityLaunched(fromTimeout, r, INVALID_DELAY, -1 /* launchState */);
            }
            }
@@ -2766,10 +2763,6 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
                case TOP_RESUMED_STATE_LOSS_TIMEOUT_MSG: {
                case TOP_RESUMED_STATE_LOSS_TIMEOUT_MSG: {
                    final ActivityRecord r = (ActivityRecord) msg.obj;
                    final ActivityRecord r = (ActivityRecord) msg.obj;
                    Slog.w(TAG, "Activity top resumed state loss timeout for " + r);
                    Slog.w(TAG, "Activity top resumed state loss timeout for " + r);
                    if (r.hasProcess()) {
                        mService.logAppTooSlow(r.app, r.topResumedStateLossTime,
                                "top state loss for " + r);
                    }
                    handleTopResumedStateReleased(true /* timeout */);
                    handleTopResumedStateReleased(true /* timeout */);
                } break;
                } break;
                default:
                default:
+0 −4
Original line number Original line Diff line number Diff line
@@ -5685,10 +5685,6 @@ class Task extends TaskFragment {
        return foundParentInTask;
        return foundParentInTask;
    }
    }


    void removeLaunchTickMessages() {
        forAllActivities(ActivityRecord::removeLaunchTickRunnable);
    }

    private void updateTransitLocked(@WindowManager.TransitionType int transit,
    private void updateTransitLocked(@WindowManager.TransitionType int transit,
            ActivityOptions options) {
            ActivityOptions options) {
        if (options != null) {
        if (options != null) {
+0 −3
Original line number Original line Diff line number Diff line
@@ -1718,9 +1718,6 @@ class TaskFragment extends WindowContainer<WindowContainer> {
                next.setVisibility(true);
                next.setVisibility(true);
            }
            }


            // schedule launch ticks to collect information about slow apps.
            next.startLaunchTickingLocked();

            ActivityRecord lastResumedActivity =
            ActivityRecord lastResumedActivity =
                    lastFocusedRootTask == null ? null
                    lastFocusedRootTask == null ? null
                            : lastFocusedRootTask.getTopResumedActivity();
                            : lastFocusedRootTask.getTopResumedActivity();