Handle child number changes after the call starts.

The child number display functionality assumed that the child number for
a call would only bet set at the start of the call.  This change removes
that assumption and supports changes to the child number at any point
during the call by adding a new listener to the InCall Call List.  It
appears there are some instances in reality where the child number can
come in after the start of a call (delayed only slightly, but enough to
prevent the number from showing up).

Bug: 24585039
Change-Id: I23148e8c4265f1bc16ce563f2919e9b3eb71784f
diff --git a/src/com/android/incallui/AnswerPresenter.java b/src/com/android/incallui/AnswerPresenter.java
index fc75bf0..97f60c0 100644
--- a/src/com/android/incallui/AnswerPresenter.java
+++ b/src/com/android/incallui/AnswerPresenter.java
@@ -113,6 +113,11 @@
         // no-op
     }
 
+    @Override
+    public void onChildNumberChange() {
+        // no-op
+    }
+
     private boolean isVideoUpgradePending(Call call) {
         return call.getSessionModificationState()
                 == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST;
diff --git a/src/com/android/incallui/Call.java b/src/com/android/incallui/Call.java
index 01205ff..16a53b2 100644
--- a/src/com/android/incallui/Call.java
+++ b/src/com/android/incallui/Call.java
@@ -334,12 +334,13 @@
 
         Bundle callExtras = mTelecommCall.getDetails().getExtras();
         if (callExtras != null) {
-            // Child address arrives when the call is first set up, so we do not need to notify the
-            // UI of this.
+            // Check for a change in the child address and notify any listeners.
             if (callExtras.containsKey(Connection.EXTRA_CHILD_ADDRESS)) {
                 String childNumber = callExtras.getString(Connection.EXTRA_CHILD_ADDRESS);
+
                 if (!Objects.equals(childNumber, mChildNumber)) {
                     mChildNumber = childNumber;
+                    CallList.getInstance().onChildNumberChange(this);
                 }
             }
 
diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index 0cc5da1..f0193c4 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/src/com/android/incallui/CallCardPresenter.java
@@ -347,6 +347,19 @@
         updatePrimaryDisplayInfo();
     }
 
+    /**
+     * Handles a change to the child number by refreshing the primary call info.
+     */
+    @Override
+    public void onChildNumberChange() {
+        Log.v(this, "onChildNumberChange");
+
+        if (mPrimary == null) {
+            return;
+        }
+        updatePrimaryDisplayInfo();
+    }
+
     private String getSubscriptionNumber() {
         // If it's an emergency call, and they're not populating the callback number,
         // then try to fall back to the phone sub info (to hopefully get the SIM's
diff --git a/src/com/android/incallui/CallList.java b/src/com/android/incallui/CallList.java
index 666ba95..11b5914 100644
--- a/src/com/android/incallui/CallList.java
+++ b/src/com/android/incallui/CallList.java
@@ -176,6 +176,21 @@
         }
     }
 
+    /**
+     * Called when the child number changes for a call.  The child number can be received after a
+     * call is initially set up, so we need to be able to inform listeners of the change.
+     *
+     * @param call The call.
+     */
+    public void onChildNumberChange(Call call) {
+        final List<CallUpdateListener> listeners = mCallUpdateListenerMap.get(call.getId());
+        if (listeners != null) {
+            for (CallUpdateListener listener : listeners) {
+                listener.onChildNumberChange();
+            }
+        }
+    }
+
     public void notifyCallUpdateListeners(Call call) {
         final List<CallUpdateListener> listeners = mCallUpdateListenerMap.get(call.getId());
         if (listeners != null) {
@@ -632,5 +647,10 @@
          * Notifies of a change to the last forwarded number for a call.
          */
         public void onLastForwardedNumberChange();
+
+        /**
+         * Notifies of a change to the child number for a call.
+         */
+        public void onChildNumberChange();
     }
 }
diff --git a/src/com/android/incallui/StatusBarNotifier.java b/src/com/android/incallui/StatusBarNotifier.java
index 3f862a2..a9b6ccc 100644
--- a/src/com/android/incallui/StatusBarNotifier.java
+++ b/src/com/android/incallui/StatusBarNotifier.java
@@ -654,4 +654,9 @@
     public void onLastForwardedNumberChange() {
         // no-op
     }
+
+    @Override
+    public void onChildNumberChange() {
+        // no-op
+    }
 }