Adopt upstream Mockito's solution to mem leak.

The upstream solution essentially disallows sharing mock between tests,
so the mock of PowerManagerWrapper is moved to SystemServicesTestRule so
that TestWindowManagerPolicy can use that to create window. It also
makes the life of PowerManagerWrapper mock the same as the
TestWindowManagerPolicy, which is used in both ActivityTestBase and
WindowTestBase but PowerManagerWrapper was only available in
WindowTestBase.

Also, Track mocks created in ActivityStarterTests#testStartActivityPreconditions
and clear them in the middle of execution because the memory usage could be
~0.8G just to run ActivityStarterTests only because of that.

Bug: 123984854
Test: "tradefed.sh run commandAndExit WmTests --include-annotation
android.platform.test.annotations.Presubmit --exclude-annotation
androidx.test.filters.FlakyTest" suffers from a lot fewer OOME.

Change-Id: I274d711fb52084d4c67547374360e373ad1e28d8
7 files changed