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
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
index b262a00..fc7646f 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
@@ -364,7 +364,7 @@
      *  - 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. */
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index c91ee8e..b8e6b0c 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -6492,10 +6492,10 @@
 
         @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);
             }
         }
 
diff --git a/services/core/java/com/android/server/wm/RootActivityContainer.java b/services/core/java/com/android/server/wm/RootActivityContainer.java
index 24cf7f1..46b5f3a 100644
--- a/services/core/java/com/android/server/wm/RootActivityContainer.java
+++ b/services/core/java/com/android/server/wm/RootActivityContainer.java
@@ -347,7 +347,8 @@
     }
 
     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 @@
      *    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 @@
             return false;
         }
 
-        if (!canStartHomeOnDisplay(aInfo, displayId, false /* allowInstrumenting */)) {
+        if (!canStartHomeOnDisplay(aInfo, displayId, allowInstrumenting)) {
             return false;
         }