Merge change 26171 into eclair

* changes:
  Fix several CDMA call collision cases
diff --git a/cmds/keystore/Android.mk b/cmds/keystore/Android.mk
index 1b1bebd..15a199f 100644
--- a/cmds/keystore/Android.mk
+++ b/cmds/keystore/Android.mk
@@ -14,6 +14,8 @@
 # limitations under the License.
 #
 
+ifneq ($(TARGET_SIMULATOR),true)
+
 LOCAL_PATH:= $(call my-dir)
 
 include $(CLEAR_VARS)
@@ -30,3 +32,5 @@
 LOCAL_MODULE:= keystore_cli
 LOCAL_MODULE_TAGS := debug
 include $(BUILD_EXECUTABLE)
+
+endif
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 7859d5a..80613d8 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -514,7 +514,7 @@
     public SyncStorageEngine getSyncStorageEngine() {
         return mSyncStorageEngine;
     }
-    
+
     private void ensureAlarmService() {
         if (mAlarmService == null) {
             mAlarmService = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
@@ -1125,7 +1125,7 @@
         tobj.set(time);
         return tobj.format("%Y-%m-%d %H:%M:%S");
     }
-    
+
     protected void dumpSyncState(PrintWriter pw, StringBuilder sb) {
         pw.print("sync enabled: "); pw.println(isSyncEnabled());
         pw.print("data connected: "); pw.println(mDataConnectionIsConnected);
@@ -1219,13 +1219,13 @@
                         = mSyncStorageEngine.getAuthority(status.authorityId);
                 if (authority != null) {
                     Account curAccount = authority.account;
-                    
+
                     if (processedAccounts.contains(curAccount)) {
                         continue;
                     }
-                    
+
                     processedAccounts.add(curAccount);
-                    
+
                     pw.print("  Account "); pw.print(authority.account.name);
                             pw.print(" "); pw.print(authority.account.type);
                             pw.println(":");
@@ -1271,7 +1271,7 @@
         pw.print(time/1000); pw.print('.'); pw.print((time/100)%10);
         pw.print('s');
     }
-    
+
     private void dumpDayStatistic(PrintWriter pw, SyncStorageEngine.DayStats ds) {
         pw.print("Success ("); pw.print(ds.successCount);
         if (ds.successCount > 0) {
@@ -1285,7 +1285,7 @@
         }
         pw.println(")");
     }
-    
+
     protected void dumpSyncHistory(PrintWriter pw, StringBuilder sb) {
         SyncStorageEngine.DayStats dses[] = mSyncStorageEngine.getDayStatistics();
         if (dses != null && dses[0] != null) {
@@ -1295,18 +1295,18 @@
             int today = dses[0].day;
             int i;
             SyncStorageEngine.DayStats ds;
-            
+
             // Print each day in the current week.
             for (i=1; i<=6 && i < dses.length; i++) {
                 ds = dses[i];
                 if (ds == null) break;
                 int delta = today-ds.day;
                 if (delta > 6) break;
-                
+
                 pw.print("  Day-"); pw.print(delta); pw.print(":  ");
                 dumpDayStatistic(pw, ds);
             }
-            
+
             // Aggregate all following days into weeks and print totals.
             int weekDay = today;
             while (i < dses.length) {
@@ -1321,7 +1321,7 @@
                     int delta = weekDay-ds.day;
                     if (delta > 6) break;
                     i++;
-                    
+
                     if (aggr == null) {
                         aggr = new SyncStorageEngine.DayStats(weekDay);
                     }
@@ -1336,7 +1336,7 @@
                 }
             }
         }
-        
+
         ArrayList<SyncStorageEngine.SyncHistoryItem> items
                 = mSyncStorageEngine.getSyncHistory();
         if (items != null && items.size() > 0) {
@@ -2132,7 +2132,8 @@
             final long now = System.currentTimeMillis();
 
             EventLog.writeEvent(2720, syncOperation.authority,
-                    SyncStorageEngine.EVENT_START, source);
+                                SyncStorageEngine.EVENT_START, source,
+                                syncOperation.account.name.hashCode());
 
             return mSyncStorageEngine.insertStartSyncEvent(
                     syncOperation.account, syncOperation.authority, now, source);
@@ -2141,7 +2142,8 @@
         public void stopSyncEvent(long rowId, SyncOperation syncOperation, String resultMessage,
                 int upstreamActivity, int downstreamActivity, long elapsedTime) {
             EventLog.writeEvent(2720, syncOperation.authority,
-                    SyncStorageEngine.EVENT_STOP, syncOperation.syncSource);
+                                SyncStorageEngine.EVENT_STOP, syncOperation.syncSource,
+                                syncOperation.account.name.hashCode());
 
             mSyncStorageEngine.stopSyncEvent(rowId, elapsedTime, resultMessage,
                     downstreamActivity, upstreamActivity);
@@ -2173,7 +2175,7 @@
                 syncOperation.pendingOperation = op;
                 add(syncOperation, op);
             }
-            
+
             if (DEBUG_CHECK_DATA_CONSISTENCY) debugCheckDataStructures(true /* check the DB */);
         }
 
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 0e72aaf..90c6328 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -937,22 +937,22 @@
          */
         private interface CommonColumns extends BaseTypes{
             /**
-             * The type of data, for example Home or Work.
-             * <P>Type: INTEGER</P>
-             */
-            public static final String TYPE = "data1";
-
-            /**
              * The data for the contact method.
              * <P>Type: TEXT</P>
              */
-            public static final String DATA = "data2";
+            public static final String DATA = DataColumns.DATA1;
+
+            /**
+             * The type of data, for example Home or Work.
+             * <P>Type: INTEGER</P>
+             */
+            public static final String TYPE = DataColumns.DATA2;
 
             /**
              * The user defined label for the the contact method.
              * <P>Type: TEXT</P>
              */
-            public static final String LABEL = "data3";
+            public static final String LABEL = DataColumns.DATA3;
         }
 
         /**
@@ -965,60 +965,60 @@
             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
 
             /**
-             * The given name for the contact.
-             * <P>Type: TEXT</P>
-             */
-            public static final String GIVEN_NAME = "data1";
-
-            /**
-             * The family name for the contact.
-             * <P>Type: TEXT</P>
-             */
-            public static final String FAMILY_NAME = "data2";
-
-            /**
-             * The contact's honorific prefix, e.g. "Sir"
-             * <P>Type: TEXT</P>
-             */
-            public static final String PREFIX = "data3";
-
-            /**
-             * The contact's middle name
-             * <P>Type: TEXT</P>
-             */
-            public static final String MIDDLE_NAME = "data4";
-
-            /**
-             * The contact's honorific suffix, e.g. "Jr"
-             */
-            public static final String SUFFIX = "data5";
-
-            /**
-             * The phonetic version of the given name for the contact.
-             * <P>Type: TEXT</P>
-             */
-            public static final String PHONETIC_GIVEN_NAME = "data6";
-
-            /**
-             * The phonetic version of the additional name for the contact.
-             * <P>Type: TEXT</P>
-             */
-            public static final String PHONETIC_MIDDLE_NAME = "data7";
-
-            /**
-             * The phonetic version of the family name for the contact.
-             * <P>Type: TEXT</P>
-             */
-            public static final String PHONETIC_FAMILY_NAME = "data8";
-
-            /**
              * The name that should be used to display the contact.
              * <i>Unstructured component of the name should be consistent with
              * its structured representation.</i>
              * <p>
              * Type: TEXT
              */
-            public static final String DISPLAY_NAME = "data9";
+            public static final String DISPLAY_NAME = DATA1;
+
+            /**
+             * The given name for the contact.
+             * <P>Type: TEXT</P>
+             */
+            public static final String GIVEN_NAME = DATA2;
+
+            /**
+             * The family name for the contact.
+             * <P>Type: TEXT</P>
+             */
+            public static final String FAMILY_NAME = DATA3;
+
+            /**
+             * The contact's honorific prefix, e.g. "Sir"
+             * <P>Type: TEXT</P>
+             */
+            public static final String PREFIX = DATA4;
+
+            /**
+             * The contact's middle name
+             * <P>Type: TEXT</P>
+             */
+            public static final String MIDDLE_NAME = DATA5;
+
+            /**
+             * The contact's honorific suffix, e.g. "Jr"
+             */
+            public static final String SUFFIX = DATA6;
+
+            /**
+             * The phonetic version of the given name for the contact.
+             * <P>Type: TEXT</P>
+             */
+            public static final String PHONETIC_GIVEN_NAME = DATA7;
+
+            /**
+             * The phonetic version of the additional name for the contact.
+             * <P>Type: TEXT</P>
+             */
+            public static final String PHONETIC_MIDDLE_NAME = DATA8;
+
+            /**
+             * The phonetic version of the family name for the contact.
+             * <P>Type: TEXT</P>
+             */
+            public static final String PHONETIC_FAMILY_NAME = DATA9;
         }
 
         /**
@@ -1176,7 +1176,7 @@
              * The display name for the email address
              * <P>Type: TEXT</P>
              */
-            public static final String DISPLAY_NAME = "data4";
+            public static final String DISPLAY_NAME = DATA4;
         }
 
         /**
@@ -1221,7 +1221,7 @@
              * <p>
              * Type: TEXT
              */
-            public static final String STREET = "data6";
+            public static final String STREET = DATA4;
 
             /**
              * Covers actual P.O. boxes, drawers, locked bags, etc. This is
@@ -1229,7 +1229,7 @@
              * <p>
              * Type: TEXT
              */
-            public static final String POBOX = "data7";
+            public static final String POBOX = DATA5;
 
             /**
              * This is used to disambiguate a street address when a city
@@ -1239,7 +1239,7 @@
              * <p>
              * Type: TEXT
              */
-            public static final String NEIGHBORHOOD = "data8";
+            public static final String NEIGHBORHOOD = DATA6;
 
             /**
              * Can be city, village, town, borough, etc. This is the postal town
@@ -1247,7 +1247,7 @@
              * <p>
              * Type: TEXT
              */
-            public static final String CITY = "data9";
+            public static final String CITY = DATA7;
 
             /**
              * A state, province, county (in Ireland), Land (in Germany),
@@ -1255,7 +1255,7 @@
              * <p>
              * Type: TEXT
              */
-            public static final String REGION = "data11";
+            public static final String REGION = DATA8;
 
             /**
              * Postal code. Usually country-wide, but sometimes specific to the
@@ -1263,14 +1263,14 @@
              * <p>
              * Type: TEXT
              */
-            public static final String POSTCODE = "data12";
+            public static final String POSTCODE = DATA9;
 
             /**
              * The name or code of the country.
              * <p>
              * Type: TEXT
              */
-            public static final String COUNTRY = "data13";
+            public static final String COUNTRY = DATA10;
         }
 
         /**
@@ -1292,9 +1292,9 @@
              * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
              * should contain the name of the custom protocol.
              */
-            public static final String PROTOCOL = "data5";
+            public static final String PROTOCOL = DATA5;
 
-            public static final String CUSTOM_PROTOCOL = "data6";
+            public static final String CUSTOM_PROTOCOL = DATA6;
 
             /*
              * The predefined IM protocol types.
@@ -1333,31 +1333,31 @@
              * The position title at this company as the user entered it.
              * <P>Type: TEXT</P>
              */
-            public static final String TITLE = "data4";
+            public static final String TITLE = DATA4;
 
             /**
              * The department at this company as the user entered it.
              * <P>Type: TEXT</P>
              */
-            public static final String DEPARTMENT = "data5";
+            public static final String DEPARTMENT = DATA5;
 
             /**
              * The job description at this company as the user entered it.
              * <P>Type: TEXT</P>
              */
-            public static final String JOB_DESCRIPTION = "data6";
+            public static final String JOB_DESCRIPTION = DATA6;
 
             /**
              * The symbol of this company as the user entered it.
              * <P>Type: TEXT</P>
              */
-            public static final String SYMBOL = "data7";
+            public static final String SYMBOL = DATA7;
 
             /**
              * The phonetic name of this company as the user entered it.
              * <P>Type: TEXT</P>
              */
-            public static final String PHONETIC_NAME = "data8";
+            public static final String PHONETIC_NAME = DATA8;
         }
 
         /**
@@ -1373,13 +1373,13 @@
              * The birthday as the user entered it.
              * <P>Type: TEXT</P>
              */
-            public static final String BIRTHDAY = "data1";
+            public static final String BIRTHDAY = DATA1;
 
             /**
              * The nickname as the user entered it.
              * <P>Type: TEXT</P>
              */
-            public static final String NICKNAME = "data2";
+            public static final String NICKNAME = DATA2;
         }
 
         /**
@@ -1447,7 +1447,7 @@
              * <p>
              * Type: BLOB
              */
-            public static final String PHOTO = "data1";
+            public static final String PHOTO = DATA15;
         }
 
         /**
@@ -1463,7 +1463,7 @@
              * The note text.
              * <P>Type: TEXT</P>
              */
-            public static final String NOTE = "data1";
+            public static final String NOTE = DATA1;
         }
 
         /**
@@ -1481,7 +1481,7 @@
              * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
              * <P>Type: INTEGER</P>
              */
-            public static final String GROUP_ROW_ID = "data1";
+            public static final String GROUP_ROW_ID = DATA1;
 
             /**
              * The sourceid of the group that this group membership refers to.  Exactly one of
@@ -1512,7 +1512,7 @@
              * The website URL string.
              * <P>Type: TEXT</P>
              */
-            public static final String URL = "data1";
+            public static final String URL = DATA;
         }
     }
 
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 196bbd7..3c43fd15 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -17,6 +17,7 @@
 package android.webkit;
 
 import android.content.Context;
+import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.os.Build;
 import android.os.Handler;
@@ -193,12 +194,20 @@
     // with Google' and the browser.
     static GoogleLocationSettingManager sGoogleLocationSettingManager;
 
+    // private WebSettings, not accessible by the host activity
+    private int             mDoubleTapToastCount = 3;
+
+    private static final String PREF_FILE = "WebViewSettings";
+    private static final String DOUBLE_TAP_TOAST_COUNT = "double_tap_toast_count";
+
     // Class to handle messages before WebCore is ready.
     private class EventHandler {
         // Message id for syncing
         static final int SYNC = 0;
         // Message id for setting priority
         static final int PRIORITY = 1;
+        // Message id for writing double-tap toast count
+        static final int SET_DOUBLE_TAP_TOAST_COUNT = 2;
         // Actual WebCore thread handler
         private Handler mHandler;
 
@@ -224,6 +233,16 @@
                             setRenderPriority();
                             break;
                         }
+
+                        case SET_DOUBLE_TAP_TOAST_COUNT: {
+                            SharedPreferences.Editor editor = mContext
+                                    .getSharedPreferences(PREF_FILE,
+                                            Context.MODE_PRIVATE).edit();
+                            editor.putInt(DOUBLE_TAP_TOAST_COUNT,
+                                    mDoubleTapToastCount);
+                            editor.commit();
+                            break;
+                        }
                     }
                 }
             };
@@ -1311,6 +1330,19 @@
         }
      }
 
+    int getDoubleTapToastCount() {
+        return mDoubleTapToastCount;
+    }
+
+    void setDoubleTapToastCount(int count) {
+        if (mDoubleTapToastCount != count) {
+            mDoubleTapToastCount = count;
+            // write the settings in the non-UI thread
+            mEventHandler.sendMessage(Message.obtain(null,
+                    EventHandler.SET_DOUBLE_TAP_TOAST_COUNT));
+        }
+    }
+
     /**
      * Transfer messages from the queue to the new WebCoreThread. Called from
      * WebCore thread.
@@ -1323,6 +1355,10 @@
         }
         sGoogleLocationSettingManager = new GoogleLocationSettingManager(mContext);
         sGoogleLocationSettingManager.start();
+        SharedPreferences sp = mContext.getSharedPreferences(PREF_FILE,
+                Context.MODE_PRIVATE);
+        mDoubleTapToastCount = sp.getInt(DOUBLE_TAP_TOAST_COUNT,
+                mDoubleTapToastCount);
         nativeSync(frame.mNativeFrame);
         mSyncPending = false;
         mEventHandler.createHandler();
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index b378553..9101578 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2001,7 +2001,7 @@
         getGlobalVisibleRect(r, p);
         r.offset(-p.x, -p.y);
         if (mFindIsUp) {
-            r.bottom -= FIND_HEIGHT;
+            r.bottom -= mFindHeight;
         }
     }
 
@@ -2073,9 +2073,6 @@
         }
     }
 
-    // Make sure this stays in sync with the actual height of the FindDialog.
-    private static final int FIND_HEIGHT = 79;
-
     @Override
     protected int computeVerticalScrollRange() {
         if (mDrawHistory) {
@@ -2306,7 +2303,11 @@
      *              that were found.
      */
     public int findAll(String find) {
-        mFindIsUp = true;
+        if (mFindIsUp == false) {
+            recordNewContentSize(mContentWidth, mContentHeight + mFindHeight,
+                    false);
+            mFindIsUp = true;
+        }
         int result = nativeFindAll(find.toLowerCase(), find.toUpperCase());
         invalidate();
         return result;
@@ -2315,6 +2316,7 @@
     // Used to know whether the find dialog is open.  Affects whether
     // or not we draw the highlights for matches.
     private boolean mFindIsUp;
+    private int mFindHeight;
 
     /**
      * Return the first substring consisting of the address of a physical
@@ -2370,7 +2372,11 @@
      * Clear the highlighting surrounding text matches created by findAll.
      */
     public void clearMatches() {
-        mFindIsUp = false;
+        if (mFindIsUp) {
+            recordNewContentSize(mContentWidth, mContentHeight - mFindHeight,
+                    false);
+            mFindIsUp = false;
+        }
         nativeSetFindIsDown();
         // Now that the dialog has been removed, ensure that we scroll to a
         // location that is not beyond the end of the page.
@@ -2379,6 +2385,16 @@
     }
 
     /**
+     * @hide
+     */
+    public void setFindDialogHeight(int height) {
+        if (DebugFlags.WEB_VIEW) {
+            Log.v(LOGTAG, "setFindDialogHeight height=" + height);
+        }
+        mFindHeight = height;
+    }
+
+    /**
      * Query the document to see if it contains any image references. The
      * message object will be dispatched with arg1 being set to 1 if images
      * were found and 0 if the document does not reference any images.
@@ -3734,6 +3750,13 @@
                             && !mZoomButtonsController.isVisible()
                             && mMinZoomScale < mMaxZoomScale) {
                         mZoomButtonsController.setVisible(true);
+                        int count = settings.getDoubleTapToastCount();
+                        if (mInZoomOverview && count > 0) {
+                            settings.setDoubleTapToastCount(count--);
+                            Toast.makeText(mContext,
+                                    com.android.internal.R.string.double_tap_toast,
+                                    Toast.LENGTH_SHORT).show();
+                        }
                     }
                 }
 
@@ -4506,7 +4529,8 @@
         mZoomCenterY = mLastTouchY;
         mInZoomOverview = !mInZoomOverview;
         // remove the zoom control after double tap
-        if (getSettings().getBuiltInZoomControls()) {
+        WebSettings settings = getSettings();
+        if (settings.getBuiltInZoomControls()) {
             if (mZoomButtonsController.isVisible()) {
                 mZoomButtonsController.setVisible(false);
             }
@@ -4518,6 +4542,7 @@
                 mZoomControls.hide();
             }
         }
+        settings.setDoubleTapToastCount(0);
         if (mInZoomOverview) {
             // Force the titlebar fully reveal in overview mode
             if (mScrollY < getTitleHeight()) mScrollY = 0;
@@ -4869,7 +4894,8 @@
                     final boolean updateLayout = viewSize.x == mLastWidthSent
                             && viewSize.y == mLastHeightSent;
                     recordNewContentSize(draw.mWidthHeight.x,
-                            draw.mWidthHeight.y, updateLayout);
+                            draw.mWidthHeight.y
+                            + (mFindIsUp ? mFindHeight : 0), updateLayout);
                     if (DebugFlags.WEB_VIEW) {
                         Rect b = draw.mInvalRegion.getBounds();
                         Log.v(LOGTAG, "NEW_PICTURE_MSG_ID {" +
diff --git a/core/java/com/android/internal/widget/ContactHeaderWidget.java b/core/java/com/android/internal/widget/ContactHeaderWidget.java
index ed375f7..4987775 100644
--- a/core/java/com/android/internal/widget/ContactHeaderWidget.java
+++ b/core/java/com/android/internal/widget/ContactHeaderWidget.java
@@ -402,7 +402,7 @@
      */
     public void bindFromPhoneNumber(String number) {
         mQueryHandler.startQuery(TOKEN_PHONE_LOOKUP, number,
-                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, number),
+                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)),
                 PHONE_LOOKUP_PROJECTION, null, null, null);
     }
 
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index bd79c75..a1a0102 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1391,6 +1391,9 @@
     <!-- Title of the WebView save password dialog.  If the user enters a password in a form on a website, a dialog will come up asking if they want to save the password. -->
     <string name="save_password_label">Confirm</string>
 
+    <!-- Toast for double-tap -->
+    <string name="double_tap_toast">Tip: double-tap to zoom in and out.</string>
+
     <!-- Title of an application permission, listed so the user can choose whether
         they want to allow the application to do this. -->
     <string name="permlab_readHistoryBookmarks">read Browser\'s history and bookmarks</string>
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index 2d8afb7..046bfea 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -317,7 +317,7 @@
      * enough for caller ID purposes.
      *
      * - Compares from right to left
-     * - requires MIN_MATCH (5) characters to match
+     * - requires MIN_MATCH (7) characters to match
      * - handles common trunk prefixes and international prefixes
      *   (basically, everything except the Russian trunk prefix)
      *
@@ -1202,10 +1202,24 @@
         JapanesePhoneNumberFormatter.format(text);
     }
 
-    // Three and four digit phone numbers for either special services
-    // or from the network (eg carrier-originated SMS messages) should
-    // not match
-    static final int MIN_MATCH = 5;
+    // Three and four digit phone numbers for either special services,
+    // or 3-6 digit addresses from the network (eg carrier-originated SMS messages) should
+    // not match.
+    //
+    // This constant used to be 5, but SMS short codes has increased in length and
+    // can be easily 6 digits now days. Most countries have SMS short code length between
+    // 3 to 6 digits. The exceptions are
+    //
+    // Australia: Short codes are six or eight digits in length, starting with the prefix "19"
+    //            followed by an additional four or six digits and two.
+    // Czech Republic: Codes are seven digits in length for MO and five (not billed) or
+    //            eight (billed) for MT direction
+    //
+    // see http://en.wikipedia.org/wiki/Short_code#Regional_differences for reference
+    //
+    // However, in order to loose match 650-555-1212 and 555-1212, we need to set the min match
+    // to 7.
+    static final int MIN_MATCH = 7;
 
     /**
      * isEmergencyNumber: checks a given number against the list of