Let app control insets during exiting PIP animation

Previously, ActivityRecord#canReceiveKeys excluded the task in PIP.
However, the PIP state of a task would only be cleared when the exiting
animation is done. There might be a display rotation change then, which
could impact the insets animation.

The life cycle of PIP can be devided into 4 states:
1. Entering PIP.
2. In PIP.
3. Exiting PIP.
4. Out of PIP.

The display rotation change can happen at the beginning of state 2 or 4.
This CL uses mWaitForEnteringPinnedMode to decide if an activity can
receive keys. We only reject keys in 1 and 2 now. (We rejected in 1, 2,
and 3 previously.) This makes the app controls insets at the beginning
of 1 and 3, which won't be affected by the display rotation.

With this change, the user now can send keys to the app which is playing
the transition from PIP mode to fullscreen mode.

Fix: 292983752
Test: atest PinnedStackTests
Test: Enter PIP mode from an immersive sticky landscape app in the
      3-button navigation mode, and then restore the app. See if
      navigation bar is moved to the right, not to the bottom.
Change-Id: Ia552250cfc858105f3d346e9996a36a09fe26ad8
2 files changed