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

Commit 0513a940 authored by Louis Chang's avatar Louis Chang
Browse files

Fix reporting HOT launch state while required to restart process

We were reporting the launch state as HOT whenever brought a task
to top, even the process was gone. Now we check if the activity
is attached to its process to judge the launch state.

Bug: 126182006
Test: atest ActivityMetricsLoggerTests

Change-Id: I3dfc54ddf27732384c4a5425c321812667313b50
parent a7246835
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -492,7 +492,6 @@ final class ActivityManagerShellCommand extends ShellCommand {
            final long endTime = SystemClock.uptimeMillis();
            PrintWriter out = mWaitOption ? pw : getErrPrintWriter();
            boolean launched = false;
            boolean hotLaunch = false;
            switch (res) {
                case ActivityManager.START_SUCCESS:
                    launched = true;
@@ -518,8 +517,6 @@ final class ActivityManagerShellCommand extends ShellCommand {
                    break;
                case ActivityManager.START_TASK_TO_FRONT:
                    launched = true;
                    //TODO(b/120981435) remove special case
                    hotLaunch = true;
                    out.println(
                            "Warning: Activity not started, its current "
                                    + "task has been brought to the front");
@@ -567,9 +564,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
                    result.who = intent.getComponent();
                }
                pw.println("Status: " + (result.timeout ? "timeout" : "ok"));
                final @WaitResult.LaunchState int launchState =
                        hotLaunch ? WaitResult.LAUNCH_STATE_HOT : result.launchState;
                pw.println("LaunchState: " + launchStateToString(launchState));
                pw.println("LaunchState: " + launchStateToString(result.launchState));
                if (result.who != null) {
                    pw.println("Activity: " + result.who.flattenToShortString());
                }
+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import static android.app.ActivityManager.START_RETURN_INTENT_TO_CALLER;
import static android.app.ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.app.WaitResult.LAUNCH_STATE_COLD;
import static android.app.WaitResult.LAUNCH_STATE_HOT;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
@@ -1305,6 +1307,8 @@ class ActivityStarter {
                        break;
                    }
                    case START_TASK_TO_FRONT: {
                        outResult.launchState =
                                r.attachedToProcess() ? LAUNCH_STATE_HOT : LAUNCH_STATE_COLD;
                        // ActivityRecord may represent a different activity, but it should not be
                        // in the resumed state.
                        if (r.nowVisible && r.isState(RESUMED)) {