Fix OOM when running testAddRemoveRace

The test has been very likely to fail with OOM error or process crashes.
This is because we repeatedly creating ActivityRecord/ActivityStack/Task
in the test. Even though we release it after each run, the GC can still
throw OOM because of reference by mocking is not released while running
the test. After receiving several OOM's, the test process will crash.

To fix this issue, simply re-use the same ActivityRecord instead of
creating one per loop run. This works for this test as we only care
about the starting window handling inside ActivityRecord.

Test: atest AppWindowTokenTests#testAddRemoveRace
Bug: 130392471
Change-Id: I7df942d364ee07e179b05b6f837494c475197d7c
1 file changed