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

Commit aa388f69 authored by Louis Chang's avatar Louis Chang
Browse files

Avoid recursively starting home if it failed to launch

Home was started in a loop during test and the reason of the
initial launch failure was unable to track from the log.

Bug: 397603607
Test: wm presubmit
Flag: EXEMPT bugfix
Change-Id: I1641b922257779fb7066392f8cce1cda5af5ad07
parent afbdde0d
Loading
Loading
Loading
Loading
+27 −7
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.server.wm.ActivityStarter.DefaultFactory;
import com.android.server.wm.ActivityStarter.Factory;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
@@ -97,6 +98,9 @@ public class ActivityStartController {
    /** Whether an {@link ActivityStarter} is currently executing (starting an Activity). */
    private boolean mInExecution = false;

    /** The {@link TaskDisplayArea}s that are currently starting home activity. */
    private ArrayList<TaskDisplayArea> mHomeLaunchingTaskDisplayAreas = new ArrayList<>();

    /**
     * TODO(b/64750076): Capture information necessary for dump and
     * {@link #postStartActivityProcessingForLastStarter} rather than keeping the entire object
@@ -162,6 +166,11 @@ public class ActivityStartController {

    void startHomeActivity(Intent intent, ActivityInfo aInfo, String reason,
            TaskDisplayArea taskDisplayArea) {
        if (mHomeLaunchingTaskDisplayAreas.contains(taskDisplayArea)) {
            Slog.e(TAG, "Abort starting home on " + taskDisplayArea + " recursively.");
            return;
        }

        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);
        if (!ActivityRecord.isResolverActivity(aInfo.name)) {
@@ -186,6 +195,8 @@ public class ActivityStartController {
            mSupervisor.endDeferResume();
        }

        try {
            mHomeLaunchingTaskDisplayAreas.add(taskDisplayArea);
            mLastHomeActivityStartResult = obtainStarter(intent, "startHomeActivity: " + reason)
                    .setOutActivity(tmpOutRecord)
                    .setCallingUid(0)
@@ -193,6 +204,9 @@ public class ActivityStartController {
                    .setActivityOptions(options.toBundle(),
                            Binder.getCallingPid(), Binder.getCallingUid())
                    .execute();
        } finally {
            mHomeLaunchingTaskDisplayAreas.remove(taskDisplayArea);
        }
        mLastHomeActivityStartRecord = tmpOutRecord[0];
        if (rootHomeTask.mInResumeTopActivity) {
            // If we are in resume section already, home activity will be initialized, but not
@@ -720,6 +734,12 @@ public class ActivityStartController {
            }
        }

        if (!mHomeLaunchingTaskDisplayAreas.isEmpty()) {
            dumped = true;
            pw.print(prefix);
            pw.println("mHomeLaunchingTaskDisplayAreas:" + mHomeLaunchingTaskDisplayAreas);
        }

        if (!dumped) {
            pw.print(prefix);
            pw.println("(nothing)");