Fix CNAP Unknown on MT call issue
Wink Saville [Wed, 29 Jul 2009 17:04:21 +0000 (10:04 -0700)]
Fix a CNAP-related issue where receiving an MT call where the CNAP info
came as a phone update would not update the CallerInfo data correctly
and only display "Unknown" as CallerInfo on the InCallScreen.

src/com/android/phone/CallCard.java
src/com/android/phone/PhoneUtils.java

index 418cf40..893a3c4 100755 (executable)
@@ -501,6 +501,33 @@ public class CallCard extends FrameLayout
                     runQuery = mPhotoTracker.isDifferentImageRequest(conn);
                 }
 
+                // Adding a check to see if the update was caused due to a Phone number update
+                // or CNAP update. If so then we need to start a new query
+                if (phone.getPhoneName().equals("CDMA")) {
+                    Object obj = conn.getUserData();
+                    String updatedNumber = conn.getAddress();
+                    String updatedCnapName = conn.getCnapName();
+                    CallerInfo info = null;
+                    if (obj instanceof PhoneUtils.CallerInfoToken) {
+                        info = ((PhoneUtils.CallerInfoToken) o).currentInfo;
+                    } else if (o instanceof CallerInfo) {
+                        info = (CallerInfo) o;
+                    }
+
+                    if (info != null) {
+                        if (updatedNumber != null && !updatedNumber.equals(info.phoneNumber)) {
+                            if (DBG) log("- displayMainCallStatus: updatedNumber = "
+                                    + updatedNumber);
+                            runQuery = true;
+                        }
+                        if (updatedCnapName != null && !updatedCnapName.equals(info.cnapName)) {
+                            if (DBG) log("- displayMainCallStatus: updatedCnapName = "
+                                    + updatedCnapName);
+                            runQuery = true;
+                        }
+                    }
+                }
+
                 if (runQuery) {
                     if (DBG) log("- displayMainCallStatus: starting CallerInfo query...");
                     PhoneUtils.CallerInfoToken info =
index 067a3b3..9627d01 100755 (executable)
@@ -1088,11 +1088,33 @@ public class PhoneUtils {
                 if (DBG) log("startGetCallerInfo: query already running, adding listener: " +
                         listener.getClass().toString());
             } else {
-                if (DBG) log("startGetCallerInfo: No query to attach to, send trivial reply.");
-                if (cit.currentInfo == null) {
-                    cit.currentInfo = new CallerInfo();
+                // handling case where number/name gets updated later on by the network
+                String updatedNumber = c.getAddress();
+                if (DBG) log("startGetCallerInfo: updatedNumber = " + updatedNumber);
+                if (!TextUtils.isEmpty(updatedNumber)) {
+                    cit.currentInfo.phoneNumber = updatedNumber;
+
+                    // Store CNAP information retrieved from the Connection
+                    cit.currentInfo.cnapName =  c.getCnapName();
+                    // This can still get overwritten by ContactInfo
+                    cit.currentInfo.name = cit.currentInfo.cnapName;
+                    cit.currentInfo.numberPresentation = c.getNumberPresentation();
+                    cit.currentInfo.namePresentation = c.getCnapNamePresentation();
+
+                    if (DBG) log("startGetCallerInfo: CNAP Info from FW: name="
+                            + cit.currentInfo.cnapName
+                            + ", Name/Number Pres=" + cit.currentInfo.numberPresentation);
+                    cit.asyncQuery = CallerInfoAsyncQuery.startQuery(QUERY_TOKEN, context,
+                            updatedNumber, sCallerInfoQueryListener, c);
+                    cit.asyncQuery.addQueryListener(QUERY_TOKEN, listener, cookie);
+                    cit.isFinal = false;
+                } else {
+                    if (DBG) log("startGetCallerInfo: No query to attach to, send trivial reply.");
+                    if (cit.currentInfo == null) {
+                        cit.currentInfo = new CallerInfo();
+                    }
+                    cit.isFinal = true; // please see note on isFinal, above.
                 }
-                cit.isFinal = true; // please see note on isFinal, above.
             }
         } else {
             cit = new CallerInfoToken();