Merge change 20686

* changes:
  fix the build
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 9b0c70e..066401f 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -573,8 +573,8 @@
         public static final String SYNC4 = "data_sync4";
 
         /**
-         * An optional update or insert URI parameter that determines if the
-         * corresponding raw contact should be marked as dirty. The default
+         * An optional insert, update or delete URI parameter that determines if
+         * the corresponding raw contact should be marked as dirty. The default
          * value is true.
          */
         public static final String MARK_AS_DIRTY = "mark_as_dirty";
@@ -1401,6 +1401,17 @@
          * Type: INTEGER
          */
         public static final String GROUP_VISIBLE = "group_visible";
+
+        /**
+         * The "deleted" flag: "0" by default, "1" if the row has been marked
+         * for deletion. When {@link android.content.ContentResolver#delete} is
+         * called on a raw contact, it is marked for deletion and removed from its
+         * aggregate contact. The sync adaptor deletes the raw contact on the server and
+         * then calls ContactResolver.delete once more, this time passing the
+         * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal.
+         * <P>Type: INTEGER</P>
+         */
+        public static final String DELETED = "deleted";
     }
 
     /**
@@ -1434,6 +1445,20 @@
          * The MIME type of a single group.
          */
         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
+
+        /**
+         * Query parameter that can be passed with the {@link #CONTENT_URI} URI
+         * to the {@link android.content.ContentResolver#delete} method to
+         * indicate that the raw contact can be deleted physically, rather than
+         * merely marked as deleted.
+         */
+        public static final String DELETE_PERMANENTLY = "delete_permanently";
+
+        /**
+         * An optional update or insert URI parameter that determines if the
+         * group should be marked as dirty. The default value is true.
+         */
+        public static final String MARK_AS_DIRTY = "mark_as_dirty";
     }
 
     /**
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 3e818eb..cf26b1b 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2728,7 +2728,14 @@
          * Controls how many attempts Gmail will try to upload an uphill operations before it
          * abandons the operation. Defaults to 20.
          */
-        public static final String GMAIL_NUM_RETRY_UPHILL_OP = "gmail_discard_error_uphill_op";
+        public static final String GMAIL_NUM_RETRY_UPHILL_OP = "gmail_num_retry_uphill_op";
+
+        /**
+         * How much time in seconds Gmail will try to upload an uphill operations before it
+         * abandons the operation. Defaults to 36400 (one day).
+         */
+        public static final String GMAIL_WAIT_TIME_RETRY_UPHILL_OP =
+                "gmail_wait_time_retry_uphill_op";
 
         /**
          * Controls if the protocol buffer version of the protocol will use a multipart request for
@@ -3346,6 +3353,14 @@
         public static final String USE_LOCATION_FOR_SERVICES = "use_location";
 
         /**
+         * The length of the calendar sync window into the future.
+         * This specifies the number of days into the future for the sliding window sync.
+         * Setting this to zero will disable sliding sync.
+         */
+        public static final String GOOGLE_CALENDAR_SYNC_WINDOW_DAYS =
+                "google_calendar_sync_window_days";
+
+        /**
          * @deprecated
          * @hide
          */
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index d019097..2e947d6 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -1512,6 +1512,10 @@
                     int name = getTrackName_l();
                     if (name < 0) break;
                     mTracks[i]->mName = name;
+                    // limit track sample rate to 2 x new output sample rate
+                    if (mTracks[i]->mCblk->sampleRate > 2 * sampleRate()) {
+                        mTracks[i]->mCblk->sampleRate = 2 * sampleRate();
+                    }
                 }
                 sendConfigEvent_l(AudioSystem::OUTPUT_CONFIG_CHANGED);
             }
diff --git a/opengl/tests/angeles/app-linux.cpp b/opengl/tests/angeles/app-linux.cpp
index 9c71693..06fa0c2 100644
--- a/opengl/tests/angeles/app-linux.cpp
+++ b/opengl/tests/angeles/app-linux.cpp
@@ -133,11 +133,11 @@
      EGLint w, h;
      EGLDisplay dpy;
 
+     EGLNativeWindowType window = android_createDisplaySurface();
+     
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
           
-     EGLNativeWindowType window = android_createDisplaySurface();
-     
      status_t err = EGLUtils::selectConfigForNativeWindow(
              dpy, configAttribs, window, &config);
      if (err) {
diff --git a/opengl/tests/copybits/copybits.cpp b/opengl/tests/copybits/copybits.cpp
index f8ca9b2..11dfb6e 100644
--- a/opengl/tests/copybits/copybits.cpp
+++ b/opengl/tests/copybits/copybits.cpp
@@ -23,6 +23,9 @@
 #include <hardware/gralloc.h>
 #include <hardware/hardware.h>
 
+#include <ui/FramebufferNativeWindow.h>
+#include <ui/EGLUtils.h>
+
 #define EGL_EGLEXT_PROTOTYPES
 #define GL_GLEXT_PROTOTYPES
 
@@ -32,8 +35,6 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
-extern "C" EGLNativeWindowType android_createDisplaySurface(void);
-
 using namespace android;
 
 EGLDisplay eglDisplay;
@@ -268,6 +269,8 @@
             EGL_NONE
     };
 
+    EGLNativeWindowType window = android_createDisplaySurface();
+
     printf("init_gl_surface\n");
     if ( (eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY )
     {
@@ -281,14 +284,15 @@
         return 0;
     }
 
-    if ( eglChooseConfig(eglDisplay, attrib, &myConfig, 1, &numConfigs) != EGL_TRUE )
+    if ( EGLUtils::selectConfigForNativeWindow(eglDisplay, attrib, window, &myConfig) != 0)
     {
-        printf("eglChooseConfig failed\n");
+        printf("EGLUtils::selectConfigForNativeWindow failed\n");
         return 0;
     }
+        
 
     if ( (eglSurface = eglCreateWindowSurface(eglDisplay, myConfig,
-            android_createDisplaySurface(), 0)) == EGL_NO_SURFACE )
+            window, 0)) == EGL_NO_SURFACE )
     {
         printf("eglCreateWindowSurface failed\n");
         return 0;
diff --git a/opengl/tests/fillrate/fillrate.cpp b/opengl/tests/fillrate/fillrate.cpp
index 4ffbc8b..911d354 100644
--- a/opengl/tests/fillrate/fillrate.cpp
+++ b/opengl/tests/fillrate/fillrate.cpp
@@ -45,11 +45,11 @@
      EGLint w, h;
      EGLDisplay dpy;
 
+     EGLNativeWindowType window = android_createDisplaySurface();
+     
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
           
-     EGLNativeWindowType window = android_createDisplaySurface();
-     
      status_t err = EGLUtils::selectConfigForNativeWindow(
              dpy, configAttribs, window, &config);
      if (err) {
diff --git a/opengl/tests/filter/filter.cpp b/opengl/tests/filter/filter.cpp
index e82b12d..82aafbf 100644
--- a/opengl/tests/filter/filter.cpp
+++ b/opengl/tests/filter/filter.cpp
@@ -37,10 +37,14 @@
      
      EGLDisplay dpy;
 
+     EGLNativeWindowType window = 0;
+     if (!usePbuffer) {
+         window = android_createDisplaySurface();
+     }
+     
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
      if (!usePbuffer) {
-         EGLNativeWindowType window = android_createDisplaySurface();
          surface = eglCreateWindowSurface(dpy, config, window, NULL);
          EGLUtils::selectConfigForNativeWindow(
                  dpy, s_configAttribs, window, &config);
diff --git a/opengl/tests/finish/finish.cpp b/opengl/tests/finish/finish.cpp
index b5b8142..91f5c45 100644
--- a/opengl/tests/finish/finish.cpp
+++ b/opengl/tests/finish/finish.cpp
@@ -46,11 +46,11 @@
      EGLint w, h;
      EGLDisplay dpy;
 
+     EGLNativeWindowType window = android_createDisplaySurface();
+     
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
           
-     EGLNativeWindowType window = android_createDisplaySurface();
-     
      status_t err = EGLUtils::selectConfigForNativeWindow(
              dpy, configAttribs, window, &config);
      if (err) {
diff --git a/opengl/tests/swapinterval/swapinterval.cpp b/opengl/tests/swapinterval/swapinterval.cpp
index 80a6c21..df53b62 100644
--- a/opengl/tests/swapinterval/swapinterval.cpp
+++ b/opengl/tests/swapinterval/swapinterval.cpp
@@ -44,12 +44,13 @@
     EGLint w, h;
     EGLDisplay dpy;
 
+    
+    EGLNativeWindowType window = android_createDisplaySurface();
+
     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     eglInitialize(dpy, 0 ,0) ;//&majorVersion, &minorVersion);
     eglGetConfigs(dpy, NULL, 0, &numConfigs);
     printf("# configs = %d\n", numConfigs);
-    
-    EGLNativeWindowType window = android_createDisplaySurface();
 
     status_t err = EGLUtils::selectConfigForNativeWindow(
             dpy, configAttribs, window, &config);
diff --git a/opengl/tests/textures/textures.cpp b/opengl/tests/textures/textures.cpp
index ee92e79..cbe8ffd 100644
--- a/opengl/tests/textures/textures.cpp
+++ b/opengl/tests/textures/textures.cpp
@@ -42,11 +42,11 @@
      EGLint w, h;
      EGLDisplay dpy;
 
+     EGLNativeWindowType window = android_createDisplaySurface();
+     
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
           
-     EGLNativeWindowType window = android_createDisplaySurface();
-     
      status_t err = EGLUtils::selectConfigForNativeWindow(
              dpy, configAttribs, window, &config);
      if (err) {
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 32ee61b..1e5302e 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -1083,7 +1083,7 @@
         public void run() {
             long startRealtime = SystemClock.elapsedRealtime();
             if (DEBUG) Log.v(TAG, "Beginning restore process mTransport=" + mTransport
-                    + " mObserver=" + mObserver + " mToken=" + mToken);
+                    + " mObserver=" + mObserver + " mToken=" + Long.toHexString(mToken));
             /**
              * Restore sequence:
              *
@@ -1706,7 +1706,8 @@
             mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
                     "performRestore");
 
-            if (DEBUG) Log.d(TAG, "performRestore token=" + token + " observer=" + observer);
+            if (DEBUG) Log.d(TAG, "performRestore token=" + Long.toHexString(token)
+                    + " observer=" + observer);
 
             if (mRestoreTransport == null || mRestoreSets == null) {
                 Log.e(TAG, "Ignoring performRestore() with no restore set");
diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java
index 8a1e928..60e0a44 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java
@@ -115,4 +115,9 @@
      */
     static final String PROPERTY_OTASP_NUM_SCHEMA = "ro.cdma.otaspnumschema";
 
+    /**
+     * Disable all calls including Emergency call when it set to true.
+     */
+    static final String PROPERTY_DISABLE_CALL = "ro.telephony.disable-call";
+
 }
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
index 3997639..be4763c 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
@@ -321,13 +321,16 @@
     canDial() {
         boolean ret;
         int serviceState = phone.getServiceState().getState();
+        String disableCall = SystemProperties.get(
+                TelephonyProperties.PROPERTY_DISABLE_CALL, "false");
 
-        ret = (serviceState != ServiceState.STATE_POWER_OFF) &&
-                pendingMO == null
+        ret = (serviceState != ServiceState.STATE_POWER_OFF)
+                && pendingMO == null
                 && !ringingCall.isRinging()
+                && !disableCall.equals("true")
                 && (!foregroundCall.getState().isAlive()
-                || (foregroundCall.getState() == CdmaCall.State.ACTIVE)
-                || !backgroundCall.getState().isAlive());
+                    || (foregroundCall.getState() == CdmaCall.State.ACTIVE)
+                    || !backgroundCall.getState().isAlive());
 
         return ret;
     }
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmCallTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmCallTracker.java
index db6e339..91c089e 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmCallTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmCallTracker.java
@@ -294,12 +294,15 @@
     canDial() {
         boolean ret;
         int serviceState = phone.getServiceState().getState();
+        String disableCall = SystemProperties.get(
+                TelephonyProperties.PROPERTY_DISABLE_CALL, "false");
 
-        ret = (serviceState != ServiceState.STATE_POWER_OFF) &&
-                pendingMO == null
+        ret = (serviceState != ServiceState.STATE_POWER_OFF)
+                && pendingMO == null
                 && !ringingCall.isRinging()
+                && !disableCall.equals("true")
                 && (!foregroundCall.getState().isAlive()
-                || !backgroundCall.getState().isAlive());
+                    || !backgroundCall.getState().isAlive());
 
         return ret;
     }