Wait for activity in test app to finish before force stop.

Wait for the RequestRoleActivity inside the test app to be removed
from our task so that when the test app is uninstalled, our task isn't
force finished and our WaitForResultActivity can survive.

RootWindowContainer force finishes all activities in a task if an
activity from a package being force stopped is found, but we are
actually finishing the offending activity right before uninstalling
the test app, so we just need to wait longer so that the activity is
removed from our task.

Fixes: 159572471
Bug: 143671173
Test: atest RoleManagerTest
Test: Observe that before this fix, WaitForResultActivity is force
      finished immediately when the test app is uninstalled/cleared
      data. The test only accidentally worked when
      WaitForResultActivity isn't GC'ed and the test is somehow
      capable to call startActivityForResult in a destroyed activity.
Test: Observe that after this fix, WaitForResultActivity stayed alive
      after the test app i uninstalled/cleared data, and is only force
      finished when the test is finished.
Change-Id: I1667a263a0cb9295eefc569e919419529822e763
1 file changed