Remove unknown visibility record when finishing activity

In AR#isSyncFinished, isVisibilityUnknown has a higher priority
than isVisibleRequested. If the unknown record is not cleared, the
transition may wait for an actual invisible activity.

An example could be launching activities from keyguard with several
activity embedded operations (so the transition may not be ready
directly by starting window). A launching activity is set to
invisible before keyguardGoingAway is called. And then the activity
requests to finish, that may cause it to remain in unknown visibility
record. And because activity won't be stopped/destroyed until
transition is finished, the transition will time out.

Previously, finishing -> invisible can be handled, but invisible
-> finishing is not. So now always remove the unknown visibility
record when the state changes to finishing or stopped.

Bug: 305200092
Test: atest UnknownAppVisibilityControllerTest# \
      testRemoveFinishingInvisibleActivityFromUnknown
Change-Id: I221c72194e80eb26ac0f994904799e98f5354931
4 files changed