Fix freeze wrong display when finishing activity

- The next activity after finishing should only consider in the
  same display.
- Make topRunningActivity goes through focusable stacks in a display
  instead of only uses top focused. Because it was used for legacy
  hierarchy that application tasks are put in a single stack.
- Update display configuration when a display becomes not containing
  running activity after finishing current activity to restore the
  original orientation.

Bug: 117861386
Test: atest ActivityStackTests#testFinishCurrentActivity
Test: atest ActivityDisplayTests#testTopRunningActivity
Change-Id: I15cafff01cf528681de64cd1b7da0547654e1103
6 files changed