Optimize traversal methods from DisplayArea

There are dozen of display areas won't contain activity or task.
So if a traversal method for task/activity is called on a display
or root, it can be skipped directly. This can save 200+ times to
go through the areas during an activity launch.

Also simplify AR#getDisplayId a bit: no need to use root task.
If the activity is detached, its task will be null. And if the
task is detached, its display will be null.

Bug: 159103089
Test: CtsWindowManagerDeviceTestCases
Change-Id: Iacd20f14bf8681d9ef156721d056bbe5e5a0c3c8
2 files changed