Fix displayId unsynced between app and system server.

If an activity is launched on non-default display and calls setVrModeEnabled
at onCreate stage, the server will move this task to default display. Then
ActivityThread.handleResumeActivity will crash because ViewRootImpl still
use the old display.

First, the launch activity process will create a ClientTransaction
object, with first transaction item is LaunchActivityItem, and lifecycle state
set as ResumeActivityItem. When client side starts to execute this
transaction, ensureActivityConfiguration will schedule MoveToDisplayItem
to another transaction, however, it cannot be execute before first transaction
completes.

We can resolve this problem by using the display ID associated with the
WindowToken for a Window (when available), this will always have the most
up-to-date value from the server.

Also re-sort imports.

bug: 72181603
bug: 112330955
Test: atest CtsActivityManagerDeviceTestCases
Test: atest CtsWindowManagerDeviceTestCases
Test: wm-smoke
Change-Id: I39a59cf3520a15b486e675284f9aed275343d3cf
2 files changed