Fix some exception occrued possible code

1.
When removeTask, task surface might be null so check null before
call migrateToNewSurfaceControl.
Refactor code in dispose too.

2.
onTaskInfoChanged callback might before onTaskAppeared or after
onTaskVanished in race condition then cause crash. Avoid it by
check TaskAppearedInfo is null or not in the list.

This is temp workaround and it should finally fixed in
TaskOrganizerController side.

Bug: 161803994
Bug: 174482124
Test: check app lunch, split screen, pip
Test: atest WMShellUnitTests
Test: atest WmTests:WindowOrganizerTests
Change-Id: Iec5ec516ed71589832366c2b61e91c8804139f6e
2 files changed