merge from donut
Jean-Baptiste Queru [Mon, 3 Aug 2009 14:45:47 +0000 (07:45 -0700)]
AndroidManifest.xml
src/com/android/phone/CallCard.java
src/com/android/phone/EriTextWidgetProvider.java [deleted file]
src/com/android/phone/PhoneApp.java
src/com/android/phone/PhoneUtils.java

index 1287b5d..c9ab4b9 100644 (file)
                 <action android:name="android.bluetooth.IBluetoothHeadset" />
             </intent-filter>
         </service>
-
-        <!-- Broadcast Receiver that will process cdma ERI text updates -->    
-        <receiver android:name="EriTextWidgetProvider" android:label="@string/eri_text_label">
-            <intent-filter>
-                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
-            </intent-filter>
-            <meta-data android:name="android.appwidget.provider" android:resource="@xml/eri_text_appwidget" />
-        </receiver>
     </application>
 </manifest>
 
index 418cf40..26c04f1 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 =
@@ -611,9 +638,12 @@ public class CallCard extends FrameLayout
             Connection conn = call.getEarliestConnection();
             PhoneUtils.CallerInfoToken cit =
                    PhoneUtils.startGetCallerInfo(getContext(), conn, this, null);
-            int presentation = conn.getNumberPresentation();
+
+            int presentation = Connection.PRESENTATION_ALLOWED;
+            if (conn != null) presentation = conn.getNumberPresentation();
             if (DBG) log("- onQueryComplete: presentation=" + presentation
                     + ", contactExists=" + ci.contactExists);
+
             // Depending on whether there was a contact match or not, we want to pass in different
             // CallerInfo (for CNAP). Therefore if ci.contactExists then use the ci passed in.
             // Otherwise, regenerate the CIT from the Connection and use the CallerInfo from there.
diff --git a/src/com/android/phone/EriTextWidgetProvider.java b/src/com/android/phone/EriTextWidgetProvider.java
deleted file mode 100644 (file)
index c44679c..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.phone;
-
-import android.app.PendingIntent;
-import android.app.Service;
-import android.appwidget.AppWidgetManager;
-import android.appwidget.AppWidgetProvider;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.os.IBinder;
-import android.telephony.TelephonyManager;
-import android.text.format.Time;
-import android.util.Log;
-import android.widget.RemoteViews;
-
-public class EriTextWidgetProvider extends AppWidgetProvider {
-    static final String LOG_TAG = "EriTextWidgetProvider";
-
-    static final ComponentName THIS_APPWIDGET =
-        new ComponentName("com.android.phone",
-                "com.android.phone.EriTextWidgetProvider");
-
-    private static EriTextWidgetProvider sInstance;
-
-    static synchronized EriTextWidgetProvider getInstance() {
-        if (sInstance == null) {
-            sInstance = new EriTextWidgetProvider();
-        }
-        return sInstance;
-    }
-
-    @Override
-    public void onEnabled(Context context) {
-        TelephonyManager mPhone;
-        String eriText = "ERI not init";
-
-        try {
-            mPhone = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
-            eriText = mPhone.getCdmaEriText();
-        } catch (Exception ex){
-            Log.e(LOG_TAG, "onEnabled, error setting Cdma Eri Text: " + ex);
-        }
-
-        if (eriText == null) eriText = "ERI not available";
-
-        performUpdate(context,eriText);
-    }
-
-    @Override
-    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
-        TelephonyManager mPhone;
-        String eriText = "ERI not init";
-
-        try {
-            mPhone = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
-            eriText = mPhone.getCdmaEriText();
-        } catch (Exception ex){
-            Log.e(LOG_TAG, "onEnabled, error setting Cdma Eri Text: " + ex);
-        }
-
-        if (eriText == null) eriText = "ERI not available";
-
-        performUpdate(context,eriText);
-    }
-
-    void performUpdate(Context context, String eriText) {
-        final Resources res = context.getResources();
-        final RemoteViews views = new RemoteViews(context.getPackageName(),
-            R.layout.eri_text_layout);
-
-        views.setTextViewText(R.id.message, eriText);
-
-        AppWidgetManager manager = AppWidgetManager.getInstance(context);
-        manager.updateAppWidget(THIS_APPWIDGET, views);
-
-    }
-}
-
index 5591da2..fc3d7f0 100755 (executable)
@@ -1169,6 +1169,13 @@ public class PhoneApp extends Application {
     }
 
     private void handleServiceStateChanged(Intent intent) {
+        /**
+         * This used to handle updating EriTextWidgetProvider this routine
+         * and and listening for ACTION_SERVICE_STATE_CHANGED intents could
+         * be removed. But leaving just in case it might be needed in the near
+         * future.
+         */
+
         // If service just returned, start sending out the queued messages
         ServiceState ss = ServiceState.newFromBundle(intent.getExtras());
 
@@ -1187,29 +1194,5 @@ public class PhoneApp extends Application {
         } else {
             hasService = false;
         }
-
-        if (ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_1xRTT
-                || ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_EVDO_0
-                || ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_EVDO_A
-                || ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_IS95A
-                || ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_IS95B) {
-            isCdma = true;
-        }
-
-        if (!isCdma) {
-            eriText = "";
-        } else {
-            if (!hasService) {
-                eriText = getText(com.android.internal.R.string.roamingTextSearching).toString();
-            } else {
-                eriText = phone.getCdmaEriText();
-            }
-        }
-
-        if (eriText != null) {
-            EriTextWidgetProvider mEriTextWidgetProvider = EriTextWidgetProvider.getInstance();
-            mEriTextWidgetProvider.performUpdate(this, eriText);
-        }
-
     }
 }
index e17f210..9627d01 100755 (executable)
@@ -16,6 +16,7 @@
 
 package com.android.phone;
 
+import android.app.ActivityManagerNative;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.KeyguardManager;
@@ -1087,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();
@@ -1276,7 +1299,10 @@ public class PhoneUtils {
 
         // Before bringing up the "incoming call" UI, force any system
         // dialogs (like "recent tasks" or the power dialog) to close first.
-        app.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
+        try {
+            ActivityManagerNative.getDefault().closeSystemDialogs("call");
+        } catch (RemoteException e) {
+        }
 
         // Go directly to the in-call screen.
         // (No need to do anything special if we're already on the in-call