Merge "Fix wallpaper not updating on initial boot." into jb-mr1-dev
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 2287859..14b3681 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -136,6 +136,7 @@
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ImageProcessing_intermediates)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ImageProcessing2_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ImageProcessing_intermediates)
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/api/17.txt b/api/17.txt
index 7b2f161..ee9a973 100644
--- a/api/17.txt
+++ b/api/17.txt
@@ -29625,7 +29625,6 @@
     method protected void onTextChanged(java.lang.CharSequence, int, int, int);
     method public boolean onTextContextMenuItem(int);
     method public void removeTextChangedListener(android.text.TextWatcher);
-    method protected void resetResolvedDrawables();
     method public void setAllCaps(boolean);
     method public final void setAutoLinkMask(int);
     method public void setCompoundDrawablePadding(int);
diff --git a/api/current.txt b/api/current.txt
index 7b2f161..ee9a973 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -29625,7 +29625,6 @@
     method protected void onTextChanged(java.lang.CharSequence, int, int, int);
     method public boolean onTextContextMenuItem(int);
     method public void removeTextChangedListener(android.text.TextWatcher);
-    method protected void resetResolvedDrawables();
     method public void setAllCaps(boolean);
     method public final void setAutoLinkMask(int);
     method public void setCompoundDrawablePadding(int);
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 0941d71..2bec1c1 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -16,6 +16,7 @@
 
 package android.os;
 
+import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -91,7 +92,7 @@
         }
         return result;
     }
-    
+
     /**
      * Copy data from a source stream to destFile.
      * Return true if succeed, return false if failed.
@@ -143,12 +144,16 @@
      */
     public static String readTextFile(File file, int max, String ellipsis) throws IOException {
         InputStream input = new FileInputStream(file);
+        // wrapping a BufferedInputStream around it because when reading /proc with unbuffered
+        // input stream, bytes read not equal to buffer size is not necessarily the correct
+        // indication for EOF; but it is true for BufferedInputStream due to its implementation.
+        BufferedInputStream bis = new BufferedInputStream(input);
         try {
             long size = file.length();
             if (max > 0 || (size > 0 && max == 0)) {  // "head" mode: read the first N bytes
                 if (size > 0 && (max == 0 || size < max)) max = (int) size;
                 byte[] data = new byte[max + 1];
-                int length = input.read(data);
+                int length = bis.read(data);
                 if (length <= 0) return "";
                 if (length <= max) return new String(data, 0, length);
                 if (ellipsis == null) return new String(data, 0, max);
@@ -161,7 +166,7 @@
                     if (last != null) rolled = true;
                     byte[] tmp = last; last = data; data = tmp;
                     if (data == null) data = new byte[-max];
-                    len = input.read(data);
+                    len = bis.read(data);
                 } while (len == data.length);
 
                 if (last == null && len <= 0) return "";
@@ -178,12 +183,13 @@
                 int len;
                 byte[] data = new byte[1024];
                 do {
-                    len = input.read(data);
+                    len = bis.read(data);
                     if (len > 0) contents.write(data, 0, len);
                 } while (len == data.length);
                 return contents.toString();
             }
         } finally {
+            bis.close();
             input.close();
         }
     }
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 608bdd7..946965b 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -3666,15 +3666,10 @@
             // Padding from the background drawable is stored at this point in mUserPaddingLeftInitial
             // and mUserPaddingRightInitial) so drawable padding will be used as ultimate default if
             // defined.
-            if (startPaddingDefined) {
-                mUserPaddingLeftInitial = startPadding;
-            } else if (leftPaddingDefined) {
+            if (leftPaddingDefined) {
                 mUserPaddingLeftInitial = leftPadding;
             }
-            if (endPaddingDefined) {
-                mUserPaddingRightInitial = endPadding;
-            }
-            else if (rightPaddingDefined) {
+            if (rightPaddingDefined) {
                 mUserPaddingRightInitial = rightPadding;
             }
         }
@@ -11559,8 +11554,10 @@
 
     /**
      * Resolve all RTL related properties.
+     *
+     * @hide
      */
-    void resolveRtlPropertiesIfNeeded() {
+    public void resolveRtlPropertiesIfNeeded() {
         if (!needRtlPropertiesResolution()) return;
 
         // Order is important here: LayoutDirection MUST be resolved first
@@ -11584,8 +11581,12 @@
         onRtlPropertiesChanged(getLayoutDirection());
     }
 
-    // Reset resolution of all RTL related properties.
-    void resetRtlProperties() {
+    /**
+     * Reset resolution of all RTL related properties.
+     *
+     * @hide
+     */
+    public void resetRtlProperties() {
         resetResolvedLayoutDirection();
         resetResolvedTextDirection();
         resetResolvedTextAlignment();
@@ -14195,7 +14196,7 @@
      *
      * @hide
      */
-    public void resolveDrawables() {
+    protected void resolveDrawables() {
         if (mBackground != null) {
             mBackground.setLayoutDirection(getLayoutDirection());
         }
@@ -14218,7 +14219,10 @@
     public void onResolveDrawables(int layoutDirection) {
     }
 
-    private void resetResolvedDrawables() {
+    /**
+     * @hide
+     */
+    protected void resetResolvedDrawables() {
         mPrivateFlags2 &= ~PFLAG2_DRAWABLE_RESOLVED;
     }
 
@@ -14804,14 +14808,14 @@
         if (isRtlCompatibilityMode()) {
             mPaddingLeft = mUserPaddingLeftInitial;
             mPaddingRight = mUserPaddingRightInitial;
+            return;
+        }
+        if (isLayoutRtl()) {
+            mPaddingLeft = (mUserPaddingEnd >= 0) ? mUserPaddingEnd : mUserPaddingLeftInitial;
+            mPaddingRight = (mUserPaddingStart >= 0) ? mUserPaddingStart : mUserPaddingRightInitial;
         } else {
-            if (isLayoutRtl()) {
-                mPaddingLeft = mUserPaddingRightInitial;
-                mPaddingRight = mUserPaddingLeftInitial;
-            } else {
-                mPaddingLeft = mUserPaddingLeftInitial;
-                mPaddingRight = mUserPaddingRightInitial;
-            }
+            mPaddingLeft = (mUserPaddingStart >= 0) ? mUserPaddingStart : mUserPaddingLeftInitial;
+            mPaddingRight = (mUserPaddingEnd >= 0) ? mUserPaddingEnd : mUserPaddingRightInitial;
         }
     }
 
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 0661992..9ce7df9 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5263,6 +5263,21 @@
      * @hide
      */
     @Override
+    public void resolveRtlPropertiesIfNeeded() {
+        super.resolveRtlPropertiesIfNeeded();
+        int count = getChildCount();
+        for (int i = 0; i < count; i++) {
+            final View child = getChildAt(i);
+            if (child.isLayoutDirectionInherited()) {
+                child.resolveRtlPropertiesIfNeeded();
+            }
+        }
+    }
+
+    /**
+     * @hide
+     */
+    @Override
     public boolean resolveLayoutDirection() {
         final boolean result = super.resolveLayoutDirection();
         if (result) {
@@ -5317,6 +5332,51 @@
      * @hide
      */
     @Override
+    public void resolvePadding() {
+        super.resolvePadding();
+        int count = getChildCount();
+        for (int i = 0; i < count; i++) {
+            final View child = getChildAt(i);
+            if (child.isLayoutDirectionInherited()) {
+                child.resolvePadding();
+            }
+        }
+    }
+
+    /**
+     * @hide
+     */
+    @Override
+    protected void resolveDrawables() {
+        super.resolveDrawables();
+        int count = getChildCount();
+        for (int i = 0; i < count; i++) {
+            final View child = getChildAt(i);
+            if (child.isLayoutDirectionInherited()) {
+                child.resolveDrawables();
+            }
+        }
+    }
+
+    /**
+     * @hide
+     */
+    @Override
+    public void resetRtlProperties() {
+        super.resetRtlProperties();
+        int count = getChildCount();
+        for (int i = 0; i < count; i++) {
+            final View child = getChildAt(i);
+            if (child.isLayoutDirectionInherited()) {
+                child.resetRtlProperties();
+            }
+        }
+    }
+
+    /**
+     * @hide
+     */
+    @Override
     public void resetResolvedLayoutDirection() {
         super.resetResolvedLayoutDirection();
 
@@ -5362,6 +5422,38 @@
     }
 
     /**
+     * @hide
+     */
+    @Override
+    public void resetResolvedPadding() {
+        super.resetResolvedPadding();
+
+        int count = getChildCount();
+        for (int i = 0; i < count; i++) {
+            final View child = getChildAt(i);
+            if (child.isLayoutDirectionInherited()) {
+                child.resetResolvedPadding();
+            }
+        }
+    }
+
+    /**
+     * @hide
+     */
+    @Override
+    protected void resetResolvedDrawables() {
+        super.resetResolvedDrawables();
+
+        int count = getChildCount();
+        for (int i = 0; i < count; i++) {
+            final View child = getChildAt(i);
+            if (child.isLayoutDirectionInherited()) {
+                child.resetResolvedDrawables();
+            }
+        }
+    }
+
+    /**
      * Return true if the pressed state should be delayed for children or descendants of this
      * ViewGroup. Generally, this should be done for containers that can scroll, such as a List.
      * This prevents the pressed state from appearing when the user is actually trying to scroll
diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java
index e74e37c..de8b80d 100644
--- a/core/java/android/widget/CheckedTextView.java
+++ b/core/java/android/widget/CheckedTextView.java
@@ -188,10 +188,11 @@
         resetPaddingToInitialValues();
         int newPadding = (mCheckMarkDrawable != null) ?
                 mCheckMarkWidth + mBasePadding : mBasePadding;
-        mNeedRequestlayout |= (mPaddingRight != newPadding);
         if (isLayoutRtl()) {
+            mNeedRequestlayout |= (mPaddingLeft != newPadding);
             mPaddingLeft = newPadding;
         } else {
+            mNeedRequestlayout |= (mPaddingRight != newPadding);
             mPaddingRight = newPadding;
         }
         if (mNeedRequestlayout) {
@@ -200,18 +201,6 @@
         }
     }
 
-    @Override
-    public void setPadding(int left, int top, int right, int bottom) {
-        super.setPadding(left, top, right, bottom);
-        setBasePadding(isLayoutRtl());
-    }
-
-    @Override
-    public void setPaddingRelative(int start, int top, int end, int bottom) {
-        super.setPaddingRelative(start, top, end, bottom);
-        setBasePadding(isLayoutRtl());
-    }
-
     private void setBasePadding(boolean isLayoutRtl) {
         if (isLayoutRtl) {
             mBasePadding = mPaddingLeft;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 958b669..b3c679c 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8314,6 +8314,9 @@
         }
     }
 
+    /**
+     * @hide
+     */
     protected void resetResolvedDrawables() {
         mResolvedDrawables = false;
     }
diff --git a/core/java/com/android/internal/widget/RotarySelector.java b/core/java/com/android/internal/widget/RotarySelector.java
index a2a38dc..4e405f4 100644
--- a/core/java/com/android/internal/widget/RotarySelector.java
+++ b/core/java/com/android/internal/widget/RotarySelector.java
@@ -25,7 +25,9 @@
 import android.graphics.BitmapFactory;
 import android.graphics.Matrix;
 import android.graphics.drawable.Drawable;
+import android.os.UserHandle;
 import android.os.Vibrator;
+import android.provider.Settings;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.MotionEvent;
@@ -667,11 +669,16 @@
      * Triggers haptic feedback.
      */
     private synchronized void vibrate(long duration) {
-        if (mVibrator == null) {
-            mVibrator = (android.os.Vibrator)
-                    getContext().getSystemService(Context.VIBRATOR_SERVICE);
+        final boolean hapticEnabled = Settings.System.getIntForUser(
+                mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1,
+                UserHandle.USER_CURRENT) != 0;
+        if (hapticEnabled) {
+            if (mVibrator == null) {
+                mVibrator = (android.os.Vibrator) getContext()
+                        .getSystemService(Context.VIBRATOR_SERVICE);
+            }
+            mVibrator.vibrate(duration);
         }
-        mVibrator.vibrate(duration);
     }
 
     /**
diff --git a/core/java/com/android/internal/widget/SlidingTab.java b/core/java/com/android/internal/widget/SlidingTab.java
index f535a08..aebc4f6 100644
--- a/core/java/com/android/internal/widget/SlidingTab.java
+++ b/core/java/com/android/internal/widget/SlidingTab.java
@@ -21,7 +21,9 @@
 import android.content.res.TypedArray;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
+import android.os.UserHandle;
 import android.os.Vibrator;
+import android.provider.Settings;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.Gravity;
@@ -811,11 +813,16 @@
      * Triggers haptic feedback.
      */
     private synchronized void vibrate(long duration) {
-        if (mVibrator == null) {
-            mVibrator = (android.os.Vibrator)
-                    getContext().getSystemService(Context.VIBRATOR_SERVICE);
+        final boolean hapticEnabled = Settings.System.getIntForUser(
+                mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1,
+                UserHandle.USER_CURRENT) != 0;
+        if (hapticEnabled) {
+            if (mVibrator == null) {
+                mVibrator = (android.os.Vibrator) getContext()
+                        .getSystemService(Context.VIBRATOR_SERVICE);
+            }
+            mVibrator.vibrate(duration);
         }
-        mVibrator.vibrate(duration);
     }
 
     /**
diff --git a/core/java/com/android/internal/widget/WaveView.java b/core/java/com/android/internal/widget/WaveView.java
index 2d89234..d33d50c 100644
--- a/core/java/com/android/internal/widget/WaveView.java
+++ b/core/java/com/android/internal/widget/WaveView.java
@@ -25,7 +25,9 @@
 import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
 import android.graphics.drawable.BitmapDrawable;
+import android.os.UserHandle;
 import android.os.Vibrator;
+import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -573,11 +575,16 @@
      * Triggers haptic feedback.
      */
     private synchronized void vibrate(long duration) {
-        if (mVibrator == null) {
-            mVibrator = (android.os.Vibrator)
-                    getContext().getSystemService(Context.VIBRATOR_SERVICE);
+        final boolean hapticEnabled = Settings.System.getIntForUser(
+                mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1,
+                UserHandle.USER_CURRENT) != 0;
+        if (hapticEnabled) {
+            if (mVibrator == null) {
+                mVibrator = (android.os.Vibrator) getContext()
+                        .getSystemService(Context.VIBRATOR_SERVICE);
+            }
+            mVibrator.vibrate(duration);
         }
-        mVibrator.vibrate(duration);
     }
 
     /**
diff --git a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java
index f507a79..0f49776 100644
--- a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java
+++ b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java
@@ -31,7 +31,9 @@
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
+import android.os.UserHandle;
 import android.os.Vibrator;
+import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -543,7 +545,10 @@
     }
 
     private void vibrate() {
-        if (mVibrator != null) {
+        final boolean hapticEnabled = Settings.System.getIntForUser(
+                mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1,
+                UserHandle.USER_CURRENT) != 0;
+        if (mVibrator != null && hapticEnabled) {
             mVibrator.vibrate(mVibrationDuration);
         }
     }
diff --git a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
index 7990b4c..e22d1e8 100644
--- a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
+++ b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
@@ -32,7 +32,9 @@
 import android.graphics.RectF;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
+import android.os.UserHandle;
 import android.os.Vibrator;
+import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -593,7 +595,10 @@
     }
 
     private void vibrate() {
-        if (mVibrator != null) {
+        final boolean hapticEnabled = Settings.System.getIntForUser(
+                mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1,
+                UserHandle.USER_CURRENT) != 0;
+        if (mVibrator != null && hapticEnabled) {
             mVibrator.vibrate(mVibrationDuration);
         }
     }
diff --git a/core/res/res/layout-land/keyguard_glow_pad_container.xml b/core/res/res/layout-land/keyguard_glow_pad_container.xml
new file mode 100644
index 0000000..f8364f1
--- /dev/null
+++ b/core/res/res/layout-land/keyguard_glow_pad_container.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2012, 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.
+*/
+-->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+    <include layout="@layout/keyguard_glow_pad_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center" />
+</merge>
\ No newline at end of file
diff --git a/core/res/res/layout-port/keyguard_host_view.xml b/core/res/res/layout-port/keyguard_host_view.xml
index 3ce9365..20726d0 100644
--- a/core/res/res/layout-port/keyguard_host_view.xml
+++ b/core/res/res/layout-port/keyguard_host_view.xml
@@ -29,15 +29,14 @@
 
     <include layout="@layout/keyguard_widget_region"
         android:layout_width="match_parent"
-        android:layout_height="0dip"
-        android:layout_weight="27" />
+        android:layout_height="153dp" />
 
     <com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper
         android:id="@+id/view_flipper"
         android:layout_height="0dp"
         android:clipChildren="false"
         android:clipToPadding="false"
-        android:layout_weight="73"
+        android:layout_weight="1"
         android:paddingLeft="@dimen/keyguard_security_view_margin"
         android:paddingTop="@dimen/keyguard_security_view_margin"
         android:paddingRight="@dimen/keyguard_security_view_margin"
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml b/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml
index 4f94f96..47d4728 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml
@@ -89,7 +89,6 @@
                     android:layout_weight="1"
                     android:gravity="center"
                     android:layout_gravity="center"
-                    android:layout_marginStart="@dimen/keyguard_lockscreen_pin_margin_left"
                     android:singleLine="true"
                     android:textStyle="normal"
                     android:inputType="textPassword"
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml b/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml
index 9a649fbb..6dd85cb 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml
@@ -93,7 +93,6 @@
                     android:inputType="textPassword"
                     android:gravity="center"
                     android:layout_gravity="center"
-                    android:layout_marginStart="@dimen/keyguard_lockscreen_pin_margin_left"
                     android:textSize="24sp"
                     android:textAppearance="?android:attr/textAppearanceMedium"
                     android:background="@null"
diff --git a/core/res/res/layout/keyguard_emergency_carrier_area.xml b/core/res/res/layout/keyguard_emergency_carrier_area.xml
index c16955c..f9a593f 100644
--- a/core/res/res/layout/keyguard_emergency_carrier_area.xml
+++ b/core/res/res/layout/keyguard_emergency_carrier_area.xml
@@ -23,7 +23,7 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
-    android:gravity="center_horizontal"
+    android:gravity="center"
     android:layout_gravity="center_horizontal"
     android:layout_alignParentBottom="true">
 
diff --git a/core/res/res/layout/keyguard_glow_pad_container.xml b/core/res/res/layout/keyguard_glow_pad_container.xml
index f8364f1..376d0e9 100644
--- a/core/res/res/layout/keyguard_glow_pad_container.xml
+++ b/core/res/res/layout/keyguard_glow_pad_container.xml
@@ -21,5 +21,6 @@
     <include layout="@layout/keyguard_glow_pad_view"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_gravity="center" />
+        android:layout_gravity="bottom|center_horizontal"
+        android:layout_marginBottom="-80dp"/>
 </merge>
\ No newline at end of file
diff --git a/core/res/res/layout/keyguard_password_view.xml b/core/res/res/layout/keyguard_password_view.xml
index 92a7551..ab8aa85 100644
--- a/core/res/res/layout/keyguard_password_view.xml
+++ b/core/res/res/layout/keyguard_password_view.xml
@@ -26,11 +26,12 @@
 
     <FrameLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="0dp"
+        android:layout_weight="1">
 
         <LinearLayout
             android:layout_height="wrap_content"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:orientation="vertical"
             android:layout_gravity="center">
 
@@ -114,14 +115,14 @@
                     android:clickable="true"
                 />
             </LinearLayout>
-
-            <include layout="@layout/keyguard_emergency_carrier_area"
-                android:id="@+id/keyguard_selector_fade_container"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="vertical"
-                android:layout_gravity="bottom|center_horizontal"
-                android:gravity="center_horizontal" />
         </LinearLayout>
     </FrameLayout>
+    <include layout="@layout/keyguard_emergency_carrier_area"
+             android:id="@+id/keyguard_selector_fade_container"
+             android:layout_width="match_parent"
+             android:layout_height="wrap_content"
+             android:orientation="vertical"
+             android:layout_gravity="bottom|center_horizontal"
+             android:gravity="center_horizontal" />
+
 </com.android.internal.policy.impl.keyguard.KeyguardPasswordView>
diff --git a/core/res/res/layout/keyguard_screen_password_landscape.xml b/core/res/res/layout/keyguard_screen_password_landscape.xml
index e0a3ce3..80d9d61 100644
--- a/core/res/res/layout/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_password_landscape.xml
@@ -143,7 +143,6 @@
             android:layout_width="0dip"
             android:layout_weight="1"
             android:gravity="center"
-            android:layout_marginStart="@dimen/keyguard_lockscreen_pin_margin_left"
             android:layout_gravity="center_vertical"
             android:singleLine="true"
             android:textStyle="normal"
diff --git a/core/res/res/layout/keyguard_screen_password_portrait.xml b/core/res/res/layout/keyguard_screen_password_portrait.xml
index 0212f73..3d61bae 100644
--- a/core/res/res/layout/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_password_portrait.xml
@@ -106,12 +106,10 @@
         android:layout_marginEnd="16dip">
 
         <EditText android:id="@+id/passwordEntry"
-            android:layout_width="0dip"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_weight="1"
             android:gravity="center_horizontal"
             android:layout_gravity="center_vertical"
-            android:layout_marginStart="@dimen/keyguard_lockscreen_pin_margin_left"
             android:singleLine="true"
             android:textStyle="normal"
             android:inputType="textPassword"
diff --git a/core/res/res/layout/keyguard_selector_view.xml b/core/res/res/layout/keyguard_selector_view.xml
index 4838c2a..daaf35b 100644
--- a/core/res/res/layout/keyguard_selector_view.xml
+++ b/core/res/res/layout/keyguard_selector_view.xml
@@ -41,10 +41,8 @@
         <include layout="@layout/keyguard_emergency_carrier_area"
             android:id="@+id/keyguard_selector_fade_container"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical"
-            android:layout_gravity="bottom|center_horizontal"
-            android:gravity="center_horizontal" />
+            android:layout_height="48dp"
+            android:layout_gravity="bottom|center_horizontal" />
     </FrameLayout>
 
 </com.android.internal.policy.impl.keyguard.KeyguardSelectorView>
diff --git a/core/res/res/layout/keyguard_status_view.xml b/core/res/res/layout/keyguard_status_view.xml
index a462c54..1de0f6c 100644
--- a/core/res/res/layout/keyguard_status_view.xml
+++ b/core/res/res/layout/keyguard_status_view.xml
@@ -33,28 +33,32 @@
         android:gravity="center_horizontal|top"
         android:contentDescription="@*android:string/keyguard_accessibility_status">
 
-        <com.android.internal.policy.impl.keyguard.ClockView
-            android:id="@+id/clock_view"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/kg_clock_top_margin"
-            android:layout_marginEnd="@dimen/kg_status_line_font_right_margin"
-            android:layout_gravity="right">
-
-            <TextView android:id="@+id/clock_text"
+        <LinearLayout android:layout_width="match_parent"
+                      android:layout_height="wrap_content"
+                      android:layout_gravity="center_vertical"
+                      android:orientation="vertical">
+            <com.android.internal.policy.impl.keyguard.ClockView
+                android:id="@+id/clock_view"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:singleLine="true"
-                android:ellipsize="none"
-                android:textSize="@dimen/kg_status_clock_font_size"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:textColor="#ffffffff"
-                android:drawablePadding="2dip"
-                />
+                android:layout_marginEnd="@dimen/kg_status_line_font_right_margin"
+                android:layout_gravity="right">
 
-        </com.android.internal.policy.impl.keyguard.ClockView>
+                <TextView android:id="@+id/clock_text"
+                          android:layout_width="wrap_content"
+                          android:layout_height="wrap_content"
+                          android:singleLine="true"
+                          android:ellipsize="none"
+                          android:textSize="@dimen/kg_status_clock_font_size"
+                          android:textAppearance="?android:attr/textAppearanceMedium"
+                          android:textColor="#ffffffff"
+                          android:drawablePadding="2dip"
+                          />
 
-        <include layout="@layout/keyguard_status_area" />
+            </com.android.internal.policy.impl.keyguard.ClockView>
+
+            <include layout="@layout/keyguard_status_area" />
+        </LinearLayout>
 
     </com.android.internal.policy.impl.keyguard.KeyguardStatusView>
 </com.android.internal.policy.impl.keyguard.KeyguardWidgetFrame>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 31d4ad7..948a3d3 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -291,10 +291,10 @@
     <dimen name="kg_widget_pager_horizontal_padding">16dp</dimen>
 
     <!-- Top padding for the widget pager -->
-    <dimen name="kg_widget_pager_top_padding">16dp</dimen>
+    <dimen name="kg_widget_pager_top_padding">0dp</dimen>
 
     <!-- Bottom padding for the widget pager -->
-    <dimen name="kg_widget_pager_bottom_padding">6dp</dimen>
+    <dimen name="kg_widget_pager_bottom_padding">0dp</dimen>
 
     <!-- Top margin for the runway lights. We add a negative margin in large
         devices to account for the widget pager padding -->
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index e812ccb..46c4398 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -191,28 +191,21 @@
       <li><a href="<?cs var:toroot ?>guide/topics/ui/menus.html">
           <span class="en">Menus</span></span>
           </a></li>
-      <li><a href="<?cs var:toroot ?>guide/topics/ui/dialogs.html">
-           <span class="en">Dialogs</span>
-          </a></li>
       <li><a href="<?cs var:toroot ?>guide/topics/ui/actionbar.html">
            <span class="en">Action Bar</span>
           </a></li>
       <li><a href="<?cs var:toroot ?>guide/topics/ui/settings.html">
             <span class="en">Settings</span>
           </a></li>
-      <li class="nav-section">
-          <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/index.html">
-              <span class="en">Notifications</span>
-            </a></div>
-          <ul>
-          <li><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/toasts.html">
-              <span class="en">Toast Notifications</span>
-            </a></li>
-          <li><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/notifications.html">
-              <span class="en">Status Notifications</span>
-            </a></li>
-          </ul>
-      </li>
+      <li><a href="<?cs var:toroot ?>guide/topics/ui/dialogs.html">
+           <span class="en">Dialogs</span>
+          </a></li>
+      <li><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/notifications.html">
+          <span class="en">Notifications</span>
+        </a></li>
+      <li><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/toasts.html">
+          <span class="en">Toasts</span>
+        </a></li>
       <li class="nav-section">
         <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/search/index.html">
             <span class="en">Search</span>
diff --git a/docs/html/guide/topics/ui/notifiers/notifications.jd b/docs/html/guide/topics/ui/notifiers/notifications.jd
index fbff532..2de6260 100644
--- a/docs/html/guide/topics/ui/notifiers/notifications.jd
+++ b/docs/html/guide/topics/ui/notifiers/notifications.jd
@@ -4,26 +4,43 @@
 <div id="qv-wrapper">
 <div id="qv">
 <h2>In this document</h2>
+<ol>
+  <li><a href="#NotificationUI">Notification Display Elements</a>
     <ol>
-        <li>
-            <a href="#NotificationUI">Notification Display Elements</a>
-        </li>
-        <li>
-        <a href="#CreateNotification">Creating a Notification</a>
-        </li>
-        <li>
-            <a href="#Managing">Managing Notifications</a>
-        </li>
-        <li>
-            <a href="#NotificationResponse">Preserving Navigation when Starting an Activity</a>
-        </li>
-        <li>
-            <a href="#Progress">Displaying Progress in a Notification</a>
-        </li>
-        <li>
-            <a href="#CustomNotification">Custom Notification Layouts</a>
-        </li>
+      <li><a href="#NormalNotify">Normal view</a></li>
+      <li><a href="#BigNotify">Big view</a></li>
     </ol>
+  </li>
+  <li><a href="#CreateNotification">Creating a Notification</a>
+    <ol>
+      <li><a href="#Required">Required notification contents</a></li>
+      <li><a href="#Optional">Optional notification contents and settings</a></li>
+      <li><a href="#Actions">Notification actions</a></li>
+      <li><a href="#SimpleNotification">Creating a simple notification</a></li>
+      <li><a href="#ApplyStyle">Applying a big view style to a notification</a></li>
+    </ol>
+  </li>
+  <li><a href="#Managing">Managing Notifications</a>
+    <ol>
+      <li><a href="#Updating">Updating notifications</a></li>
+      <li><a href="#Removing">Removing notifications</a></li>
+    </ol>
+  </li>
+  <li><a href="#NotificationResponse">Preserving Navigation when Starting an Activity</a>
+    <ol>
+      <li><a href="#DirectEntry">Setting up a regular activity PendingIntent</a></li>
+      <li><a href="#ExtendedNotification">Setting up a special activity PendingIntent</a></li>
+    </ol>
+  </li>
+  <li><a href="#Progress">Displaying Progress in a Notification</a>
+    <ol>
+      <li><a href="#FixedProgress">Displaying a fixed-duration progress indicator</a></li>
+      <li><a href="#ActivityIndicator">Displaying a continuing activity indicator</a></li>
+    </ol>
+  </li>
+  <li><a href="#CustomNotification">Custom Notification Layouts</a></li>
+</ol>
+
     <h2>Key classes</h2>
     <ol>
         <li>{@link android.app.NotificationManager}</li>
@@ -54,13 +71,12 @@
 <img
     id="figure1"
     src="{@docRoot}images/ui/notifications/iconic_notification.png"
-    height="32"
-    alt="" />
+    height="120" alt="" />
 <p class="img-caption">
     <strong>Figure 1.</strong> Notifications in the notification area.
 </p>
 <img id="figure2" src="{@docRoot}images/ui/notifications/normal_notification.png"
-    height="240" alt="" />
+     height="293" alt="" />
 <p class="img-caption">
     <strong>Figure 2.</strong> Notifications in the notification drawer.
 </p>
@@ -98,7 +114,7 @@
 <img
     src="{@docRoot}images/ui/notifications/normal_notification_callouts.png"
     alt=""
-    height="204"
+    height="153"
     id="figure3" />
 <p class="img-caption">
   <strong>Figure 3.</strong> Notification in normal view.
diff --git a/docs/html/guide/topics/ui/notifiers/toasts.jd b/docs/html/guide/topics/ui/notifiers/toasts.jd
index 1a1fb1f..92c146a 100644
--- a/docs/html/guide/topics/ui/notifiers/toasts.jd
+++ b/docs/html/guide/topics/ui/notifiers/toasts.jd
@@ -1,17 +1,8 @@
-page.title=Toast Notifications
-parent.title=Notifications
-parent.link=index.html
+page.title=Toasts
 @jd:body
 
 <div id="qv-wrapper">
-  <div id="qv">
-    <h2>Quickview</h2>
-    <ol>
-      <li>A toast is a message that appears on the surface of the screen for a moment, but it
-does not take focus (or pause the current activity), so it cannot accept user input</li>
-      <li>You can customize the toast layout to include images</li>
-    </ol>
-    
+  <div id="qv">    
     <h2>In this document</h2>
     <ol>
       <li><a href="#Basics">The Basics</a></li>
@@ -26,22 +17,17 @@
   </div>
 </div>
 
-<p>A toast notification is a message that pops up on the surface of the window.
-It only fills the amount of space required for the message and the user's current
-activity remains visible and interactive. The notification automatically fades in and 
-out, and does not accept interaction events.</p>
+<p>A toast provides simple feedback about an operation in a small popup.
+It only fills the amount of space required for the message and the current
+activity remains visible and interactive. 
+For example, navigating away from an email before you send it triggers a 
+"Draft saved" toast to let you know that you can continue editing later. 
+Toasts automatically disappear after a timeout.</p>
 
-<p>The screenshot below shows an example toast notification from the Alarm application.
-Once an alarm is turned on, a toast is displayed to assure you that the 
-alarm was set.</p>
 <img src="{@docRoot}images/toast.png" alt="" />
 
-<p>A toast can be created and displayed from an {@link android.app.Activity} or 
-{@link android.app.Service}. If you create a toast notification from a Service, it
-appears in front of the Activity currently in focus.</p>
-
-<p>If user response to the notification is required, consider using a 
-<a href="notifications.html">Status Bar Notification</a>.</p>
+<p>If user response to a status message is required, consider instead using a 
+<a href="{@docRoot}guide/topics/ui/notifiers/notifications.html">Notification</a>.</p>
 
 
 <h2 id="Basics">The Basics</h2>
@@ -90,8 +76,6 @@
 
 <h2 id="CustomToastView">Creating a Custom Toast View</h2>
 
-<img src="{@docRoot}images/custom_toast.png" alt="" style="float:right" />
-
 <p>If a simple text message isn't enough, you can create a customized layout for your
 toast notification. To create a custom layout, define a View layout,
 in XML or in your application code, and pass the root {@link android.view.View} object
@@ -105,17 +89,17 @@
               android:orientation="horizontal"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
-              android:padding="10dp"
+              android:padding="8dp"
               android:background="#DAAA"
               >
-    &lt;ImageView android:id="@+id/image"
+    &lt;ImageView android:src="@drawable/droid"
                android:layout_width="wrap_content"
-               android:layout_height="fill_parent"
-               android:layout_marginRight="10dp"
+               android:layout_height="wrap_content"
+               android:layout_marginRight="8dp"
                />
     &lt;TextView android:id="@+id/text"
               android:layout_width="wrap_content"
-              android:layout_height="fill_parent"
+              android:layout_height="wrap_content"
               android:textColor="#FFF"
               />
 &lt;/LinearLayout>
@@ -126,13 +110,11 @@
 
 <pre>
 LayoutInflater inflater = getLayoutInflater();
-View layout = inflater.inflate(R.layout.toast_layout,
+View layout = inflater.inflate(R.layout.custom_toast,
                                (ViewGroup) findViewById(R.id.toast_layout_root));
 
-ImageView image = (ImageView) layout.findViewById(R.id.image);
-image.setImageResource(R.drawable.android);
 TextView text = (TextView) layout.findViewById(R.id.text);
-text.setText("Hello! This is a custom toast!");
+text.setText("This is a custom toast");
 
 Toast toast = new Toast(getApplicationContext());
 toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
diff --git a/docs/html/images/toast.png b/docs/html/images/toast.png
index 223048a..b4c709a 100644
--- a/docs/html/images/toast.png
+++ b/docs/html/images/toast.png
Binary files differ
diff --git a/docs/html/images/ui/notifications/iconic_notification.png b/docs/html/images/ui/notifications/iconic_notification.png
index 4cabfdb..e72fe4e 100644
--- a/docs/html/images/ui/notifications/iconic_notification.png
+++ b/docs/html/images/ui/notifications/iconic_notification.png
Binary files differ
diff --git a/docs/html/images/ui/notifications/normal_notification.png b/docs/html/images/ui/notifications/normal_notification.png
index 3cf0231..9bea5fb 100644
--- a/docs/html/images/ui/notifications/normal_notification.png
+++ b/docs/html/images/ui/notifications/normal_notification.png
Binary files differ
diff --git a/docs/html/images/ui/notifications/normal_notification_callouts.png b/docs/html/images/ui/notifications/normal_notification_callouts.png
index db57daf..6880e90 100644
--- a/docs/html/images/ui/notifications/normal_notification_callouts.png
+++ b/docs/html/images/ui/notifications/normal_notification_callouts.png
Binary files differ
diff --git a/graphics/java/android/renderscript/ScriptGroup.java b/graphics/java/android/renderscript/ScriptGroup.java
index 8943f75..7afdb39 100644
--- a/graphics/java/android/renderscript/ScriptGroup.java
+++ b/graphics/java/android/renderscript/ScriptGroup.java
@@ -77,7 +77,6 @@
         ArrayList<Script.KernelID> mKernels = new ArrayList<Script.KernelID>();
         ArrayList<ConnectLine> mInputs = new ArrayList<ConnectLine>();
         ArrayList<ConnectLine> mOutputs = new ArrayList<ConnectLine>();
-        boolean mSeen;
         int dagNumber;
 
         Node mNext;
@@ -176,39 +175,24 @@
             mRS = rs;
         }
 
-        private void validateCycleRecurse(Node n, int depth) {
-            n.mSeen = true;
-
-            //android.util.Log.v("RSR", " validateCycleRecurse outputCount " + n.mOutputs.size());
-            for (int ct=0; ct < n.mOutputs.size(); ct++) {
-                final ConnectLine cl = n.mOutputs.get(ct);
+        // do a DFS from original node, looking for original node
+        // any cycle that could be created must contain original node
+        private void validateCycle(Node target, Node original) {
+            for (int ct = 0; ct < target.mOutputs.size(); ct++) {
+                final ConnectLine cl = target.mOutputs.get(ct);
                 if (cl.mToK != null) {
                     Node tn = findNode(cl.mToK.mScript);
-                    if (tn.mSeen) {
+                    if (tn.equals(original)) {
                         throw new RSInvalidStateException("Loops in group not allowed.");
                     }
-                    validateCycleRecurse(tn, depth + 1);
+                    validateCycle(tn, original);
                 }
                 if (cl.mToF != null) {
                     Node tn = findNode(cl.mToF.mScript);
-                    if (tn.mSeen) {
+                    if (tn.equals(original)) {
                         throw new RSInvalidStateException("Loops in group not allowed.");
                     }
-                    validateCycleRecurse(tn, depth + 1);
-                }
-            }
-        }
-
-        private void validateCycle() {
-            //android.util.Log.v("RSR", "validateCycle");
-
-            for (int ct=0; ct < mNodes.size(); ct++) {
-                for (int ct2=0; ct2 < mNodes.size(); ct2++) {
-                    mNodes.get(ct2).mSeen = false;
-                }
-                Node n = mNodes.get(ct);
-                if (n.mInputs.size() == 0) {
-                    validateCycleRecurse(n, 0);
+                    validateCycle(tn, original);
                 }
             }
         }
@@ -327,7 +311,7 @@
 
             Node nf = findNode(from);
             if (nf == null) {
-                throw new RSInvalidStateException("From kernel not found.");
+                throw new RSInvalidStateException("From script not found.");
             }
 
             Node nt = findNode(to.mScript);
@@ -341,7 +325,7 @@
             nf.mOutputs.add(cl);
             nt.mInputs.add(cl);
 
-            validateCycle();
+            validateCycle(nf, nf);
             return this;
         }
 
@@ -362,7 +346,7 @@
 
             Node nf = findNode(from);
             if (nf == null) {
-                throw new RSInvalidStateException("From kernel not found.");
+                throw new RSInvalidStateException("From script not found.");
             }
 
             Node nt = findNode(to);
@@ -376,7 +360,7 @@
             nf.mOutputs.add(cl);
             nt.mInputs.add(cl);
 
-            validateCycle();
+            validateCycle(nf, nf);
             return this;
         }
 
diff --git a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
index 2cf795d..87d56fd 100644
--- a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
+++ b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java
@@ -42,16 +42,7 @@
     private static final String NETWORK = LocationManager.NETWORK_PROVIDER;
     private static final String GPS = LocationManager.GPS_PROVIDER;
 
-    // threshold below which a location is considered stale enough
-    // that we shouldn't use its bearing, altitude, speed etc
-    private static final double WEIGHT_THRESHOLD = 0.5;
-    // accuracy in meters at which a Location's weight is halved (compared to 0 accuracy)
-    private static final double ACCURACY_HALFLIFE_M = 20.0;
-    // age in seconds at which a Location's weight is halved (compared to 0 age)
-    private static final double AGE_HALFLIFE_S = 60.0;
-
-    private static final double ACCURACY_DECAY_CONSTANT_M = Math.log(2) / ACCURACY_HALFLIFE_M;
-    private static final double AGE_DECAY_CONSTANT_S = Math.log(2) / AGE_HALFLIFE_S;
+    public static final long SWITCH_ON_FRESHNESS_CLIFF_NS = 11 * 1000000000; // 11 seconds
 
     private final Context mContext;
     private final LocationManager mLocationManager;
@@ -62,8 +53,6 @@
     private Location mFusedLocation;
     private Location mGpsLocation;
     private Location mNetworkLocation;
-    private double mNetworkWeight;
-    private double mGpsWeight;
 
     private boolean mEnabled;
     private ProviderRequestUnbundled mRequest;
@@ -102,10 +91,6 @@
         Log.i(TAG, "engine stopped (" + mContext.getPackageName() + ")");
     }
 
-    private boolean isAvailable() {
-        return mStats.get(GPS).available || mStats.get(NETWORK).available;
-    }
-
     /** Called on mLooper thread */
     public void enable() {
         mEnabled = true;
@@ -130,7 +115,6 @@
         public boolean requested;
         public long requestTime;
         public long minTime;
-        public long lastRequestTtff;
         @Override
         public String toString() {
             StringBuilder s = new StringBuilder();
@@ -171,9 +155,6 @@
             return;
         }
 
-        ProviderStats gpsStats = mStats.get(GPS);
-        ProviderStats networkStats = mStats.get(NETWORK);
-
         long networkInterval = Long.MAX_VALUE;
         long gpsInterval = Long.MAX_VALUE;
         for (LocationRequest request : mRequest.getLocationRequests()) {
@@ -209,104 +190,46 @@
         }
     }
 
-    private static double weighAccuracy(Location loc) {
-        double accuracy = loc.getAccuracy();
-        return Math.exp(-accuracy * ACCURACY_DECAY_CONSTANT_M);
-    }
+    /**
+     * Test whether one location (a) is better to use than another (b).
+     */
+    private static boolean isBetterThan(Location locationA, Location locationB) {
+      if (locationA == null) {
+        return false;
+      }
+      if (locationB == null) {
+        return true;
+      }
+      // A provider is better if the reading is sufficiently newer.  Heading
+      // underground can cause GPS to stop reporting fixes.  In this case it's
+      // appropriate to revert to cell, even when its accuracy is less.
+      if (locationA.getElapsedRealtimeNanos() > locationB.getElapsedRealtimeNanos() + SWITCH_ON_FRESHNESS_CLIFF_NS) {
+        return true;
+      }
 
-    private static double weighAge(Location loc) {
-        long ageSeconds = SystemClock.elapsedRealtimeNanos() - loc.getElapsedRealtimeNanos();
-        ageSeconds /= 1000000000L;
-        if (ageSeconds < 0) ageSeconds = 0;
-        return Math.exp(-ageSeconds * AGE_DECAY_CONSTANT_S);
-    }
-
-    private double weigh(double gps, double network) {
-        return (gps * mGpsWeight) + (network * mNetworkWeight);
-    }
-
-    private double weigh(double gps, double network, double wrapMin, double wrapMax) {
-        // apply aliasing
-        double wrapWidth = wrapMax - wrapMin;
-        if (gps - network > wrapWidth / 2) network += wrapWidth;
-        else if (network - gps > wrapWidth / 2) gps += wrapWidth;
-
-        double result = weigh(gps, network);
-
-        // remove aliasing
-        if (result > wrapMax) result -= wrapWidth;
-        return result;
+      // A provider is better if it has better accuracy.  Assuming both readings
+      // are fresh (and by that accurate), choose the one with the smaller
+      // accuracy circle.
+      if (!locationA.hasAccuracy()) {
+        return false;
+      }
+      if (!locationB.hasAccuracy()) {
+        return true;
+      }
+      return locationA.getAccuracy() < locationB.getAccuracy();
     }
 
     private void updateFusedLocation() {
-        // naive fusion
-        mNetworkWeight = weighAccuracy(mNetworkLocation) * weighAge(mNetworkLocation);
-        mGpsWeight = weighAccuracy(mGpsLocation) * weighAge(mGpsLocation);
-        // scale mNetworkWeight and mGpsWeight so that they add to 1
-        double totalWeight = mNetworkWeight + mGpsWeight;
-        mNetworkWeight /= totalWeight;
-        mGpsWeight /= totalWeight;
-
-        Location fused = new Location(LocationManager.FUSED_PROVIDER);
-        // fuse lat/long
-        // assumes the two locations are close enough that earth curvature doesn't matter
-        fused.setLatitude(weigh(mGpsLocation.getLatitude(), mNetworkLocation.getLatitude()));
-        fused.setLongitude(weigh(mGpsLocation.getLongitude(), mNetworkLocation.getLongitude(),
-                -180.0, 180.0));
-
-        // fused accuracy
-        //TODO: use some real math instead of this crude fusion
-        // one suggestion is to fuse in a quadratic manner, eg
-        // sqrt(weigh(gpsAcc^2, netAcc^2)).
-        // another direction to explore is to consider the difference in the 2
-        // locations. If the component locations overlap, the fused accuracy is
-        // better than the component accuracies. If they are far apart,
-        // the fused accuracy is much worse.
-        fused.setAccuracy((float)weigh(mGpsLocation.getAccuracy(), mNetworkLocation.getAccuracy()));
-
-        // fused time - now
-        fused.setTime(System.currentTimeMillis());
-        fused.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
-
-        // fuse altitude
-        if (mGpsLocation.hasAltitude() && !mNetworkLocation.hasAltitude() &&
-                mGpsWeight > WEIGHT_THRESHOLD) {
-            fused.setAltitude(mGpsLocation.getAltitude());   // use GPS
-        } else if (!mGpsLocation.hasAltitude() && mNetworkLocation.hasAltitude() &&
-                mNetworkWeight > WEIGHT_THRESHOLD) {
-            fused.setAltitude(mNetworkLocation.getAltitude());   // use Network
-        } else if (mGpsLocation.hasAltitude() && mNetworkLocation.hasAltitude()) {
-            fused.setAltitude(weigh(mGpsLocation.getAltitude(), mNetworkLocation.getAltitude()));
+        // may the best location win!
+        if (isBetterThan(mGpsLocation, mNetworkLocation)) {
+            mFusedLocation = new Location(mGpsLocation);
+        } else {
+            mFusedLocation = new Location(mNetworkLocation);
         }
-
-        // fuse speed
-        if (mGpsLocation.hasSpeed() && !mNetworkLocation.hasSpeed() &&
-                mGpsWeight > WEIGHT_THRESHOLD) {
-            fused.setSpeed(mGpsLocation.getSpeed());   // use GPS if its not too old
-        } else if (!mGpsLocation.hasSpeed() && mNetworkLocation.hasSpeed() &&
-                mNetworkWeight > WEIGHT_THRESHOLD) {
-            fused.setSpeed(mNetworkLocation.getSpeed());   // use Network
-        } else if (mGpsLocation.hasSpeed() && mNetworkLocation.hasSpeed()) {
-            fused.setSpeed((float)weigh(mGpsLocation.getSpeed(), mNetworkLocation.getSpeed()));
-        }
-
-        // fuse bearing
-        if (mGpsLocation.hasBearing() && !mNetworkLocation.hasBearing() &&
-                mGpsWeight > WEIGHT_THRESHOLD) {
-            fused.setBearing(mGpsLocation.getBearing());   // use GPS if its not too old
-        } else if (!mGpsLocation.hasBearing() && mNetworkLocation.hasBearing() &&
-                mNetworkWeight > WEIGHT_THRESHOLD) {
-            fused.setBearing(mNetworkLocation.getBearing());   // use Network
-        } else if (mGpsLocation.hasBearing() && mNetworkLocation.hasBearing()) {
-            fused.setBearing((float)weigh(mGpsLocation.getBearing(), mNetworkLocation.getBearing(),
-                    0.0, 360.0));
-        }
-
         if (mNetworkLocation != null) {
-            fused.setExtraLocation(Location.EXTRA_NO_GPS_LOCATION, mNetworkLocation);
+            mFusedLocation.setExtraLocation(Location.EXTRA_NO_GPS_LOCATION, mNetworkLocation);
         }
-
-        mFusedLocation = fused;
+        mFusedLocation.setProvider(LocationManager.FUSED_PROVIDER);
 
         mCallback.reportLocation(mFusedLocation);
     }
@@ -349,9 +272,9 @@
         StringBuilder s = new StringBuilder();
         s.append("mEnabled=" + mEnabled).append(' ').append(mRequest).append('\n');
         s.append("fused=").append(mFusedLocation).append('\n');
-        s.append(String.format("gps %.3f %s\n", mGpsWeight, mGpsLocation));
+        s.append(String.format("gps %s\n", mGpsLocation));
         s.append("    ").append(mStats.get(GPS)).append('\n');
-        s.append(String.format("net %.3f %s\n", mNetworkWeight, mNetworkLocation));
+        s.append(String.format("net %s\n", mNetworkLocation));
         s.append("    ").append(mStats.get(NETWORK)).append('\n');
         pw.append(s);
     }
diff --git a/packages/SystemUI/res/anim/recent_app_enter.xml b/packages/SystemUI/res/anim/recent_app_enter.xml
deleted file mode 100644
index 4947eee..0000000
--- a/packages/SystemUI/res/anim/recent_app_enter.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-
-<!-- Special window zoom animation: this is the element that enters the screen,
-     it starts at 200% and scales down.  Goes with zoom_exit.xml. -->
-<set xmlns:android="http://schemas.android.com/apk/res/android"
-        android:interpolator="@android:anim/decelerate_interpolator">
-    <scale android:fromXScale="0.25" android:toXScale="1.0"
-           android:fromYScale="0.25" android:toYScale="1.0"
-           android:pivotX="0%p" android:pivotY="0%p"
-           android:duration="500" />
-    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
-            android:duration="500"/>
-</set>
diff --git a/packages/SystemUI/res/anim/recent_app_leave.xml b/packages/SystemUI/res/anim/recent_app_leave.xml
deleted file mode 100644
index 3d83988..0000000
--- a/packages/SystemUI/res/anim/recent_app_leave.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-
-<!-- Special window zoom animation: this is the element that enters the screen,
-     it starts at 200% and scales down.  Goes with zoom_exit.xml. -->
-<set xmlns:android="http://schemas.android.com/apk/res/android"
-        android:interpolator="@android:anim/decelerate_interpolator">
-    <scale android:fromXScale="1.0" android:toXScale="0.25"
-           android:fromYScale="1.0" android:toYScale="0.25"
-           android:pivotX="0%p" android:pivotY="0%p"
-           android:duration="500" />
-    <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
-            android:duration="500"/>
-</set>
diff --git a/packages/SystemUI/res/anim/recents_launch_from_launcher_enter.xml b/packages/SystemUI/res/anim/recents_launch_from_launcher_enter.xml
new file mode 100644
index 0000000..73ae9f2
--- /dev/null
+++ b/packages/SystemUI/res/anim/recents_launch_from_launcher_enter.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, 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.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+     android:detachWallpaper="true"
+     android:shareInterpolator="false"
+     android:zAdjustment="normal">
+  <!--scale android:fromXScale="2.0" android:toXScale="1.0"
+         android:fromYScale="2.0" android:toYScale="1.0"
+         android:interpolator="@android:interpolator/decelerate_cubic"
+         android:fillEnabled="true"
+         android:fillBefore="true" android:fillAfter="true"
+         android:pivotX="50%p" android:pivotY="50%p"
+         android:duration="250" /-->
+  <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
+         android:fillEnabled="true"
+         android:fillBefore="true" android:fillAfter="true"
+         android:interpolator="@android:interpolator/decelerate_cubic"
+         android:duration="250"/>
+</set>
diff --git a/packages/SystemUI/res/anim/recents_launch_from_launcher_exit.xml b/packages/SystemUI/res/anim/recents_launch_from_launcher_exit.xml
new file mode 100644
index 0000000..becc9d0
--- /dev/null
+++ b/packages/SystemUI/res/anim/recents_launch_from_launcher_exit.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, 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.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+     android:shareInterpolator="false"
+     android:zAdjustment="normal">
+  <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
+         android:fillEnabled="true"
+         android:fillBefore="true" android:fillAfter="true"
+         android:interpolator="@android:interpolator/decelerate_cubic"
+         android:duration="250"/>
+</set>
diff --git a/packages/SystemUI/res/anim/recents_return_to_launcher_enter.xml b/packages/SystemUI/res/anim/recents_return_to_launcher_enter.xml
new file mode 100644
index 0000000..efa9019
--- /dev/null
+++ b/packages/SystemUI/res/anim/recents_return_to_launcher_enter.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, 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.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+     android:shareInterpolator="false"
+     android:zAdjustment="normal">
+  <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
+         android:interpolator="@android:interpolator/decelerate_cubic"
+         android:duration="250"/>
+</set>
diff --git a/packages/SystemUI/res/anim/recents_return_to_launcher_exit.xml b/packages/SystemUI/res/anim/recents_return_to_launcher_exit.xml
new file mode 100644
index 0000000..e95e667
--- /dev/null
+++ b/packages/SystemUI/res/anim/recents_return_to_launcher_exit.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, 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.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+     android:shareInterpolator="false"
+     android:zAdjustment="normal">
+  <!--scale android:fromXScale="1.0" android:toXScale="2.0"
+         android:fromYScale="1.0" android:toYScale="2.0"
+         android:interpolator="@android:interpolator/decelerate_cubic"
+         android:pivotX="50%p" android:pivotY="50%p"
+         android:duration="250" /-->
+  <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
+         android:interpolator="@android:interpolator/decelerate_cubic"
+         android:duration="250"/>
+</set>
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_normal.png b/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_normal.png
new file mode 100644
index 0000000..3ed7418
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_normal.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_pressed.png b/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_pressed.png
new file mode 100644
index 0000000..5e20eea
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_pressed.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_normal.png b/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_normal.png
new file mode 100644
index 0000000..44cfc5b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_normal.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_pressed.png b/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_pressed.png
new file mode 100644
index 0000000..0c3fdcd
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_pressed.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_normal.png b/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_normal.png
new file mode 100644
index 0000000..80fdb79
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_normal.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_pressed.png b/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_pressed.png
new file mode 100644
index 0000000..ac7c1a7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_pressed.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/ic_notify_settings.xml b/packages/SystemUI/res/drawable/ic_notify_settings.xml
new file mode 100644
index 0000000..6579d8e
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_notify_settings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true"
+         android:drawable="@drawable/ic_notify_settings_pressed" />
+    <item
+         android:drawable="@drawable/ic_notify_settings_normal" />
+</selector>
+
diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
index f1a8d82..c921837 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
@@ -75,14 +75,14 @@
         android:layout_width="50dp"
         android:layout_height="50dp"
         android:scaleType="center"
-        android:src="@drawable/ic_notify_quicksettings"
+        android:src="@drawable/ic_notify_settings"
         android:contentDescription="@string/accessibility_settings_button"
         />
 
     <ImageView android:id="@+id/clear_all_button"
         android:layout_width="50dp"
         android:layout_height="50dp"
-        android:layout_marginLeft="18dp"
+        android:layout_marginLeft="12dp"
         android:scaleType="center"
         android:src="@drawable/ic_notify_clear"
         android:contentDescription="@string/accessibility_clear_all"
diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml
index 4b895ec..07aca6c 100644
--- a/packages/SystemUI/res/layout/super_status_bar.xml
+++ b/packages/SystemUI/res/layout/super_status_bar.xml
@@ -42,20 +42,11 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             />
-        <include layout="@layout/quick_settings"
+        <ViewStub android:id="@+id/quick_settings_stub"
+            android:layout="@layout/quick_settings"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             />
     </com.android.systemui.statusbar.phone.PanelHolder>
 
-    <ViewStub
-        android:layout="@layout/status_bar_help"
-        android:id="@+id/status_bar_cling_stub"
-        android:inflatedId="@+id/status_bar_cling"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_marginTop="@*android:dimen/status_bar_height"
-        android:visibility="gone"
-        />
-
 </com.android.systemui.statusbar.phone.StatusBarWindowView>
diff --git a/packages/SystemUI/res/values-sw600dp/config.xml b/packages/SystemUI/res/values-sw600dp/config.xml
index 209ad11..50575d0 100644
--- a/packages/SystemUI/res/values-sw600dp/config.xml
+++ b/packages/SystemUI/res/values-sw600dp/config.xml
@@ -20,6 +20,9 @@
 <!-- These resources are around just to allow their values to be customized
      for different hardware and product builds. -->
 <resources>
+    <!-- Enable quick settings on tablets -->
+    <bool name="config_hasSettingsPanel">true</bool>
+
     <!-- The number of columns in the QuickSettings -->
     <integer name="quick_settings_num_columns">3</integer>
 
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 942e814..aec9555 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -97,5 +97,7 @@
 
     <integer name="blinds_pop_duration_ms">10</integer>
 
+    <!-- Disable quick settings by default -->
+    <bool name="config_hasSettingsPanel">false</bool>
 </resources>
 
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 4bf6c10..4de0891 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -52,7 +52,7 @@
     <dimen name="status_bar_recents_item_padding">0dip</dimen>
     <!-- When recents first appears, how far the icon and label of the primary activity
          travel -->
-    <dimen name="status_bar_recents_app_icon_translate_distance">100dp</dimen>
+    <dimen name="status_bar_recents_app_icon_translate_distance">35dip</dimen>
 
     <!-- Where to place the app icon over the thumbnail -->
     <dimen name="status_bar_recents_app_icon_left_margin">0dp</dimen>
diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml
index 4a73200..2cc3446 100644
--- a/packages/SystemUI/res/values/ids.xml
+++ b/packages/SystemUI/res/values/ids.xml
@@ -19,4 +19,5 @@
     <item type="id" name="expandable_tag" />
     <item type="id" name="user_expanded_tag" />
     <item type="id" name="user_lock_tag" />
+    <item type="id" name="status_bar_cling_stub" />
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
index f71f554..bc61ab0 100644
--- a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
@@ -184,8 +184,8 @@
 
     private void vibrate() {
         Context context = getContext();
-        if (Settings.System.getInt(context.getContentResolver(),
-                Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) != 0) {
+        if (Settings.System.getIntForUser(context.getContentResolver(),
+                Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, UserHandle.USER_CURRENT) != 0) {
             Resources res = context.getResources();
             Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
             vibrator.vibrate(res.getInteger(R.integer.config_search_panel_view_vibration_duration));
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
index 79069b8..ef9f36e 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
@@ -18,6 +18,7 @@
 
 import android.app.Activity;
 import android.app.ActivityManager;
+import android.app.WallpaperManager;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -26,6 +27,7 @@
 import android.os.UserHandle;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.WindowManager;
 
 import com.android.systemui.R;
 import com.android.systemui.SystemUIApplication;
@@ -42,6 +44,7 @@
     private IntentFilter mIntentFilter;
     private boolean mShowing;
     private boolean mForeground;
+
     private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
@@ -79,6 +82,9 @@
 
     @Override
     public void onPause() {
+        overridePendingTransition(
+                R.anim.recents_return_to_launcher_enter,
+                R.anim.recents_return_to_launcher_exit);
         mForeground = false;
         super.onPause();
     }
@@ -92,8 +98,23 @@
         super.onStop();
     }
 
+    private void updateWallpaperVisibility(boolean visible) {
+        int wpflags = visible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0;
+        int curflags = getWindow().getAttributes().flags
+                & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
+        if (wpflags != curflags) {
+            getWindow().setFlags(wpflags, WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
+        }
+    }
+
     @Override
     public void onStart() {
+        // Hide wallpaper if it's not a static image
+        if (WallpaperManager.getInstance(this).getWallpaperInfo() != null) {
+            updateWallpaperVisibility(false);
+        } else {
+            updateWallpaperVisibility(true);
+        }
         mShowing = true;
         if (mRecentsPanel != null) {
             mRecentsPanel.refreshViews();
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index 8607508..57d2ed3 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -520,7 +520,7 @@
 
     public void onWindowAnimationStart() {
         if (mItemToAnimateInWhenWindowAnimationIsFinished != null) {
-            final int startDelay = 100;
+            final int startDelay = 150;
             final int duration = 250;
             final ViewHolder holder = mItemToAnimateInWhenWindowAnimationIsFinished;
             final TimeInterpolator cubic = new DecelerateInterpolator(1.5f);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 3e929d6..577b1f4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -485,7 +485,11 @@
                     | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
 
             if (firstTask == null) {
-                mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
+                ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext,
+                        R.anim.recents_launch_from_launcher_enter,
+                        R.anim.recents_launch_from_launcher_exit);
+                mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(
+                        UserHandle.USER_CURRENT));
             } else {
                 Bitmap first = firstTask.getThumbnail();
                 final Resources res = mContext.getResources();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
index 3fd413a..d0fc340 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
@@ -57,9 +57,9 @@
         mPanelHolder = ph;
         final int N = ph.getChildCount();
         for (int i=0; i<N; i++) {
-            final PanelView v = (PanelView) ph.getChildAt(i);
-            if (v != null) {
-                addPanel(v);
+            final View v = ph.getChildAt(i);
+            if (v != null && v instanceof PanelView) {
+                addPanel((PanelView) v);
             }
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index d68151d..75a2598 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -188,12 +188,13 @@
     TextView mNotificationPanelDebugText;
 
     // settings
+    boolean mHasSettingsPanel;
     SettingsPanelView mSettingsPanel;
     int mSettingsPanelGravity;
 
     // top bar
     View mClearButton;
-    View mSettingsButton;
+    ImageView mSettingsButton;
 
     // carrier/wifi label
     private TextView mCarrierLabel;
@@ -420,13 +421,25 @@
         mClearButton.setVisibility(View.INVISIBLE);
         mClearButton.setEnabled(false);
         mDateView = (DateView)mStatusBarWindow.findViewById(R.id.date);
-        mSettingsButton = mStatusBarWindow.findViewById(R.id.settings_button);
+
+        mHasSettingsPanel = res.getBoolean(R.bool.config_hasSettingsPanel);
+
+        mSettingsButton = (ImageView) mStatusBarWindow.findViewById(R.id.settings_button);
         if (mSettingsButton != null) {
-            if (mStatusBarView.hasFullWidthNotifications()) {
-                mSettingsButton.setOnClickListener(mSettingsButtonListener);
-                mSettingsButton.setVisibility(View.VISIBLE);
+            mSettingsButton.setOnClickListener(mSettingsButtonListener);
+            if (mHasSettingsPanel) {
+                if (mStatusBarView.hasFullWidthNotifications()) {
+                    // the settings panel is hiding behind this button
+                    mSettingsButton.setImageResource(R.drawable.ic_notify_quicksettings);
+                    mSettingsButton.setVisibility(View.VISIBLE);
+                } else {
+                    // there is a settings panel, but it's on the other side of the (large) screen
+                    mSettingsButton.setVisibility(View.GONE);
+                }
             } else {
-                mSettingsButton.setVisibility(View.GONE);
+                // no settings panel, go straight to settings
+                mSettingsButton.setVisibility(View.VISIBLE);
+                mSettingsButton.setImageResource(R.drawable.ic_notify_settings);
             }
         }
         
@@ -490,18 +503,31 @@
             });
         }
 
-        // Quick Settings (WIP)
-        mSettingsPanel = (SettingsPanelView) mStatusBarWindow.findViewById(R.id.settings_panel);
-        mSettingsPanel.setBar(mStatusBarView);
-        mSettingsPanel.setService(this);
-        mSettingsPanel.setup(mNetworkController, mBluetoothController, mBatteryController,
-                mLocationController);
-        mSettingsPanel.setSystemUiVisibility(
-                View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER | View.STATUS_BAR_DISABLE_SYSTEM_INFO);
+        // Quick Settings (where available, some restrictions apply)
+        if (mHasSettingsPanel) {
+            final View settings_stub 
+                    = mStatusBarWindow.findViewById(R.id.quick_settings_stub);
 
-        if (!ActivityManager.isHighEndGfx()) {
-            mSettingsPanel.setBackground(new FastColorDrawable(context.getResources().getColor(
-                    R.color.notification_panel_solid_background)));
+            if (settings_stub != null) {
+                mSettingsPanel = (SettingsPanelView) ((ViewStub)settings_stub).inflate();
+            } else {
+                mSettingsPanel = (SettingsPanelView) mStatusBarWindow.findViewById(R.id.settings_panel);
+            }
+
+            if (mSettingsPanel != null) {
+                mSettingsPanel.setBar(mStatusBarView);
+                mSettingsPanel.setService(this);
+                mSettingsPanel.setup(mNetworkController, mBluetoothController, mBatteryController,
+                        mLocationController);
+                mSettingsPanel.setSystemUiVisibility(
+                          View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER
+                        | View.STATUS_BAR_DISABLE_SYSTEM_INFO);
+    
+                if (!ActivityManager.isHighEndGfx()) {
+                    mSettingsPanel.setBackground(new FastColorDrawable(context.getResources().getColor(
+                            R.color.notification_panel_solid_background)));
+                }
+            }
         }
 
         mClingShown = ! (DEBUG_CLINGS 
@@ -1286,7 +1312,7 @@
             return;
         }
 
-        mSettingsPanel.expand();
+        if (mSettingsPanel != null) mSettingsPanel.expand();
 
         if (false) postStartTracing();
     }
@@ -1596,7 +1622,7 @@
         mCommandQueue.setNavigationIconHints(
                 altBack ? (mNavigationIconHints | StatusBarManager.NAVIGATION_HINT_BACK_ALT)
                         : (mNavigationIconHints & ~StatusBarManager.NAVIGATION_HINT_BACK_ALT));
-        mSettingsPanel.setImeWindowStatus(vis > 0);
+        if (mSettingsPanel != null) mSettingsPanel.setImeWindowStatus(vis > 0);
     }
 
     @Override
@@ -1820,10 +1846,12 @@
         lp.leftMargin = mNotificationPanelMarginPx;
         mNotificationPanel.setLayoutParams(lp);
 
-        lp = (FrameLayout.LayoutParams) mSettingsPanel.getLayoutParams();
-        lp.gravity = mSettingsPanelGravity;
-        lp.rightMargin = mNotificationPanelMarginPx;
-        mSettingsPanel.setLayoutParams(lp);
+        if (mSettingsPanel != null) {
+            lp = (FrameLayout.LayoutParams) mSettingsPanel.getLayoutParams();
+            lp.gravity = mSettingsPanelGravity;
+            lp.rightMargin = mNotificationPanelMarginPx;
+            mSettingsPanel.setLayoutParams(lp);
+        }
 
         updateCarrierLabelVisibility(false);
     }
@@ -1916,7 +1944,19 @@
 
     private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() {
         public void onClick(View v) {
-            animateExpandSettingsPanel();
+            if (mHasSettingsPanel) {
+                animateExpandSettingsPanel();
+            } else {
+                try {
+                    // Dismiss the lock screen when Settings starts.
+                    ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
+                } catch (RemoteException e) {
+                }
+                Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
+                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+                mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
+                animateCollapsePanels();
+            }
         }
     };
 
@@ -2010,7 +2050,7 @@
         }
 
         // Update the QuickSettings container
-        mSettingsPanel.updateResources();
+        if (mSettingsPanel != null) mSettingsPanel.updateResources();
 
         loadDimens();
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 96f729e..3c2f0e6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -109,7 +109,8 @@
 
         if (mFullWidthNotifications) {
             // No double swiping. If either panel is open, nothing else can be pulled down.
-            return (mSettingsPanel.getExpandedHeight() + mNotificationPanel.getExpandedHeight()> 0) 
+            return ((mSettingsPanel == null ? 0 : mSettingsPanel.getExpandedHeight()) 
+                        + mNotificationPanel.getExpandedHeight() > 0) 
                     ? null 
                     : mNotificationPanel;
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
index 8c390c8..faf20e2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -754,6 +754,7 @@
             mBrightnessDialog.setCanceledOnTouchOutside(true);
 
             mBrightnessController = new BrightnessController(mContext,
+                    (ImageView) mBrightnessDialog.findViewById(R.id.brightness_icon),
                     (ToggleSlider) mBrightnessDialog.findViewById(R.id.brightness_slider));
             mBrightnessController.addStateChangedCallback(mModel);
             mBrightnessDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java
index 0009503..e18b28a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java
@@ -28,6 +28,7 @@
 import android.util.Slog;
 import android.view.IWindowManager;
 import android.widget.CompoundButton;
+import android.widget.ImageView;
 
 import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
 
@@ -40,6 +41,7 @@
     private final int mMaximumBacklight;
 
     private final Context mContext;
+    private final ImageView mIcon;
     private final ToggleSlider mControl;
     private final boolean mAutomaticAvailable;
     private final IPowerManager mPower;
@@ -52,8 +54,9 @@
         public void onBrightnessLevelChanged();
     }
 
-    public BrightnessController(Context context, ToggleSlider control) {
+    public BrightnessController(Context context, ImageView icon, ToggleSlider control) {
         mContext = context;
+        mIcon = icon;
         mControl = control;
         mUserTracker = new CurrentUserTracker(mContext);
 
@@ -84,8 +87,10 @@
                 automatic = 0;
             }
             control.setChecked(automatic != 0);
+            updateIcon(automatic != 0);
         } else {
             control.setChecked(false);
+            updateIcon(false /*automatic*/);
             //control.hideToggle();
         }
         
@@ -105,6 +110,7 @@
     public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) {
         setMode(automatic ? Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC
                 : Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+        updateIcon(automatic);
         if (!automatic) {
             final int val = value + mMinimumBacklight;
             setBrightness(val);
@@ -136,4 +142,12 @@
         } catch (RemoteException ex) {
         }        
     }
+
+    private void updateIcon(boolean automatic) {
+        if (mIcon != null) {
+            mIcon.setImageResource(automatic ?
+                    com.android.systemui.R.drawable.ic_qs_brightness_auto_on :
+                    com.android.systemui.R.drawable.ic_qs_brightness_auto_off);
+        }
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
index 194f1f6..f71842e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
@@ -78,6 +78,7 @@
                 });
 
         mBrightness = new BrightnessController(context,
+                (ImageView)findViewById(R.id.brightness_icon),
                 (ToggleSlider)findViewById(R.id.brightness));
         mDoNotDisturb = new DoNotDisturbController(context,
                 (CompoundButton)findViewById(R.id.do_not_disturb_checkbox));
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardAccountView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardAccountView.java
index 57239c3..ba695ac 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardAccountView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardAccountView.java
@@ -137,8 +137,9 @@
         mLogin.setText("");
         mPassword.setText("");
         mLogin.requestFocus();
-        mSecurityMessageDisplay.setMessage(mLockPatternUtils.isPermanentlyLocked() ?
-                R.string.kg_login_too_many_attempts : R.string.kg_login_instructions);
+        boolean permLocked = mLockPatternUtils.isPermanentlyLocked();
+        mSecurityMessageDisplay.setMessage(permLocked ? R.string.kg_login_too_many_attempts :
+            R.string.kg_login_instructions, permLocked ? true : false);
     }
 
     /** {@inheritDoc} */
@@ -178,7 +179,7 @@
                     // dismiss keyguard
                     mCallback.dismiss(true);
                 } else {
-                    mSecurityMessageDisplay.setMessage(R.string.kg_login_invalid_input);
+                    mSecurityMessageDisplay.setMessage(R.string.kg_login_invalid_input, true);
                     mPassword.setText("");
                     mCallback.reportFailedUnlockAttempt();
                 }
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 49870200..fc1cac6 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -195,7 +195,8 @@
     protected void onAttachedToWindow() {
         super.onAttachedToWindow();
         mAppWidgetHost.startListening();
-        maybePopulateWidgets();
+        // TODO: Re-enable when we have layouts that can support a better variety of widgets.
+        // maybePopulateWidgets();
         disableStatusViewInteraction();
         post(mSwitchPageRunnable);
     }
@@ -643,11 +644,7 @@
         if (securityMode == SecurityMode.None) {
             // Discard current runnable if we're switching back to the selector view
             setOnDismissRunnable(null);
-            setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_BACK);
-        } else {
-            setSystemUiVisibility(getSystemUiVisibility() & (~View.STATUS_BAR_DISABLE_BACK));
-        }
-
+        } 
         mCurrentSecuritySelection = securityMode;
     }
 
@@ -787,17 +784,12 @@
                 public void onListenerDetached() {
                     int page = getWidgetPosition(R.id.keyguard_transport_control);
                     if (page != -1) {
-                        if (page == mAppWidgetContainer.getCurrentPage()) {
-                            // Switch back to clock view if music was showing.
-                            mAppWidgetContainer
-                                .setCurrentPage(getWidgetPosition(R.id.keyguard_status_view));
-                        }
                         mAppWidgetContainer.removeView(mTransportControl);
-                        // XXX keep view attached to hierarchy so we still get show/hide events
-                        // from AudioManager
+                        // XXX keep view attached so we still get show/hide events from AudioManager
                         KeyguardHostView.this.addView(mTransportControl);
                         mTransportControl.setVisibility(View.GONE);
                         mTransportState = TRANSPORT_GONE;
+                        mTransportControl.post(mSwitchPageRunnable);
                     }
                 }
 
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardNavigationManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardNavigationManager.java
index 74b244d..8dc38e7 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardNavigationManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardNavigationManager.java
@@ -16,11 +16,8 @@
 
 package com.android.internal.policy.impl.keyguard;
 
-import android.view.View;
 import android.widget.TextView;
 
-import com.android.internal.R;
-
 public class KeyguardNavigationManager implements SecurityMessageDisplay {
 
     private TextView mMessageArea;
@@ -30,12 +27,12 @@
         mMessageArea.setSelected(true); // Make marquee work
     }
 
-    public void setMessage(CharSequence msg) {
+    public void setMessage(CharSequence msg, boolean important) {
         mMessageArea.setText(msg);
         mMessageArea.announceForAccessibility(mMessageArea.getText());
     }
 
-    public void setMessage(int resId) {
+    public void setMessage(int resId, boolean important) {
         if (resId != 0) {
             mMessageArea.setText(resId);
             mMessageArea.announceForAccessibility(mMessageArea.getText());
@@ -44,7 +41,7 @@
         }
     }
 
-    public void setMessage(int resId, Object... formatArgs) {
+    public void setMessage(int resId, boolean important, Object... formatArgs) {
         if (resId != 0) {
             mMessageArea.setText(mMessageArea.getContext().getString(resId, formatArgs));
             mMessageArea.announceForAccessibility(mMessageArea.getText());
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
index 5a1c30f..8df6f8e 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
@@ -102,7 +102,7 @@
 
     private void resetState() {
         mSecurityMessageDisplay.setMessage(
-                mIsAlpha ? R.string.kg_password_instructions : R.string.kg_pin_instructions);
+                mIsAlpha ? R.string.kg_password_instructions : R.string.kg_pin_instructions, false);
         mPasswordEntry.setEnabled(true);
         mKeyboardView.setEnabled(true);
     }
@@ -207,12 +207,13 @@
             });
         }
 
-        // If no icon is visible, reset the left margin on the password field so the text is
+        // If no icon is visible, reset the start margin on the password field so the text is
         // still centered.
         if (!imeOrDeleteButtonVisible) {
             android.view.ViewGroup.LayoutParams params = mPasswordEntry.getLayoutParams();
             if (params instanceof MarginLayoutParams) {
-                ((MarginLayoutParams)params).leftMargin = 0;
+                final MarginLayoutParams mlp = (MarginLayoutParams) params;
+                mlp.setMarginStart(0);
                 mPasswordEntry.setLayoutParams(params);
             }
         }
@@ -287,7 +288,7 @@
                 handleAttemptLockout(deadline);
             }
             mSecurityMessageDisplay.setMessage(
-                    mIsAlpha ? R.string.kg_wrong_password : R.string.kg_wrong_pin);
+                    mIsAlpha ? R.string.kg_wrong_password : R.string.kg_wrong_pin, true);
         }
         mPasswordEntry.setText("");
     }
@@ -303,7 +304,7 @@
             public void onTick(long millisUntilFinished) {
                 int secondsRemaining = (int) (millisUntilFinished / 1000);
                 mSecurityMessageDisplay.setMessage(
-                        R.string.kg_too_many_failed_attempts_countdown, secondsRemaining);
+                        R.string.kg_too_many_failed_attempts_countdown, true, secondsRemaining);
             }
 
             @Override
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java
index d8d7990..7361481 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java
@@ -182,7 +182,7 @@
         if (deadline != 0) {
             handleAttemptLockout(deadline);
         } else {
-            mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions);
+            mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions, false);
         }
 
         // the footer depends on how many total attempts the user has failed
@@ -254,7 +254,7 @@
                     long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
                     handleAttemptLockout(deadline);
                 } else {
-                    mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern);
+                    mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true);
                     mLockPatternView.postDelayed(mCancelPatternRunnable, PATTERN_CLEAR_TIMEOUT_MS);
                 }
             }
@@ -327,13 +327,13 @@
             public void onTick(long millisUntilFinished) {
                 final int secondsRemaining = (int) (millisUntilFinished / 1000);
                 mSecurityMessageDisplay.setMessage(
-                        R.string.kg_too_many_failed_attempts_countdown, secondsRemaining);
+                        R.string.kg_too_many_failed_attempts_countdown, true, secondsRemaining);
             }
 
             @Override
             public void onFinish() {
                 mLockPatternView.setEnabled(true);
-                mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions);
+                mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions, false);
                 // TODO mUnlockIcon.setVisibility(View.VISIBLE);
                 mFailedPatternAttemptsSinceLastTimeout = 0;
                 if (mEnableFallback) {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
index 3516af9..31ae8fa 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
@@ -111,7 +111,7 @@
     public void reset() {
         // start fresh
         if (mSecurityMessageDisplay != null) {
-            mSecurityMessageDisplay.setMessage(R.string.kg_sim_pin_instructions);
+            mSecurityMessageDisplay.setMessage(R.string.kg_sim_pin_instructions, true);
         }
 
         // make sure that the number of entered digits is consistent when we
@@ -193,7 +193,7 @@
     private void checkPin() {
         if (mPinEntry.getText().length() < 4) {
             // otherwise, display a message to the user, and don't submit.
-            mSecurityMessageDisplay.setMessage(R.string.kg_invalid_sim_pin_hint);
+            mSecurityMessageDisplay.setMessage(R.string.kg_invalid_sim_pin_hint, true);
             mPinEntry.setText("");
             mCallback.userActivity(0);
             return;
@@ -216,7 +216,8 @@
                                 KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked();
                                 mCallback.dismiss(true);
                             } else {
-                                mSecurityMessageDisplay.setMessage(R.string.kg_password_wrong_pin_code);
+                                mSecurityMessageDisplay.setMessage
+                                    (R.string.kg_password_wrong_pin_code, true);
                                 mPinEntry.setText("");
                             }
                             mCallback.userActivity(0);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
index 2194c80..4c0d3b7 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
@@ -99,7 +99,7 @@
             }
             mSimPinEntry.setText(null);
             if (msg != 0) {
-                mSecurityMessageDisplay.setMessage(msg);
+                mSecurityMessageDisplay.setMessage(msg, true);
             }
         }
 
@@ -108,7 +108,7 @@
             mPukText="";
             state = ENTER_PUK;
             if (mSecurityMessageDisplay != null) {
-                mSecurityMessageDisplay.setMessage(R.string.kg_puk_enter_puk_hint);
+                mSecurityMessageDisplay.setMessage(R.string.kg_puk_enter_puk_hint, true);
             }
             mSimPinEntry.requestFocus();
         }
@@ -279,7 +279,7 @@
                                 mCallback.dismiss(true);
                             } else {
                                 mStateMachine.reset();
-                                mSecurityMessageDisplay.setMessage(R.string.kg_invalid_puk);
+                                mSecurityMessageDisplay.setMessage(R.string.kg_invalid_puk, true);
                             }
                             mCheckInProgress = false;
                         }
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java
index ab2e170..9615e71 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java
@@ -188,13 +188,17 @@
         updateStatusLines();
     }
 
-    public void setMessage(CharSequence msg) {
-        mSecurityMessageContents = msg;
+    public void setMessage(CharSequence msg, boolean important) {
+        if (!important) {
+            mSecurityMessageContents = "";
+        } else {
+            mSecurityMessageContents = msg;
+        }
         securityMessageChanged();
     }
 
-    public void setMessage(int resId) {
-        if (resId != 0) {
+    public void setMessage(int resId, boolean important) {
+        if (resId != 0 && important) {
             mSecurityMessageContents = getContext().getResources().getText(resId);
         } else {
             mSecurityMessageContents = "";
@@ -202,8 +206,8 @@
         securityMessageChanged();
     }
 
-    public void setMessage(int resId, Object... formatArgs) {
-        if (resId != 0) {
+    public void setMessage(int resId, boolean important, Object... formatArgs) {
+        if (resId != 0 && important) {
             mSecurityMessageContents = getContext().getString(resId, formatArgs);
         } else {
             mSecurityMessageContents = "";
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
index 1ec4176..0ad2404 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -210,6 +210,18 @@
         mKeyguardView.setLockPatternUtils(mLockPatternUtils);
         mKeyguardView.setViewMediatorCallback(mViewMediatorCallback);
 
+        // HACK
+        // The keyguard view will have set up window flags in onFinishInflate before we set
+        // the view mediator callback. Make sure it knows the correct IME state.
+        if (mViewMediatorCallback != null) {
+            KeyguardPasswordView kpv = (KeyguardPasswordView) mKeyguardView.findViewById(
+                    R.id.keyguard_password_view);
+
+            if (kpv != null) {
+                mViewMediatorCallback.setNeedsInput(kpv.needsInput());
+            }
+        }
+
         if (options != null) {
             if (options.getBoolean(LockPatternUtils.KEYGUARD_SHOW_USER_SWITCHER)) {
                 mKeyguardView.goToUserSwitcher();
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetRegion.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetRegion.java
index bd79d67..4ff6f27 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetRegion.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetRegion.java
@@ -29,6 +29,9 @@
     private int mPage = 0;
     private Callbacks mCallbacks;
 
+    // We are disabling touch interaction of the widget region for factory ROM. 
+    private static final boolean DISABLE_TOUCH_INTERACTION = true;
+
     private static final long CUSTOM_WIDGET_USER_ACTIVITY_TIMEOUT = 30000;
 
     public KeyguardWidgetRegion(Context context) {
@@ -52,19 +55,21 @@
         mPager.setPageSwitchListener(this);
 
         setSoundEffectsEnabled(false);
-        setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                showPagingFeedback();
-            }
-        });
+        if (!DISABLE_TOUCH_INTERACTION) {
+            setOnClickListener(new OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    showPagingFeedback();
+                }
+            });
+        }
     }
 
     public void showPagingFeedback() {
-        if (true || (mPage < mPager.getPageCount() - 1)) {
+        if ((mPage < mPager.getPageCount() - 1)) {
             mLeftStrip.makeEmGo();
         }
-        if (true || (mPage > 0)) {
+        if ((mPage > 0)) {
             mRightStrip.makeEmGo();
         }
     }
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java b/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java
index d834741..86c05b1 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java
@@ -77,6 +77,9 @@
     private static final int MIN_SNAP_VELOCITY = 1500;
     private static final int MIN_FLING_VELOCITY = 250;
 
+    // We are disabling touch interaction of the widget region for factory ROM. 
+    private static final boolean DISABLE_TOUCH_INTERACTION = true;
+
     static final int AUTOMATIC_PAGE_SPACING = -1;
 
     protected int mFlingThresholdVelocity;
@@ -317,6 +320,7 @@
             return;
         }
 
+        mForceScreenScrolled = true;
         mCurrentPage = Math.max(0, Math.min(currentPage, getPageCount() - 1));
         updateCurrentPageScroll();
         updateScrollingIndicator();
@@ -861,6 +865,10 @@
 
     @Override
     public boolean onInterceptTouchEvent(MotionEvent ev) {
+        if (DISABLE_TOUCH_INTERACTION) {
+            return false;
+        }
+
         /*
          * This method JUST determines whether we want to intercept the motion.
          * If we return true, onTouchEvent will be called and we do the actual
@@ -1099,6 +1107,10 @@
 
     @Override
     public boolean onTouchEvent(MotionEvent ev) {
+        if (DISABLE_TOUCH_INTERACTION) {
+            return false;
+        }
+
         // Skip touch handling if there are no pages to swipe
         if (getChildCount() <= 0) return super.onTouchEvent(ev);
 
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/SecurityMessageDisplay.java b/policy/src/com/android/internal/policy/impl/keyguard/SecurityMessageDisplay.java
index 98fd11e..b57d8c1 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/SecurityMessageDisplay.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/SecurityMessageDisplay.java
@@ -17,9 +17,9 @@
 package com.android.internal.policy.impl.keyguard;
 
 public interface SecurityMessageDisplay {
-    public void setMessage(CharSequence msg);
+    public void setMessage(CharSequence msg, boolean important);
 
-    public void setMessage(int resId);
+    public void setMessage(int resId, boolean important);
 
-    public void setMessage(int resId, Object... formatArgs);
+    public void setMessage(int resId, boolean important, Object... formatArgs);
 }
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index daed0a2..7132e1e 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -3930,48 +3930,54 @@
             removeDyingProviderLocked(null, providers.get(i), true);
         }
 
-        if (mIntentSenderRecords.size() > 0) {
-            Iterator<WeakReference<PendingIntentRecord>> it
-                    = mIntentSenderRecords.values().iterator();
-            while (it.hasNext()) {
-                WeakReference<PendingIntentRecord> wpir = it.next();
-                if (wpir == null) {
+        if (name == null) {
+            // Remove pending intents.  For now we only do this when force
+            // stopping users, because we have some problems when doing this
+            // for packages -- app widgets are not currently cleaned up for
+            // such packages, so they can be left with bad pending intents.
+            if (mIntentSenderRecords.size() > 0) {
+                Iterator<WeakReference<PendingIntentRecord>> it
+                        = mIntentSenderRecords.values().iterator();
+                while (it.hasNext()) {
+                    WeakReference<PendingIntentRecord> wpir = it.next();
+                    if (wpir == null) {
+                        it.remove();
+                        continue;
+                    }
+                    PendingIntentRecord pir = wpir.get();
+                    if (pir == null) {
+                        it.remove();
+                        continue;
+                    }
+                    if (name == null) {
+                        // Stopping user, remove all objects for the user.
+                        if (pir.key.userId != userId) {
+                            // Not the same user, skip it.
+                            continue;
+                        }
+                    } else {
+                        if (UserHandle.getAppId(pir.uid) != appId) {
+                            // Different app id, skip it.
+                            continue;
+                        }
+                        if (userId != UserHandle.USER_ALL && pir.key.userId != userId) {
+                            // Different user, skip it.
+                            continue;
+                        }
+                        if (!pir.key.packageName.equals(name)) {
+                            // Different package, skip it.
+                            continue;
+                        }
+                    }
+                    if (!doit) {
+                        return true;
+                    }
+                    didSomething = true;
                     it.remove();
-                    continue;
-                }
-                PendingIntentRecord pir = wpir.get();
-                if (pir == null) {
-                    it.remove();
-                    continue;
-                }
-                if (name == null) {
-                    // Stopping user, remove all objects for the user.
-                    if (pir.key.userId != userId) {
-                        // Not the same user, skip it.
-                        continue;
+                    pir.canceled = true;
+                    if (pir.key.activity != null) {
+                        pir.key.activity.pendingResults.remove(pir.ref);
                     }
-                } else {
-                    if (UserHandle.getAppId(pir.uid) != appId) {
-                        // Different app id, skip it.
-                        continue;
-                    }
-                    if (userId != UserHandle.USER_ALL && pir.key.userId != userId) {
-                        // Different user, skip it.
-                        continue;
-                    }
-                    if (!pir.key.packageName.equals(name)) {
-                        // Different package, skip it.
-                        continue;
-                    }
-                }
-                if (!doit) {
-                    return true;
-                }
-                didSomething = true;
-                it.remove();
-                pir.canceled = true;
-                if (pir.key.activity != null) {
-                    pir.key.activity.pendingResults.remove(pir.ref);
                 }
             }
         }
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java
index 2920824..2303fc3 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java
@@ -52,8 +52,10 @@
             new AdapterView.OnItemSelectedListener() {
                 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
                     currentIntrinsic = pos;
-                    runTest();
-                    act.updateDisplay();
+                    if (mRS != null) {
+                        runTest();
+                        act.updateDisplay();
+                    }
                 }
 
                 public void onNothingSelected(AdapterView parent) {
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java
index 8009daa..bb3f2f3 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java
@@ -123,6 +123,7 @@
 
     public void destroy() {
         mRS.destroy();
+        mRS = null;
     }
 
     public void updateBitmap(Bitmap b) {
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs
similarity index 88%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs
index a83e819..ba8711b 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs
@@ -29,10 +29,10 @@
     Mat = m;
 }
 
-void root(const uchar4 *in, uchar4 *out) {
-    float4 f = convert_float4(*in);
+uchar4 __attribute__((kernel)) root(uchar4 in) {
+    float4 f = convert_float4(in);
     f = rsMatrixMultiply(&Mat, f);
     f = clamp(f, 0.f, 255.f);
-    *out = convert_uchar4(f);
+    return convert_uchar4(f);
 }
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs
similarity index 94%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs
index 98128279..772503f 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs
@@ -24,7 +24,7 @@
 
 float gCoeffs[9];
 
-void root(uchar4 *out, uint32_t x, uint32_t y) {
+uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
     uint32_t x1 = min((int32_t)x+1, gWidth-1);
     uint32_t x2 = max((int32_t)x-1, 0);
     uint32_t y1 = min((int32_t)y+1, gHeight-1);
@@ -61,7 +61,7 @@
     p20 += p02;
 
     p20 = clamp(p20, 0.f, 255.f);
-    *out = convert_uchar4(p20);
+    return convert_uchar4(p20);
 }
 
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs
similarity index 96%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs
index e6d03c9..a916bfb 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs
@@ -24,7 +24,7 @@
 
 float gCoeffs[25];
 
-void root(uchar4 *out, uint32_t x, uint32_t y) {
+uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
     uint32_t x0 = max((int32_t)x-2, 0);
     uint32_t x1 = max((int32_t)x-1, 0);
     uint32_t x2 = x;
@@ -68,7 +68,7 @@
               + convert_float4(rsGetElementAt_uchar4(gIn, x4, y4)) * gCoeffs[24];
 
     p0 = clamp(p0 + p1 + p2 + p3 + p4, 0.f, 255.f);
-    *out = convert_uchar4(p0);
+    return convert_uchar4(p0);
 }
 
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs
similarity index 90%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs
index 9eb5d43..5f03483 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs
@@ -17,8 +17,8 @@
 #pragma version(1)
 #pragma rs java_package_name(com.android.rs.image)
 
-void root(const uchar4 *v_in, uchar4 *v_out) {
-    *v_out = *v_in;
+uchar4 __attribute__((kernel)) root(uchar4 v_in) {
+    return v_in;
 }
 
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh
index 3809912..2eacb7d 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh
@@ -26,7 +26,7 @@
     neg_center = -center;
     inv_dimensions.x = 1.f / (float)dim_x;
     inv_dimensions.y = 1.f / (float)dim_y;
-    alpha = k * 2.0 + 0.75;
+    alpha = k * 2.0f + 0.75f;
 
     axis_scale = (float2)1.f;
     if (dim_x > dim_y)
@@ -34,15 +34,15 @@
     else
         axis_scale.x = (float)dim_x / (float)dim_y;
     
-    const float bound2 = 0.25 * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
+    const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
     const float bound = sqrt(bound2);
-    const float radius = 1.15 * bound;
+    const float radius = 1.15f * bound;
     radius2 = radius*radius;
     const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2));
     factor = bound / max_radian;
 }
 
-void root(uchar4 *out, uint32_t x, uint32_t y) {
+uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
     // Convert x and y to floating point coordinates with center as origin
     const float2 inCoord = {(float)x, (float)y};
     const float2 coord = mad(inCoord, inv_dimensions, neg_center);
@@ -53,6 +53,6 @@
     const float scalar = radian * factor * inv_dist;
     const float2 new_coord = mad(coord, scalar, center);
     const float4 fout = rsSample(in_alloc, sampler, new_coord);
-    *out = rsPackColorTo8888(fout);
+    return rsPackColorTo8888(fout);
 }
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh
index 08b4126..fcf0a3d 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh
@@ -26,7 +26,7 @@
     neg_center = -center;
     inv_dimensions.x = 1.f / (float)dim_x;
     inv_dimensions.y = 1.f / (float)dim_y;
-    alpha = k * 2.0 + 0.75;
+    alpha = k * 2.0f + 0.75f;
 
     axis_scale = (float2)1.f;
     if (dim_x > dim_y)
@@ -34,15 +34,15 @@
     else
         axis_scale.x = (float)dim_x / (float)dim_y;
 
-    const float bound2 = 0.25 * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
+    const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y);
     const float bound = sqrt(bound2);
-    const float radius = 1.15 * bound;
+    const float radius = 1.15f * bound;
     radius2 = radius*radius;
     const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2));
     factor = bound / max_radian;
 }
 
-void root(uchar4 *out, uint32_t x, uint32_t y) {
+uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
     // Convert x and y to floating point coordinates with center as origin
     const float2 inCoord = {(float)x, (float)y};
     const float2 coord = mad(inCoord, inv_dimensions, neg_center);
@@ -53,6 +53,6 @@
     const float scalar = radian * factor * inv_dist;
     const float2 new_coord = mad(coord, scalar, center);
     const float4 fout = rsSample(in_alloc, sampler, new_coord);
-    *out = rsPackColorTo8888(fout);
+    return rsPackColorTo8888(fout);
 }
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.fs
similarity index 100%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.fs
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.fs
similarity index 100%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.fs
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs
similarity index 89%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs
index c8531f3..4ae095d 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs
@@ -18,8 +18,8 @@
 #pragma rs java_package_name(com.android.rs.image)
 #pragma rs_fp_relaxed
 
-void genRand(uchar *out) {
-    *out = (uchar)rsRand(0xff);
+uchar __attribute__((kernel)) genRand() {
+    return (uchar)rsRand(0xff);
 }
 
 /*
@@ -42,7 +42,7 @@
 int32_t gHMask;
 
 rs_allocation gBlendSource;
-void blend9(uchar *out, uint32_t x, uint32_t y) {
+uchar __attribute__((kernel)) blend9(uint32_t x, uint32_t y) {
     uint32_t x1 = (x-1) & gWMask;
     uint32_t x2 = (x+1) & gWMask;
     uint32_t y1 = (y-1) & gHMask;
@@ -70,14 +70,14 @@
     p20 += p02;
 
     p20 = min(p20 >> 10, (uint)255);
-    *out = (uchar)p20;
+    return (uchar)p20;
 }
 
 float gNoiseStrength;
 
 rs_allocation gNoise;
-void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
-    float4 ip = convert_float4(*in);
+uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
+    float4 ip = convert_float4(in);
     float pnoise = (float) rsGetElementAt_uchar(gNoise, x & gWMask, y & gHMask);
 
     float energy_level = ip.r + ip.g + ip.b;
@@ -89,5 +89,5 @@
 
     uchar4 p = convert_uchar4(ip);
     p.a = 0xff;
-    *out = p;
+    return p;
 }
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs
similarity index 86%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs
index c420cac..90ba058 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs
@@ -20,11 +20,11 @@
 
 const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
 
-void root(const uchar4 *v_in, uchar4 *v_out) {
-    float4 f4 = rsUnpackColor8888(*v_in);
+uchar4 __attribute__((kernel)) root(uchar4 v_in) {
+    float4 f4 = rsUnpackColor8888(v_in);
 
     float3 mono = dot(f4.rgb, gMonoMult);
-    *v_out = rsPackColorTo8888(mono);
+    return rsPackColorTo8888(mono);
 }
 
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh
index 7c5d930..e289906 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh
@@ -21,24 +21,26 @@
 float overInWMinInB;
 rs_matrix3x3 colorMat;
 
-void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
-    float3 pixel = convert_float4(in[0]).rgb;
+uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
+    uchar4 out;
+    float3 pixel = convert_float4(in).rgb;
     pixel = rsMatrixMultiply(&colorMat, pixel);
     pixel = clamp(pixel, 0.f, 255.f);
     pixel = (pixel - inBlack) * overInWMinInB;
     pixel = pixel * outWMinOutB + outBlack;
     pixel = clamp(pixel, 0.f, 255.f);
-    out->xyz = convert_uchar3(pixel);
-    out->w = 0xff;
+    out.xyz = convert_uchar3(pixel);
+    out.w = 0xff;
+    return out;
 }
 
-void root4(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
-    float4 pixel = convert_float4(in[0]);
+uchar4 __attribute__((kernel)) root4(uchar4 in, uint32_t x, uint32_t y) {
+    float4 pixel = convert_float4(in);
     pixel.rgb = rsMatrixMultiply(&colorMat, pixel.rgb);
     pixel = clamp(pixel, 0.f, 255.f);
     pixel = (pixel - inBlack) * overInWMinInB;
     pixel = pixel * outWMinOutB + outBlack;
     pixel = clamp(pixel, 0.f, 255.f);
-    out->xyzw = convert_uchar4(pixel);
+    return convert_uchar4(pixel);
 }
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.fs
similarity index 100%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.fs
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.fs
similarity index 75%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.fs
index da81d2e..ac2061b 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.fs
@@ -23,7 +23,7 @@
 float lowerBoundY = -2.f;
 float scaleFactor = 4.f;
 
-void root(uchar4 *v_out, uint32_t x, uint32_t y) {
+uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
   float2 p;
   p.x = lowerBoundX + ((float)x / gDimX) * scaleFactor;
   p.y = lowerBoundY + ((float)y / gDimY) * scaleFactor;
@@ -41,16 +41,16 @@
 
   if(iter >= gMaxIteration) {
     // write a non-transparent black pixel
-    *v_out = (uchar4){0, 0, 0, 0xff};
+    return (uchar4){0, 0, 0, 0xff};
   } else {
-    float mi3 = gMaxIteration / 3.;
+    float mi3 = gMaxIteration / 3.f;
     if (iter <= (gMaxIteration / 3))
-      *v_out = (uchar4){0xff * (iter / mi3), 0, 0, 0xff};
+      return (uchar4){0xff * (iter / mi3), 0, 0, 0xff};
     else if (iter <= (((gMaxIteration / 3) * 2)))
-      *v_out = (uchar4){0xff - (0xff * ((iter - mi3) / mi3)),
-                        (0xff * ((iter - mi3) / mi3)), 0, 0xff};
+      return (uchar4){0xff - (0xff * ((iter - mi3) / mi3)),
+                      (0xff * ((iter - mi3) / mi3)), 0, 0xff};
     else
-      *v_out = (uchar4){0, 0xff - (0xff * ((iter - (mi3 * 2)) / mi3)),
-                        (0xff * ((iter - (mi3 * 2)) / mi3)), 0xff};
+      return (uchar4){0, 0xff - (0xff * ((iter - (mi3 * 2)) / mi3)),
+                      (0xff * ((iter - (mi3 * 2)) / mi3)), 0xff};
   }
 }
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs
similarity index 70%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs
index 3dfa94b..86e155a 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs
@@ -56,51 +56,49 @@
     }
 }
 
-void copyIn(const uchar4 *in, float4 *out) {
-    *out = convert_float4(*in);
+float4 __attribute__((kernel)) copyIn(uchar4 in) {
+    return convert_float4(in);
 }
 
-void vert(uchar4 *out, uint32_t x, uint32_t y) {
+uchar4 __attribute__((kernel)) vert(uint32_t x, uint32_t y) {
     float3 blurredPixel = 0;
-    const float *gPtr = gaussian;
+    int gi = 0;
+    uchar4 out;
     if ((y > radius) && (y < (height - radius))) {
         for (int r = -radius; r <= radius; r ++) {
-            const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel2, x, y + r);
-            blurredPixel += i->xyz * gPtr[0];
-            gPtr++;
+            float4 i = rsGetElementAt_float4(ScratchPixel2, x, y + r);
+            blurredPixel += i.xyz * gaussian[gi++];
         }
     } else {
         for (int r = -radius; r <= radius; r ++) {
             int validH = rsClamp((int)y + r, (int)0, (int)(height - 1));
-            const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel2, x, validH);
-            blurredPixel += i->xyz * gPtr[0];
-            gPtr++;
+            float4 i = rsGetElementAt_float4(ScratchPixel2, x, validH);
+            blurredPixel += i.xyz * gaussian[gi++];
         }
     }
 
-    out->xyz = convert_uchar3(clamp(blurredPixel, 0.f, 255.f));
-    out->w = 0xff;
+    out.xyz = convert_uchar3(clamp(blurredPixel, 0.f, 255.f));
+    out.w = 0xff;
+    return out;
 }
 
-void horz(float4 *out, uint32_t x, uint32_t y) {
-    float3 blurredPixel = 0;
-    const float *gPtr = gaussian;
+float4 __attribute__((kernel)) horz(uint32_t x, uint32_t y) {
+    float4 blurredPixel = 0;
+    int gi = 0;
     if ((x > radius) && (x < (width - radius))) {
         for (int r = -radius; r <= radius; r ++) {
-            const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel1, x + r, y);
-            blurredPixel += i->xyz * gPtr[0];
-            gPtr++;
+            float4 i = rsGetElementAt_float4(ScratchPixel1, x + r, y);
+            blurredPixel += i * gaussian[gi++];
         }
     } else {
         for (int r = -radius; r <= radius; r ++) {
             // Stepping left and right away from the pixel
             int validX = rsClamp((int)x + r, (int)0, (int)(width - 1));
-            const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel1, validX, y);
-            blurredPixel += i->xyz * gPtr[0];
-            gPtr++;
+            float4 i = rsGetElementAt_float4(ScratchPixel1, validX, y);
+            blurredPixel += i * gaussian[gi++];
         }
     }
 
-    out->xyz = blurredPixel;
+    return blurredPixel;
 }
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh
index a1e4ae5..04ca1f1 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh
@@ -31,29 +31,29 @@
     else
         axis_scale.x = (float)dim_x / (float)dim_y;
 
-    const float max_dist = 0.5 * length(axis_scale);
+    const float max_dist = 0.5f * length(axis_scale);
     sloped_inv_max_dist = desired_slope * 1.f/max_dist;
 
     // Range needs to be between 1.3 to 0.6. When scale is zero then range is
     // 1.3 which means no vignette at all because the luminousity difference is
     // less than 1/256.  Expect input scale to be between 0.0 and 1.0.
-    const float neg_range = 0.7*sqrt(desired_scale) - 1.3;
+    const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f;
     sloped_neg_range = exp(neg_range * desired_slope);
 
     shade = desired_shade;
     opp_shade = 1.f - desired_shade;
 }
 
-void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
+uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
     // Convert x and y to floating point coordinates with center as origin
-    const float4 fin = convert_float4(*in);
+    const float4 fin = convert_float4(in);
     const float2 inCoord = {(float)x, (float)y};
     const float2 coord = mad(inCoord, inv_dimensions, neg_center);
     const float sloped_dist_ratio = length(axis_scale * coord)  * sloped_inv_max_dist;
-    const float lumen = opp_shade + shade / ( 1.0 + sloped_neg_range * exp(sloped_dist_ratio) );
+    const float lumen = opp_shade + shade / ( 1.0f + sloped_neg_range * exp(sloped_dist_ratio) );
     float4 fout;
     fout.rgb = fin.rgb * lumen;
     fout.w = fin.w;
-    *out = convert_uchar4(fout);
+    return convert_uchar4(fout);
 }
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh
index 7f7bdcf..05a5929 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh
@@ -31,22 +31,22 @@
     else
         axis_scale.x = (float)dim_x / (float)dim_y;
 
-    const float max_dist = 0.5 * length(axis_scale);
+    const float max_dist = 0.5f * length(axis_scale);
     sloped_inv_max_dist = desired_slope * 1.f/max_dist;
 
     // Range needs to be between 1.3 to 0.6. When scale is zero then range is
     // 1.3 which means no vignette at all because the luminousity difference is
     // less than 1/256.  Expect input scale to be between 0.0 and 1.0.
-    const float neg_range = 0.7*sqrt(desired_scale) - 1.3;
+    const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f;
     sloped_neg_range = exp(neg_range * desired_slope);
 
     shade = desired_shade;
     opp_shade = 1.f - desired_shade;
 }
 
-void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
+uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
     // Convert x and y to floating point coordinates with center as origin
-    const float4 fin = convert_float4(*in);
+    const float4 fin = convert_float4(in);
     const float2 inCoord = {(float)x, (float)y};
     const float2 coord = mad(inCoord, inv_dimensions, neg_center);
     const float sloped_dist_ratio = fast_length(axis_scale * coord)  * sloped_inv_max_dist;
@@ -55,6 +55,6 @@
     float4 fout;
     fout.rgb = fin.rgb * lumen;
     fout.w = fin.w;
-    *out = convert_uchar4(fout);
+    return convert_uchar4(fout);
 }
 
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.fs
similarity index 100%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.fs
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.fs
similarity index 100%
rename from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.rs
rename to tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.fs