Apply WindowTestRunner to more WM tests

- Remove the manual locking inside test methods.
- Replace test thread with display thread for
  ActivityTaskManagerService, so it is closer to real case.
- Use null thread for ActivityManagerService so the modules
  outside WM won't be created, including:
    ActivityManagerConstants, ActiveServices, OomAdjuster,
    IntentFirewall, PendingIntentController

Bug: 140284973
Test: atest WmTests
Change-Id: I34dfd716fc1e16d034405a59d2a0f9beef0ffe36
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
index 70ed62a..a2c76be 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
@@ -34,15 +34,17 @@
 import androidx.test.filters.SmallTest;
 
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
 /**
  * Tests for the {@link TaskStack} class.
  *
  * Build/Install/Run:
- *  atest FrameworksServicesTests:TaskStackTests
+ *  atest WmTests:TaskStackTests
  */
 @SmallTest
 @Presubmit
+@RunWith(WindowTestRunner.class)
 public class TaskStackTests extends WindowTestsBase {
 
     @Test
@@ -176,13 +178,8 @@
     public void testStackOutset() {
         final TaskStack stack = createTaskStackOnDisplay(mDisplayContent);
         final int stackOutset = 10;
-        // Clear the handler and hold the lock for mock, to prevent multi-thread issue.
-        waitUntilHandlersIdle();
-        synchronized (mWm.mGlobalLock) {
-            spyOn(stack);
-
-            doReturn(stackOutset).when(stack).getStackOutset();
-        }
+        spyOn(stack);
+        doReturn(stackOutset).when(stack).getStackOutset();
 
         final Rect stackBounds = new Rect(200, 200, 800, 1000);
         // Update surface position and size by the given bounds.