Checks voicemail setting before notifying InCallUi

- Changes the CallerInfoAsyncQuery cookie to the Connection instead of
  the CallNotifier instance.

Bug: 10458113
Change-Id: I78043851a6fb1b1ccaceb431164b55eabab63f40
diff --git a/src/com/android/phone/CallModeler.java b/src/com/android/phone/CallModeler.java
index 7af2416..f53e788 100644
--- a/src/com/android/phone/CallModeler.java
+++ b/src/com/android/phone/CallModeler.java
@@ -110,7 +110,9 @@
     public void handleMessage(Message msg) {
         switch(msg.what) {
             case CallStateMonitor.PHONE_NEW_RINGING_CONNECTION:
-                onNewRingingConnection((Connection) ((AsyncResult) msg.obj).result);
+                // We let the CallNotifier handle the new ringing connection first. When the custom
+                // ringtone and send_to_voicemail settings are retrieved, CallNotifier will directly
+                // call CallModeler's onNewRingingConnection.
                 break;
             case CallStateMonitor.PHONE_DISCONNECT:
                 onDisconnect((Connection) ((AsyncResult) msg.obj).result);
@@ -282,15 +284,15 @@
         }
     }
 
-    private Call onNewRingingConnection(Connection conn) {
+    /* package */ Call onNewRingingConnection(Connection conn) {
         Log.i(TAG, "onNewRingingConnection");
         final Call call = getCallFromMap(mCallMap, conn, true);
 
-        updateCallFromConnection(call, conn, false);
+        if (call != null) {
+            updateCallFromConnection(call, conn, false);
 
-        for (int i = 0; i < mListeners.size(); ++i) {
-            if (call != null) {
-              mListeners.get(i).onIncoming(call);
+            for (int i = 0; i < mListeners.size(); ++i) {
+                mListeners.get(i).onIncoming(call);
             }
         }