Merge "Killing Facelock when a phonecall comes in"
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 99aae37..d2facdc 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -1478,7 +1478,7 @@
         }
 
         //Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics);
-        DisplayMetrics metrics = getDisplayMetricsLocked(compInfo, false);
+        DisplayMetrics metrics = getDisplayMetricsLocked(null, false);
         r = new Resources(assets, metrics, getConfiguration(), compInfo);
         if (false) {
             Slog.i(TAG, "Created app resources " + resDir + " " + r + ": "
@@ -3476,7 +3476,7 @@
             return false;
         }
         int changes = mResConfiguration.updateFrom(config);
-        DisplayMetrics dm = getDisplayMetricsLocked(compat, true);
+        DisplayMetrics dm = getDisplayMetricsLocked(null, true);
 
         if (compat != null && (mResCompatibilityInfo == null ||
                 !mResCompatibilityInfo.equals(compat))) {
@@ -3517,7 +3517,20 @@
         
         return changes != 0;
     }
-    
+
+    final Configuration applyCompatConfiguration() {
+        Configuration config = mConfiguration;
+        if (mCompatConfiguration == null) {
+            mCompatConfiguration = new Configuration();
+        }
+        mCompatConfiguration.setTo(mConfiguration);
+        if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) {
+            mResCompatibilityInfo.applyToConfiguration(mCompatConfiguration);
+            config = mCompatConfiguration;
+        }
+        return config;
+    }
+
     final void handleConfigurationChanged(Configuration config, CompatibilityInfo compat) {
 
         ArrayList<ComponentCallbacks2> callbacks = null;
@@ -3546,14 +3559,7 @@
                 return;
             }
             mConfiguration.updateFrom(config);
-            if (mCompatConfiguration == null) {
-                mCompatConfiguration = new Configuration();
-            }
-            mCompatConfiguration.setTo(mConfiguration);
-            if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) {
-                mResCompatibilityInfo.applyToConfiguration(mCompatConfiguration);
-                config = mCompatConfiguration;
-            }
+            config = applyCompatConfiguration();
             callbacks = collectComponentCallbacksLocked(false, config);
         }
         
@@ -3752,6 +3758,7 @@
          * in AppBindData can be safely assumed to be up to date
          */
         applyConfigurationToResourcesLocked(data.config, data.compatInfo);
+        applyCompatConfiguration();
 
         data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
 
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 1d8ea12..5faab36 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -282,6 +282,10 @@
          * <p>Applications targeting this or a later release will get these
          * new changes in behavior:</p>
          * <ul>
+         * <li> For devices without a dedicated menu key, the software compatibility
+         * menu key will not be shown even on phones.  By targeting Ice Cream Sandwich
+         * or later, your UI must always have its own menu UI affordance if needed,
+         * on both tablets and phones.  The ActionBar will take care of this for you.
          * <li> 2d drawing hardware acceleration is now turned on by default.
          * You can use
          * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
@@ -296,6 +300,12 @@
          *      will not change character within the same platform version. Applications
          *      that wish to blend in with the device should use a theme from the
          *      {@link android.R.style#Theme_DeviceDefault} family.
+         * <li> Managed cursors can now throw an exception if you directly close
+         * the cursor yourself without stopping the management of it; previously failures
+         * would be silently ignored.
+         * <li> The fadingEdge attribute on views will be ignored (fading edges is no
+         * longer a standard part of the UI).  A new requiresFadingEdge attribute allows
+         * applications to still force fading edges on for special cases.
          * </ul>
          */
         public static final int ICE_CREAM_SANDWICH = 14;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 63c4d03..440ee79 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -518,7 +518,7 @@
     /**
      * Update the layers' content
      */
-    private native int nativeUpdateLayers(Region invalRegion);
+    private native boolean nativeUpdateLayers(int baseLayer);
 
     private native boolean nativeFocusBoundsChanged();
 
@@ -2004,18 +2004,25 @@
         boolean mFocusSizeChanged;
     }
 
+    DrawData mLastDrawData = null;
+
     // Only update the layers' content, not the base surface
     // PictureSet.
     private void webkitDrawLayers() {
         mDrawLayersIsScheduled = false;
-        if (mDrawIsScheduled) {
+        if (mDrawIsScheduled || mLastDrawData == null) {
             removeMessages(EventHub.WEBKIT_DRAW);
             webkitDraw();
             return;
         }
-        DrawData draw = new DrawData();
-        draw.mBaseLayer = nativeUpdateLayers(draw.mInvalRegion);
-        webkitDraw(draw);
+        // Directly update the layers we last passed to the UI side
+        if (nativeUpdateLayers(mLastDrawData.mBaseLayer)) {
+            // If anything more complex than position has been touched, let's do a full draw
+            webkitDraw();
+        } else {
+            Message.obtain(mWebView.mPrivateHandler,
+                    WebView.INVAL_RECT_MSG_ID).sendToTarget();
+        }
     }
 
     private void webkitDraw() {
@@ -2032,6 +2039,7 @@
             }
             return;
         }
+        mLastDrawData = draw;
         webkitDraw(draw);
     }
 
diff --git a/docs/html/resources/resources-data.js b/docs/html/resources/resources-data.js
index d7700ee..796b30a 100644
--- a/docs/html/resources/resources-data.js
+++ b/docs/html/resources/resources-data.js
@@ -588,6 +588,16 @@
     }
   },
   {
+    tags: ['sample', 'input', 'new'],
+    path: 'samples/SampleSpellCheckerService/index.html',
+    title: {
+      en: 'Spell Checker'
+    },
+    description: {
+      en: 'An example spell checker service, using the <a href="'+toRoot+'reference/android/service/textservice/SpellCheckerService.html"><code>SpellCheckerservice</code></a>.'
+    }
+  },
+  {
     tags: ['sample', 'accountsync'],
     path: 'samples/SampleSyncAdapter/index.html',
     title: {
@@ -701,7 +711,7 @@
     tags: ['sample', 'data', 'new'],
     path: 'samples/VoicemailProviderDemo/index.html',
     title: {
-      en: 'Voicemail Provider Demo'
+      en: 'Voicemail Provider'
     },
     description: {
       en: 'A sample application to demonstrate how to use voicemail content provider APIs in Android 4.0.'
diff --git a/libs/rs/scriptc/rs_allocation.rsh b/libs/rs/scriptc/rs_allocation.rsh
index 1e755cd..154a099 100644
--- a/libs/rs/scriptc/rs_allocation.rsh
+++ b/libs/rs/scriptc/rs_allocation.rsh
@@ -71,6 +71,8 @@
 extern uint32_t __attribute__((overloadable))
     rsAllocationGetDimFaces(rs_allocation);
 
+#if (defined(RS_VERSION) && (RS_VERSION >= 14))
+
 /**
  * Copy part of an allocation from another allocation.
  *
@@ -123,6 +125,7 @@
                             uint32_t srcMip,
                             rs_allocation_cubemap_face srcFace);
 
+#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
 
 /**
  * Extract a single element from an allocation.
diff --git a/libs/rs/scriptc/rs_atomic.rsh b/libs/rs/scriptc/rs_atomic.rsh
index 95513ad..87c6c02 100644
--- a/libs/rs/scriptc/rs_atomic.rsh
+++ b/libs/rs/scriptc/rs_atomic.rsh
@@ -23,6 +23,7 @@
 #ifndef __RS_ATOMIC_RSH__
 #define __RS_ATOMIC_RSH__
 
+#if (defined(RS_VERSION) && (RS_VERSION >= 14))
 
 /**
  * Atomic add one to the value at addr.
@@ -243,6 +244,7 @@
 extern uint32_t __attribute__((overloadable))
     rsAtomicCas(volatile uint32_t* addr, int32_t compareValue, int32_t newValue);
 
+#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
 
 #endif
 
diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh
index 00fd1b10..3e9339e 100644
--- a/libs/rs/scriptc/rs_graphics.rsh
+++ b/libs/rs/scriptc/rs_graphics.rsh
@@ -23,6 +23,7 @@
 #ifndef __RS_GRAPHICS_RSH__
 #define __RS_GRAPHICS_RSH__
 
+#if (defined(RS_VERSION) && (RS_VERSION >= 14))
 /**
  * Set the color target used for all subsequent rendering calls
  * @param colorTarget
@@ -64,6 +65,8 @@
 extern uint __attribute__((overloadable))
     rsgFinish(void);
 
+#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
+
 /**
  * Bind a new ProgramFragment to the rendering context.
  *
@@ -187,6 +190,8 @@
 extern void __attribute__((overloadable))
     rsgAllocationSyncAll(rs_allocation alloc);
 
+#if (defined(RS_VERSION) && (RS_VERSION >= 14))
+
 /**
  * Sync the contents of an allocation from memory space
  * specified by source.
@@ -198,6 +203,8 @@
     rsgAllocationSyncAll(rs_allocation alloc,
                          rs_allocation_usage_type source);
 
+#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
+
 /**
  * Low performance utility function for drawing a simple rectangle.  Not
  * intended for drawing large quantities of geometry.
diff --git a/libs/rs/scriptc/rs_matrix.rsh b/libs/rs/scriptc/rs_matrix.rsh
index ab3cd3b..ebff7f4 100644
--- a/libs/rs/scriptc/rs_matrix.rsh
+++ b/libs/rs/scriptc/rs_matrix.rsh
@@ -308,7 +308,7 @@
 #else
 /**
  * Multiply a vector by a matrix and return the result vector.
- * API version 10-13
+ * API version 14+
  */
 _RS_RUNTIME float4 __attribute__((overloadable))
 rsMatrixMultiply(const rs_matrix4x4 *m, float4 in);
diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh
index 5d5df60..e9c3c5e 100644
--- a/libs/rs/scriptc/rs_types.rsh
+++ b/libs/rs/scriptc/rs_types.rsh
@@ -366,6 +366,7 @@
 #define RS_PACKED __attribute__((packed, aligned(4)))
 #define NULL ((const void *)0)
 
+#if (defined(RS_VERSION) && (RS_VERSION >= 14))
 
 /**
  * \brief Enum for selecting cube map faces
@@ -393,4 +394,6 @@
     RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010
 } rs_allocation_usage_type;
 
+#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
+
 #endif
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 73ac296..8e98ec4 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -9003,8 +9003,8 @@
                 mScreenRotationAnimation = null;
             }
             updateRotation = true;
-            Surface.unfreezeDisplay(0);
         }
+        Surface.unfreezeDisplay(0);
 
         mInputMonitor.thawInputDispatchingLw();