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

Commit 39232091 authored by Chilun's avatar Chilun Committed by Chilun Huang
Browse files

Allow home app being instrumented while starting home from PhoneWindowManager

The Launcher tests about home key will go througth PhoneWindowManager
and call to RootActivityContainer#startHomeOnDisplay().
The original startHomeOnDisplay() calls canStartHomeOnDisplay() with
allowInstrumenting=false and causes the tests fail.

This patch allow home app being instrumented while staring home from
PhoneWindowManager.

Bug: 129073085
Test: adb shell am instrument -w -r -e debug false -e log false -e class com.android.quickstep.TaplTestsQuickstep#testOverview com.google.android.apps.nexuslauncher.tests/androidx.test.runner.AndroidJUnitRunner
Change-Id: If6e2c748bed034866b3d4c3e40554c34373a333c
parent f76cdad4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5126,7 +5126,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        // Start home.
        mActivityTaskManagerInternal.startHomeOnDisplay(mCurrentUserId, "startDockOrHome",
                displayId, fromHomeKey);
                displayId, true /* allowInstrumenting */, fromHomeKey);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -364,7 +364,7 @@ public abstract class ActivityTaskManagerInternal {
     *  - Use the secondary home defined in the config.
     */
    public abstract boolean startHomeOnDisplay(int userId, String reason, int displayId,
            boolean fromHomeKey);
            boolean allowInstrumenting, boolean fromHomeKey);
    /** Start home activities on all displays that support system decorations. */
    public abstract boolean startHomeOnAllDisplays(int userId, String reason);
    /** @return true if the given process is the factory test process. */
+2 −2
Original line number Diff line number Diff line
@@ -6492,10 +6492,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

        @Override
        public boolean startHomeOnDisplay(int userId, String reason, int displayId,
                boolean fromHomeKey) {
                boolean allowInstrumenting, boolean fromHomeKey) {
            synchronized (mGlobalLock) {
                return mRootActivityContainer.startHomeOnDisplay(userId, reason, displayId,
                        fromHomeKey);
                        allowInstrumenting, fromHomeKey);
            }
        }

+5 −3
Original line number Diff line number Diff line
@@ -347,7 +347,8 @@ class RootActivityContainer extends ConfigurationContainer
    }

    boolean startHomeOnDisplay(int userId, String reason, int displayId) {
        return startHomeOnDisplay(userId, reason, displayId, false /*fromHomeKey*/);
        return startHomeOnDisplay(userId, reason, displayId, false /* allowInstrumenting */,
                false /* fromHomeKey */);
    }

    /**
@@ -361,7 +362,8 @@ class RootActivityContainer extends ConfigurationContainer
     *    If there are multiple activities matched, use first one.
     *  - Use the secondary home defined in the config.
     */
    boolean startHomeOnDisplay(int userId, String reason, int displayId, boolean fromHomeKey) {
    boolean startHomeOnDisplay(int userId, String reason, int displayId, boolean allowInstrumenting,
            boolean fromHomeKey) {
        // Fallback to top focused display if the displayId is invalid.
        if (displayId == INVALID_DISPLAY) {
            displayId = getTopDisplayFocusedStack().mDisplayId;
@@ -383,7 +385,7 @@ class RootActivityContainer extends ConfigurationContainer
            return false;
        }

        if (!canStartHomeOnDisplay(aInfo, displayId, false /* allowInstrumenting */)) {
        if (!canStartHomeOnDisplay(aInfo, displayId, allowInstrumenting)) {
            return false;
        }