am 04ff6961: Merge "Update TeleService callback and reduce update frequency." into klp-dev

* commit '04ff6961859dde76c64e1f14e95741d7c7956a51':
  Update TeleService callback and reduce update frequency.
diff --git a/common/src/com/android/services/telephony/common/Call.java b/common/src/com/android/services/telephony/common/Call.java
index d88e8fb..b2774ec 100644
--- a/common/src/com/android/services/telephony/common/Call.java
+++ b/common/src/com/android/services/telephony/common/Call.java
@@ -49,7 +49,7 @@
         public static final int DIALING = 5;        /* An outgoing call during dial phase */
         public static final int ONHOLD = 6;         /* An active phone call placed on hold */
         public static final int DISCONNECTED = 7;   /* State after a call disconnects */
-        public static final int CONFERENCED = 8;     /* Call part of a conference call */
+        public static final int CONFERENCED = 8;    /* Call part of a conference call */
 
         public static boolean isConnected(int state) {
             switch(state) {
diff --git a/common/src/com/android/services/telephony/common/ICallHandlerService.aidl b/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
index 4fbc8b8..0cbd9b9 100644
--- a/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
+++ b/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
@@ -31,10 +31,11 @@
 oneway interface ICallHandlerService {
 
     /**
+     * First call made when we are ready to start sending events to the service.
      * Hands a command interface to the CallHandlerService through which
      * the call monitor can control the phone calls.
      */
-    void setCallCommandService(ICallCommandService callCommandService);
+    void startCallService(ICallCommandService callCommandService);
 
     /**
      * Called when there is an incoming call.
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index 82c56a5..3c7b517 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -402,7 +402,7 @@
      */
     private void makeInitialServiceCalls() {
         try {
-            mCallHandlerServiceGuarded.setCallCommandService(mCallCommandService);
+            mCallHandlerServiceGuarded.startCallService(mCallCommandService);
 
             onSupportedAudioModeChange(mAudioRouter.getSupportedAudioModes());
             onAudioModeChange(mAudioRouter.getAudioMode(), mAudioRouter.getMute());
diff --git a/src/com/android/phone/CallModeler.java b/src/com/android/phone/CallModeler.java
index 8848f73..79e77f6 100644
--- a/src/com/android/phone/CallModeler.java
+++ b/src/com/android/phone/CallModeler.java
@@ -301,18 +301,18 @@
         for (com.android.internal.telephony.Call telephonyCall : telephonyCalls) {
 
             for (Connection connection : telephonyCall.getConnections()) {
-                // We do not create incoming or disconnected calls on update.  Those are created
-                // from the associated onNewRingingConnection and onDisconnected which do this
-                // process on their own and slightly differently.
-                boolean create = connection.getState().isAlive() &&
+                // We only send updates for live calls which are not incoming (ringing).
+                // Disconnected and incoming calls are handled by onDisconnect and
+                // onNewRingingConnection.
+                boolean shouldUpdate = connection.getState().isAlive() &&
                         !connection.getState().isRinging();
 
                 // New connections return a Call with INVALID state, which does not translate to
                 // a state in the internal.telephony.Call object.  This ensures that staleness
                 // check below fails and we always add the item to the update list if it is new.
-                final Call call = getCallFromMap(mCallMap, connection, create);
+                final Call call = getCallFromMap(mCallMap, connection, shouldUpdate /* create */);
 
-                if (call == null) {
+                if (call == null || !shouldUpdate) {
                     continue;
                 }