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

Commit cf235049 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

[DO NOT MERGE] AM: Use ActivityMetricsLogger to get app launch times

- Make ActivityMetricsLogger the single source of truth for activity metrics and
use it to provide data for Tron, logcat, event logs and {@link android.app.WaitResult}
- Remove LaunchTimeTracker
- Remove workaround added for b/80084651
- Remove thisTime from WaitResult and logs
- Remove am_activity_fully_drawn_time EventLog Tag
- Update WaitResult parsing logic in AppLaunch
- Discard metrics if a launching activity is already visible.
- original bug: 67683350

Compatibility Changes:
- thisTime removed from logcat and eventlog. Only totalTime will be displayed.
- Change in activity visiblity during launch will invalidate totalTime. am start -w
  will only report WaitTime in this case.
- am_activity_fully_drawn_time is removed from event log.

Bug: 117235762
Test: atest  google/perf/app-startup/third-party-apps/cold-dropcache-stable-test -v
Test: manual tests
Test: check applaunch.txt matches test run

Change-Id: Ib033594b961be9227256eba2a519dd6c2e3db573
(cherry picked from commit 132ee838)
(cherry picked from commit 017cddcb)
(cherry picked from commit f8accc5b)
(cherry picked from commit af0ea315)
parent 7098d462
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -28,10 +28,10 @@ import java.io.PrintWriter;
 * @hide
 * @hide
 */
 */
public class WaitResult implements Parcelable {
public class WaitResult implements Parcelable {
    public static final int INVALID_DELAY = -1;
    public int result;
    public int result;
    public boolean timeout;
    public boolean timeout;
    public ComponentName who;
    public ComponentName who;
    public long thisTime;
    public long totalTime;
    public long totalTime;


    public WaitResult() {
    public WaitResult() {
@@ -47,7 +47,6 @@ public class WaitResult implements Parcelable {
        dest.writeInt(result);
        dest.writeInt(result);
        dest.writeInt(timeout ? 1 : 0);
        dest.writeInt(timeout ? 1 : 0);
        ComponentName.writeToParcel(who, dest);
        ComponentName.writeToParcel(who, dest);
        dest.writeLong(thisTime);
        dest.writeLong(totalTime);
        dest.writeLong(totalTime);
    }
    }


@@ -68,7 +67,6 @@ public class WaitResult implements Parcelable {
        result = source.readInt();
        result = source.readInt();
        timeout = source.readInt() != 0;
        timeout = source.readInt() != 0;
        who = ComponentName.readFromParcel(source);
        who = ComponentName.readFromParcel(source);
        thisTime = source.readLong();
        totalTime = source.readLong();
        totalTime = source.readLong();
    }
    }


@@ -77,7 +75,6 @@ public class WaitResult implements Parcelable {
        pw.println(prefix + "  result=" + result);
        pw.println(prefix + "  result=" + result);
        pw.println(prefix + "  timeout=" + timeout);
        pw.println(prefix + "  timeout=" + timeout);
        pw.println(prefix + "  who=" + who);
        pw.println(prefix + "  who=" + who);
        pw.println(prefix + "  thisTime=" + thisTime);
        pw.println(prefix + "  totalTime=" + totalTime);
        pw.println(prefix + "  totalTime=" + totalTime);
    }
    }
}
}
 No newline at end of file
+0 −13
Original line number Original line Diff line number Diff line
@@ -5895,7 +5895,6 @@ public class ActivityManagerService extends IActivityManager.Stub
    private final void handleAppDiedLocked(ProcessRecord app,
    private final void handleAppDiedLocked(ProcessRecord app,
            boolean restarting, boolean allowRestart) {
            boolean restarting, boolean allowRestart) {
        int pid = app.pid;
        int pid = app.pid;
        final boolean clearLaunchStartTime = !restarting && app.removed && app.foregroundActivities;
        boolean kept = cleanUpApplicationRecordLocked(app, restarting, allowRestart, -1,
        boolean kept = cleanUpApplicationRecordLocked(app, restarting, allowRestart, -1,
                false /*replacingPid*/);
                false /*replacingPid*/);
        if (!kept && !restarting) {
        if (!kept && !restarting) {
@@ -5937,18 +5936,6 @@ public class ActivityManagerService extends IActivityManager.Stub
            mWindowManager.continueSurfaceLayout();
            mWindowManager.continueSurfaceLayout();
        }
        }
        // Hack for pi
        // When an app process is removed, activities from the process may be relaunched. In the
        // case of forceStopPackageLocked the activities are finished before any window is drawn,
        // and the launch time is not cleared. This will be incorrectly used to calculate launch
        // time for the next launched activity launched in the same windowing mode.
        if (clearLaunchStartTime) {
            final LaunchTimeTracker.Entry entry = mStackSupervisor
                    .getLaunchTimeTracker().getEntry(mStackSupervisor.getWindowingMode());
            if (entry != null) {
                entry.mLaunchStartTime = 0;
            }
        }
    }
    }
    private final int getLRURecordIndexForAppLocked(IApplicationThread thread) {
    private final int getLRURecordIndexForAppLocked(IApplicationThread thread) {
+0 −3
Original line number Original line Diff line number Diff line
@@ -558,9 +558,6 @@ final class ActivityManagerShellCommand extends ShellCommand {
                if (result.who != null) {
                if (result.who != null) {
                    pw.println("Activity: " + result.who.flattenToShortString());
                    pw.println("Activity: " + result.who.flattenToShortString());
                }
                }
                if (result.thisTime >= 0) {
                    pw.println("ThisTime: " + result.thisTime);
                }
                if (result.totalTime >= 0) {
                if (result.totalTime >= 0) {
                    pw.println("TotalTime: " + result.totalTime);
                    pw.println("TotalTime: " + result.totalTime);
                }
                }
+173 −43

File changed.

Preview size limit exceeded, changes collapsed.

+12 −93

File changed.

Preview size limit exceeded, changes collapsed.

Loading