Update AOSP Dialer source from internal google3 repository at
cl/152373142.

Test: make, treehugger

This CL updates the AOSP Dialer source with all the changes that have
gone into the private google3 repository. This includes all the
changes from cl/151342913 (3/27/2017) to cl/152373142 (4/06/2017).

This goal of these drops is to keep the AOSP source in sync with the
internal google3 repository. Currently these sync are done by hand
with very minor modifications to the internal source code.
See the Android.mk file for list of modifications.
Our current goal is to do frequent drops (daily if possible) and
eventually switched to an automated process.

Change-Id: I2fbc88cf6867b90ac8b65f75e5e34468988c7217
diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java
index db4d884..d3d8399 100644
--- a/java/com/android/incallui/InCallPresenter.java
+++ b/java/com/android/incallui/InCallPresenter.java
@@ -40,6 +40,7 @@
 import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener;
 import com.android.dialer.blocking.FilteredNumbersUtil;
 import com.android.dialer.common.LogUtil;
+import com.android.dialer.enrichedcall.EnrichedCallComponent;
 import com.android.dialer.logging.Logger;
 import com.android.dialer.logging.nano.InteractionEvent;
 import com.android.dialer.postcall.PostCall;
@@ -320,6 +321,9 @@
     mStatusBarNotifier = statusBarNotifier;
     mExternalCallNotifier = externalCallNotifier;
     addListener(mStatusBarNotifier);
+    EnrichedCallComponent.get(mContext)
+        .getEnrichedCallManager()
+        .registerStateChangedListener(mStatusBarNotifier);
 
     mProximitySensor = proximitySensor;
     addListener(mProximitySensor);
@@ -1003,7 +1007,10 @@
   void onActivityStarted() {
     Log.d(this, "onActivityStarted");
     notifyVideoPauseController(true);
-    mStatusBarNotifier.updateNotification(mCallList);
+    if (mStatusBarNotifier != null) {
+      // TODO - b/36649622: Investigate this redundant call
+      mStatusBarNotifier.updateNotification(mCallList);
+    }
   }
 
   /*package*/
@@ -1297,12 +1304,7 @@
     } else if (startIncomingCallSequence) {
       Log.i(this, "Start Full Screen in call UI");
 
-      if (!startUi()) {
-        // startUI refused to start the UI. This indicates that it needed to restart the
-        // activity.  When it finally restarts, it will call us back, so we do not actually
-        // change the state yet (we return mInCallState instead of newState).
-        return mInCallState;
-      }
+      mStatusBarNotifier.updateNotification(mCallList);
     } else if (newState == InCallState.NO_CALLS) {
       // The new state is the no calls state.  Tear everything down.
       attemptFinishActivity();
@@ -1339,18 +1341,6 @@
     }
   }
 
-  private boolean startUi() {
-    boolean isCallWaiting =
-        mCallList.getActiveCall() != null && mCallList.getIncomingCall() != null;
-
-    if (isCallWaiting) {
-      showInCall(false, false);
-    } else {
-      mStatusBarNotifier.updateNotification(mCallList);
-    }
-    return true;
-  }
-
   /**
    * @return {@code true} if the InCallPresenter is ready to be torn down, {@code false} otherwise.
    *     Calling classes should use this as an indication whether to interact with the
@@ -1387,7 +1377,11 @@
 
       if (mStatusBarNotifier != null) {
         removeListener(mStatusBarNotifier);
+        EnrichedCallComponent.get(mContext)
+            .getEnrichedCallManager()
+            .unregisterStateChangedListener(mStatusBarNotifier);
       }
+
       if (mExternalCallNotifier != null && mExternalCallList != null) {
         mExternalCallList.removeExternalCallListener(mExternalCallNotifier);
       }