Refactoring to update stack in onResume.

This CL fixes a long-standing issue in which Recents is not updated
correctly if it is not completely hidden and shown.  In particular, it
would cause animation issues when launching into a non-fullscreen
activity or if the user quickly toggles between recent tasks.  It
contains several fixes:

- The visual state in Recents is no longer reset until the activity is 
  fully hidden (onStop() is called), and the task stack state is saved 
  allowing us to return to the same initial state.  When restarting the 
  activity, we propagate whether the activity was hidden down the view 
  hierarchy, so that each task can decide whether to reset itself.
- When the recents activity is started, we now merge the new stack with
  the current stack instead of replacing it completely.  This unifies
  the logic when dismissing multi-window while Recents is open, and this
  CL fixes an issue with the merging where onStackTaskAdded() was called
  before the stack was updated with the new task.  As a result of this
  change, we can just rebind the task views without having to return and
  pick them up from the view pool.
- This CL also fixes an issue with flashing when the screen turns off.  
  The activity onStop() can be called before the activity is fully 
  hidden, which would trigger a reset(), which would return all views to
  the pool.

Bug: 23815609
Bug: 25411120
Bug: 27186407
Change-Id: I83d74c947f9b47766d6778b7f5c421bb6df833e9
15 files changed