Improve lifecycle ordering for InCallUI

This CL rearranges startup and teardown of InCallUI to reduce the number
of race conditions resulting in runtime exceptions and app crashes.

At a high level this CL fixes the following:
- TeleService should be able to unbind and rebind at any time without
causing problems in the UI. (Fixes to InCallPresenter)
   - On weird occasions we were seeing secondary UIs pop up if we
   rebound while the older UI was still up and one of the UIs would be
   orphaned on the foreground.
- call notifications can be sent during (1) activity startup, (2)
activity lifetime, (3) activity destruction, (4) no activity...and
nothing should crash.
   - Lots of crashes when notifications came during destruction and
   startup. (Fixed setup in InCallActivity + presenters, and
   startup/teardown ordering in InCallPresenter)

Details:
(1) InCallPresenter handed out instances of member classes to the UI
classes, but upon unbinding and rebinding, the classes were
recreated.  This meant that the activity which was potentially still up
had stale versions of AudioModeProvider and ProximitySensor.
 - Classes created/used by CallHandlerService are now singletons so that
   they do not change from one bind to the other. If the service tries
   to initialize InCallPresenter while the activity is still up (and so
   we haven't yet torn down) we reuse the reuse the previous
   initialization since there is no need to recreate them, and classes
   in the Activity dont ever become stale.
(2) We were recreating new copies of InCallActivity on updates that
occur while tearing down the previous activity.  This caused weird
errors where second emptier activities were up after all calls ended.
 - Solution to this was to ignore all updates while we are finishing the
   activity.  When the activity is finally finished, we check if we
   should bring up a new activity in case some update came while we were
   finishing.
(3) We set listeners on presenters from a parent class that wasn't aware
of UI transitions.
 - All Presenters are not responsible for setting and unsetting their
   listeners.  This allows them to unset them before their UI goes away.

+ renamed HIDDEN to NO_CALLS as hidden was confusing to developers
which associated the term with foreground/backgroundness of the app.
+ Improved some logging

bug:10573125

Change-Id: I2d1af6a6e972b3b3bd93af839054e879f0b74b4f
11 files changed
tree: 9ffb5c9a744cc5679c59091e617c00acc4209193
  1. InCallUI/