Merge "Fix bug #7259242 text is left justified with no padding" into jb-mr1-dev
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 396771f..a276225 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -271,11 +271,11 @@
     return 0;
 }
 
-int delete_cache(const char *pkgname)
+int delete_cache(const char *pkgname, uid_t persona)
 {
     char cachedir[PKG_PATH_MAX];
 
-    if (create_pkg_path(cachedir, pkgname, CACHE_DIR_POSTFIX, 0))
+    if (create_pkg_path(cachedir, pkgname, CACHE_DIR_POSTFIX, persona))
         return -1;
 
         /* delete contents, not the directory, no exceptions */
diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c
index a099537..19298a3 100644
--- a/cmds/installd/installd.c
+++ b/cmds/installd/installd.c
@@ -72,7 +72,7 @@
 
 static int do_rm_cache(char **arg, char reply[REPLY_MAX])
 {
-    return delete_cache(arg[0]); /* pkgname */
+    return delete_cache(arg[0], atoi(arg[1])); /* pkgname, userid */
 }
 
 static int do_get_size(char **arg, char reply[REPLY_MAX])
@@ -142,7 +142,7 @@
     { "rename",               2, do_rename },
     { "fixuid",               3, do_fixuid },
     { "freecache",            1, do_free_cache },
-    { "rmcache",              1, do_rm_cache },
+    { "rmcache",              2, do_rm_cache },
     { "getsize",              5, do_get_size },
     { "rmuserdata",           2, do_rm_user_data },
     { "movefiles",            0, do_movefiles },
diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h
index a229b970..2540dbe 100644
--- a/cmds/installd/installd.h
+++ b/cmds/installd/installd.h
@@ -199,7 +199,7 @@
 int make_user_data(const char *pkgname, uid_t uid, uid_t persona);
 int delete_persona(uid_t persona);
 int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy);
-int delete_cache(const char *pkgname);
+int delete_cache(const char *pkgname, uid_t persona);
 int move_dex(const char *src, const char *dst);
 int rm_dex(const char *path);
 int protect(char *pkgname, gid_t gid);
diff --git a/core/java/android/app/MediaRouteButton.java b/core/java/android/app/MediaRouteButton.java
index a9ccef0..3ecafc3 100644
--- a/core/java/android/app/MediaRouteButton.java
+++ b/core/java/android/app/MediaRouteButton.java
@@ -50,6 +50,7 @@
     private boolean mRemoteActive;
     private boolean mToggleMode;
     private boolean mCheatSheetEnabled;
+    private boolean mIsConnecting;
 
     private int mMinWidth;
     private int mMinHeight;
@@ -57,6 +58,10 @@
     private OnClickListener mExtendedSettingsClickListener;
     private MediaRouteChooserDialogFragment mDialogFragment;
 
+    private static final int[] CHECKED_STATE_SET = {
+        R.attr.state_checked
+    };
+
     private static final int[] ACTIVATED_STATE_SET = {
         R.attr.state_activated
     };
@@ -210,10 +215,21 @@
     }
 
     void updateRemoteIndicator() {
-        final boolean isRemote =
-                mRouter.getSelectedRoute(mRouteTypes) != mRouter.getSystemAudioRoute();
+        final RouteInfo selected = mRouter.getSelectedRoute(mRouteTypes);
+        final boolean isRemote = selected != mRouter.getSystemAudioRoute();
+        final boolean isConnecting = selected.getStatusCode() == RouteInfo.STATUS_CONNECTING;
+
+        boolean needsRefresh = false;
         if (mRemoteActive != isRemote) {
             mRemoteActive = isRemote;
+            needsRefresh = true;
+        }
+        if (mIsConnecting != isConnecting) {
+            mIsConnecting = isConnecting;
+            needsRefresh = true;
+        }
+
+        if (needsRefresh) {
             refreshDrawableState();
         }
     }
@@ -248,7 +264,14 @@
     @Override
     protected int[] onCreateDrawableState(int extraSpace) {
         final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
-        if (mRemoteActive) {
+
+        // Technically we should be handling this more completely, but these
+        // are implementation details here. Checked is used to express the connecting
+        // drawable state and it's mutually exclusive with activated for the purposes
+        // of state selection here.
+        if (mIsConnecting) {
+            mergeDrawableStates(drawableState, CHECKED_STATE_SET);
+        } else if (mRemoteActive) {
             mergeDrawableStates(drawableState, ACTIVATED_STATE_SET);
         }
         return drawableState;
@@ -426,6 +449,11 @@
         }
 
         @Override
+        public void onRouteChanged(MediaRouter router, RouteInfo info) {
+            updateRemoteIndicator();
+        }
+
+        @Override
         public void onRouteAdded(MediaRouter router, RouteInfo info) {
             updateRouteCount();
         }
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java
index 9d57467..d36d99d 100644
--- a/core/java/android/app/PendingIntent.java
+++ b/core/java/android/app/PendingIntent.java
@@ -395,6 +395,31 @@
     }
 
     /**
+     * @hide
+     * Note that UserHandle.CURRENT will be interpreted at the time the
+     * activity is started, not when the pending intent is created.
+     */
+    public static PendingIntent getActivitiesAsUser(Context context, int requestCode,
+            Intent[] intents, int flags, Bundle options, UserHandle user) {
+        String packageName = context.getPackageName();
+        String[] resolvedTypes = new String[intents.length];
+        for (int i=0; i<intents.length; i++) {
+            intents[i].setAllowFds(false);
+            resolvedTypes[i] = intents[i].resolveTypeIfNeeded(context.getContentResolver());
+        }
+        try {
+            IIntentSender target =
+                ActivityManagerNative.getDefault().getIntentSender(
+                    ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
+                    null, null, requestCode, intents, resolvedTypes,
+                    flags, options, user.getIdentifier());
+            return target != null ? new PendingIntent(target) : null;
+        } catch (RemoteException e) {
+        }
+        return null;
+    }
+
+    /**
      * Retrieve a PendingIntent that will perform a broadcast, like calling
      * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
      *
diff --git a/core/java/android/app/TaskStackBuilder.java b/core/java/android/app/TaskStackBuilder.java
index 9d5bcc6..3e0ac7e 100644
--- a/core/java/android/app/TaskStackBuilder.java
+++ b/core/java/android/app/TaskStackBuilder.java
@@ -274,6 +274,20 @@
     }
 
     /**
+     * @hide
+     */
+    public PendingIntent getPendingIntent(int requestCode, int flags, Bundle options,
+            UserHandle user) {
+        if (mIntents.isEmpty()) {
+            throw new IllegalStateException(
+                    "No intents added to TaskStackBuilder; cannot getPendingIntent");
+        }
+
+        return PendingIntent.getActivitiesAsUser(mSourceContext, requestCode, getIntents(), flags,
+                options, user);
+    }
+
+    /**
      * Return an array containing the intents added to this builder. The intent at the
      * root of the task stack will appear as the first item in the array and the
      * intent at the top of the stack will appear as the last item.
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 8bfefd4..557d3f3 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -40,8 +40,6 @@
     void reboot(String reason);
     void crash(String message);
 
-    void clearUserActivityTimeout(long now, long timeout);
-    void setPokeLock(int pokey, IBinder lock, String tag);
     void setStayOnSetting(int val);
     void setMaximumScreenOffTimeoutFromDeviceAdmin(int timeMs);
 
diff --git a/core/java/android/os/LocalPowerManager.java b/core/java/android/os/LocalPowerManager.java
deleted file mode 100644
index 519315c..0000000
--- a/core/java/android/os/LocalPowerManager.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.os;
-
-/** @hide */
-public interface LocalPowerManager {
-    // FIXME: Replace poke locks with something else.
-
-    public static final int POKE_LOCK_IGNORE_TOUCH_EVENTS = 0x1;
-
-    public static final int POKE_LOCK_SHORT_TIMEOUT = 0x2;
-    public static final int POKE_LOCK_MEDIUM_TIMEOUT = 0x4;
-    public static final int POKE_LOCK_TIMEOUT_MASK = 0x6;
-}
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 58372f4..ae50ddb 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -340,6 +340,15 @@
     }
 
     /**
+     * Returns true if the twilight service should be used to adjust screen brightness
+     * policy.  This setting is experimental and disabled by default.
+     * @hide
+     */
+    public static boolean useTwilightAdjustmentFeature() {
+        return SystemProperties.getBoolean("persist.power.usetwilightadj", false);
+    }
+
+    /**
      * Creates a new wake lock with the specified level and flags.
      * <p>
      * The {@code levelAndFlags} parameter specifies a wake lock level and optional flags
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 8825f58..8f1210b 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3078,30 +3078,6 @@
         public static final String BLUETOOTH_ON = Global.BLUETOOTH_ON;
 
         /**
-         * Get the key that retrieves a bluetooth headset's priority.
-         * @hide
-         */
-        public static final String getBluetoothHeadsetPriorityKey(String address) {
-            return ("bluetooth_headset_priority_" + address.toUpperCase());
-        }
-
-        /**
-         * Get the key that retrieves a bluetooth a2dp sink's priority.
-         * @hide
-         */
-        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
-            return ("bluetooth_a2dp_sink_priority_" + address.toUpperCase());
-        }
-
-        /**
-         * Get the key that retrieves a bluetooth Input Device's priority.
-         * @hide
-         */
-        public static final String getBluetoothInputDevicePriorityKey(String address) {
-            return ("bluetooth_input_device_priority_" + address.toUpperCase());
-        }
-
-        /**
          * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead
          */
         @Deprecated
@@ -5160,6 +5136,40 @@
          */
         public static final String DEFAULT_DNS_SERVER = "default_dns_server";
 
+        /** {@hide} */
+        public static final String
+                BLUETOOTH_HEADSET_PRIORITY_PREFIX = "bluetooth_headset_priority_";
+        /** {@hide} */
+        public static final String
+                BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX = "bluetooth_a2dp_sink_priority_";
+        /** {@hide} */
+        public static final String
+                BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX = "bluetooth_input_device_priority_";
+
+        /**
+         * Get the key that retrieves a bluetooth headset's priority.
+         * @hide
+         */
+        public static final String getBluetoothHeadsetPriorityKey(String address) {
+            return BLUETOOTH_HEADSET_PRIORITY_PREFIX + address.toUpperCase();
+        }
+
+        /**
+         * Get the key that retrieves a bluetooth a2dp sink's priority.
+         * @hide
+         */
+        public static final String getBluetoothA2dpSinkPriorityKey(String address) {
+            return BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX + address.toUpperCase();
+        }
+
+        /**
+         * Get the key that retrieves a bluetooth Input Device's priority.
+         * @hide
+         */
+        public static final String getBluetoothInputDevicePriorityKey(String address) {
+            return BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX + address.toUpperCase();
+        }
+
         // Populated lazily, guarded by class object:
         private static NameValueCache sNameValueCache = new NameValueCache(
                     SYS_PROP_SETTING_VERSION,
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 4838fb7..63ec577 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -17234,7 +17234,7 @@
          * @return the measure specification based on size and mode
          */
         public static int makeMeasureSpec(int size, int mode) {
-            return (size & ~MODE_MASK) | (mode & MODE_MASK);
+            return size + mode;
         }
 
         /**
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index fa2d4e8..6e51270 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -1176,14 +1176,42 @@
         public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
 
         /**
+         * When this window has focus, does not call user activity for all input events so
+         * the application will have to do it itself.  Should only be used by
+         * the keyguard and phone app.
+         * <p>
+         * Should only be used by the keyguard and phone app.
+         * </p>
+         *
+         * @hide
+         */
+        public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004;
+
+        /**
          * Control special features of the input subsystem.
          *
          * @see #INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES
          * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
+         * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY
          * @hide
          */
         public int inputFeatures;
 
+        /**
+         * Sets the number of milliseconds before the user activity timeout occurs
+         * when this window has focus.  A value of -1 uses the standard timeout.
+         * A value of 0 uses the minimum support display timeout.
+         * <p>
+         * This property can only be used to reduce the user specified display timeout;
+         * it can never make the timeout longer than it normally would be.
+         * </p><p>
+         * Should only be used by the keyguard and phone app.
+         * </p>
+         *
+         * @hide
+         */
+        public long userActivityTimeout = -1;
+
         public LayoutParams() {
             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
             type = TYPE_APPLICATION;
@@ -1268,6 +1296,7 @@
             out.writeInt(subtreeSystemUiVisibility);
             out.writeInt(hasSystemUiListeners ? 1 : 0);
             out.writeInt(inputFeatures);
+            out.writeLong(userActivityTimeout);
         }
         
         public static final Parcelable.Creator<LayoutParams> CREATOR
@@ -1308,6 +1337,7 @@
             subtreeSystemUiVisibility = in.readInt();
             hasSystemUiListeners = in.readInt() != 0;
             inputFeatures = in.readInt();
+            userActivityTimeout = in.readLong();
         }
     
         @SuppressWarnings({"PointlessBitwiseExpression"})
@@ -1334,6 +1364,8 @@
         /** {@hide} */
         public static final int PRIVATE_FLAGS_CHANGED = 1<<16;
         /** {@hide} */
+        public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<17;
+        /** {@hide} */
         public static final int EVERYTHING_CHANGED = 0xffffffff;
 
         // internal buffer to backup/restore parameters under compatibility mode.
@@ -1455,6 +1487,11 @@
                 changes |= INPUT_FEATURES_CHANGED;
             }
 
+            if (userActivityTimeout != o.userActivityTimeout) {
+                userActivityTimeout = o.userActivityTimeout;
+                changes |= USER_ACTIVITY_TIMEOUT_CHANGED;
+            }
+
             return changes;
         }
     
@@ -1547,6 +1584,9 @@
             if (inputFeatures != 0) {
                 sb.append(" if=0x").append(Integer.toHexString(inputFeatures));
             }
+            if (userActivityTimeout >= 0) {
+                sb.append(" userActivityTimeout=").append(userActivityTimeout);
+            }
             sb.append('}');
             return sb.toString();
         }
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 1d465ce..87396fb 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -789,12 +789,6 @@
                     if (resizeWidth) {
                         int newWidth = (int)(desiredAspect * (heightSize - ptop - pbottom)) +
                                 pleft + pright;
-
-                        // Allow the width to outgrow its original estimate if height is fixed.
-                        if (!resizeHeight) {
-                            widthSize = resolveAdjustedSize(newWidth, mMaxWidth, widthMeasureSpec);
-                        }
-
                         if (newWidth <= widthSize) {
                             widthSize = newWidth;
                             done = true;
@@ -805,13 +799,6 @@
                     if (!done && resizeHeight) {
                         int newHeight = (int)((widthSize - pleft - pright) / desiredAspect) +
                                 ptop + pbottom;
-
-                        // Allow the height to outgrow its original estimate if width is fixed.
-                        if (!resizeWidth) {
-                            heightSize = resolveAdjustedSize(newHeight, mMaxHeight,
-                                    heightMeasureSpec);
-                        }
-
                         if (newHeight <= heightSize) {
                             heightSize = newHeight;
                         }
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index 5f46d89..455355f 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -369,10 +369,10 @@
         int width = 0;
         int height = 0;
 
-        final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
-        final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
-        final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
-        final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+        int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+        int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+        int heightSize = MeasureSpec.getSize(heightMeasureSpec);
 
         // Record our dimensions if they are known;
         if (widthMode != MeasureSpec.UNSPECIFIED) {
@@ -637,12 +637,7 @@
                 mPaddingLeft, mPaddingRight,
                 myWidth);
         int childHeightMeasureSpec;
-        if (myHeight < 0) {
-            // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement
-            // is code for, "we got an unspecified mode in the RelativeLayout's measurespec."
-            // Carry it forward.
-            childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
-        } else if (params.width == LayoutParams.MATCH_PARENT) {
+        if (params.width == LayoutParams.MATCH_PARENT) {
             childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(myHeight, MeasureSpec.EXACTLY);
         } else {
             childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(myHeight, MeasureSpec.AT_MOST);
@@ -669,13 +664,6 @@
     private int getChildMeasureSpec(int childStart, int childEnd,
             int childSize, int startMargin, int endMargin, int startPadding,
             int endPadding, int mySize) {
-        if (mySize < 0) {
-            // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement
-            // is code for, "we got an unspecified mode in the RelativeLayout's measurespec."
-            // Carry it forward.
-            return MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
-        }
-
         int childSpecMode = 0;
         int childSpecSize = 0;
 
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index 600c27a..04e5bc9 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -33,6 +33,7 @@
     void topAppWindowChanged(boolean menuVisible);
     void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
     void expandSettingsPanel();
+    void setCurrentUser(int newUserId);
 
     // ---- Methods below are for use by the status bar policy services ----
     // You need the STATUS_BAR_SERVICE permission
diff --git a/core/res/res/drawable-hdpi/ic_media_route_on_0_holo_dark.png b/core/res/res/drawable-hdpi/ic_media_route_on_0_holo_dark.png
new file mode 100644
index 0000000..10fc8da
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_media_route_on_0_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_media_route_on_0_holo_light.png b/core/res/res/drawable-hdpi/ic_media_route_on_0_holo_light.png
new file mode 100644
index 0000000..a0e5060
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_media_route_on_0_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_media_route_on_1_holo_dark.png b/core/res/res/drawable-hdpi/ic_media_route_on_1_holo_dark.png
new file mode 100644
index 0000000..8364a36
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_media_route_on_1_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_media_route_on_1_holo_light.png b/core/res/res/drawable-hdpi/ic_media_route_on_1_holo_light.png
new file mode 100644
index 0000000..44b89e1
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_media_route_on_1_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_media_route_on_2_holo_dark.png b/core/res/res/drawable-hdpi/ic_media_route_on_2_holo_dark.png
new file mode 100644
index 0000000..770bf78
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_media_route_on_2_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_media_route_on_2_holo_light.png b/core/res/res/drawable-hdpi/ic_media_route_on_2_holo_light.png
new file mode 100644
index 0000000..2a2467b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_media_route_on_2_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_media_route_on_0_holo_dark.png b/core/res/res/drawable-mdpi/ic_media_route_on_0_holo_dark.png
new file mode 100644
index 0000000..fb2ac25
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_media_route_on_0_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_media_route_on_0_holo_light.png b/core/res/res/drawable-mdpi/ic_media_route_on_0_holo_light.png
new file mode 100644
index 0000000..0c20091
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_media_route_on_0_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_media_route_on_1_holo_dark.png b/core/res/res/drawable-mdpi/ic_media_route_on_1_holo_dark.png
new file mode 100644
index 0000000..2f70cee
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_media_route_on_1_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_media_route_on_1_holo_light.png b/core/res/res/drawable-mdpi/ic_media_route_on_1_holo_light.png
new file mode 100644
index 0000000..0b76d8e
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_media_route_on_1_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_media_route_on_2_holo_dark.png b/core/res/res/drawable-mdpi/ic_media_route_on_2_holo_dark.png
new file mode 100644
index 0000000..ae7b105
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_media_route_on_2_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_media_route_on_2_holo_light.png b/core/res/res/drawable-mdpi/ic_media_route_on_2_holo_light.png
new file mode 100644
index 0000000..8d37b99
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_media_route_on_2_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_media_route_on_0_holo_dark.png b/core/res/res/drawable-xhdpi/ic_media_route_on_0_holo_dark.png
new file mode 100644
index 0000000..483b612
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_media_route_on_0_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_media_route_on_0_holo_light.png b/core/res/res/drawable-xhdpi/ic_media_route_on_0_holo_light.png
new file mode 100644
index 0000000..c3507dc
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_media_route_on_0_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_media_route_on_1_holo_dark.png b/core/res/res/drawable-xhdpi/ic_media_route_on_1_holo_dark.png
new file mode 100644
index 0000000..24c6519
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_media_route_on_1_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_media_route_on_1_holo_light.png b/core/res/res/drawable-xhdpi/ic_media_route_on_1_holo_light.png
new file mode 100644
index 0000000..2be0380
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_media_route_on_1_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_media_route_on_2_holo_dark.png b/core/res/res/drawable-xhdpi/ic_media_route_on_2_holo_dark.png
new file mode 100644
index 0000000..4fd69bd
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_media_route_on_2_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_media_route_on_2_holo_light.png b/core/res/res/drawable-xhdpi/ic_media_route_on_2_holo_light.png
new file mode 100644
index 0000000..51588564
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_media_route_on_2_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable/ic_media_route_connecting_holo_dark.xml b/core/res/res/drawable/ic_media_route_connecting_holo_dark.xml
new file mode 100644
index 0000000..36e01f6
--- /dev/null
+++ b/core/res/res/drawable/ic_media_route_connecting_holo_dark.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.
+ */
+-->
+<animation-list
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:oneshot="false">
+    <item android:drawable="@drawable/ic_media_route_on_0_holo_dark" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_1_holo_dark" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_2_holo_dark" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_holo_dark" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_2_holo_dark" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_1_holo_dark" android:duration="500" />
+</animation-list>
diff --git a/core/res/res/drawable/ic_media_route_connecting_holo_light.xml b/core/res/res/drawable/ic_media_route_connecting_holo_light.xml
new file mode 100644
index 0000000..6683db8
--- /dev/null
+++ b/core/res/res/drawable/ic_media_route_connecting_holo_light.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.
+ */
+-->
+<animation-list
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:oneshot="false">
+    <item android:drawable="@drawable/ic_media_route_on_0_holo_light" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_1_holo_light" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_2_holo_light" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_holo_light" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_2_holo_light" android:duration="500" />
+    <item android:drawable="@drawable/ic_media_route_on_1_holo_light" android:duration="500" />
+</animation-list>
diff --git a/core/res/res/drawable/ic_media_route_holo_dark.xml b/core/res/res/drawable/ic_media_route_holo_dark.xml
index 0b267d7..b4c1fac 100644
--- a/core/res/res/drawable/ic_media_route_holo_dark.xml
+++ b/core/res/res/drawable/ic_media_route_holo_dark.xml
@@ -15,6 +15,7 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_checked="true" android:state_enabled="true" android:drawable="@android:drawable/ic_media_route_connecting_holo_dark" />
     <item android:state_activated="true" android:state_enabled="true" android:drawable="@android:drawable/ic_media_route_on_holo_dark" />
     <item android:state_enabled="true" android:drawable="@android:drawable/ic_media_route_off_holo_dark" />
     <item android:drawable="@android:drawable/ic_media_route_disabled_holo_dark" />
diff --git a/core/res/res/drawable/ic_media_route_holo_light.xml b/core/res/res/drawable/ic_media_route_holo_light.xml
index 377253a..553721d6 100644
--- a/core/res/res/drawable/ic_media_route_holo_light.xml
+++ b/core/res/res/drawable/ic_media_route_holo_light.xml
@@ -15,6 +15,7 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_checked="true" android:state_enabled="true" android:drawable="@android:drawable/ic_media_route_connecting_holo_light" />
     <item android:state_activated="true" android:state_enabled="true" android:drawable="@android:drawable/ic_media_route_on_holo_light" />
     <item android:state_enabled="true" android:drawable="@android:drawable/ic_media_route_off_holo_light" />
     <item android:drawable="@android:drawable/ic_media_route_disabled_holo_light" />
diff --git a/core/res/res/layout-xlarge/select_dialog_holo.xml b/core/res/res/layout-xlarge/select_dialog_holo.xml
deleted file mode 100644
index f931cf2..0000000
--- a/core/res/res/layout-xlarge/select_dialog_holo.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 2010, 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.
-*/
--->
-
-<!--
-    This layout file is used by the AlertDialog when displaying a list of items.
-    This layout file is inflated and used as the ListView to display the items.
-    Assign an ID so its state will be saved/restored.
--->
-<view class="com.android.internal.app.AlertController$RecycleListView"
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+android:id/select_dialog_listview"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layout_marginTop="5dip"
-    android:paddingStart="16dip"
-    android:paddingEnd="16dip"
-    android:cacheColorHint="@null"
-    android:divider="?android:attr/listDividerAlertDialog"
-    android:scrollbars="vertical"
-    android:overScrollMode="ifContentScrolls" />
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 2a0a84b..75850dd 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -649,6 +649,8 @@
         <item name="listPreferredItemPaddingRight">10dip</item>
         <item name="listPreferredItemPaddingStart">10dip</item>
         <item name="listPreferredItemPaddingEnd">10dip</item>
+
+        <item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
     </style>
 
     <!-- Variant of {@link Theme_Dialog} that does not include a frame (or background).
@@ -1608,6 +1610,8 @@
         <item name="listPreferredItemPaddingRight">16dip</item>
         <item name="listPreferredItemPaddingStart">16dip</item>
         <item name="listPreferredItemPaddingEnd">16dip</item>
+
+        <item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
     </style>
 
     <!-- Variant of Theme.Holo.Dialog that has a nice minimum width for
@@ -1722,6 +1726,8 @@
         <item name="listPreferredItemPaddingRight">16dip</item>
         <item name="listPreferredItemPaddingStart">16dip</item>
         <item name="listPreferredItemPaddingEnd">16dip</item>
+
+        <item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
     </style>
 
     <!-- Variant of Theme.Holo.Light.Dialog that has a nice minimum width for
diff --git a/docs/html/about/dashboards/index.jd b/docs/html/about/dashboards/index.jd
index c3da3bf..6555733 100644
--- a/docs/html/about/dashboards/index.jd
+++ b/docs/html/about/dashboards/index.jd
@@ -30,33 +30,31 @@
   <th>API</th>
   <th>Distribution</th>
 </tr>
-<tr><td><a href="/about/versions/android-1.5.html">1.5</a></td><td>Cupcake</td>  <td>3</td><td>0.2%</td></tr>
+<tr><td><a href="/about/versions/android-1.5.html">1.5</a></td><td>Cupcake</td>  <td>3</td><td>0.1%</td></tr>
 <tr><td><a href="/about/versions/android-1.6.html">1.6</a></td><td>Donut</td>    <td>4</td><td>0.4%</td></tr>
-<tr><td><a href="/about/versions/android-2.1.html">2.1</a></td><td>Eclair</td>   <td>7</td><td>3.7%</td></tr>
-<tr><td><a href="/about/versions/android-2.2.html">2.2</a></td><td>Froyo</td>    <td>8</td><td>14%</td></tr>
+<tr><td><a href="/about/versions/android-2.1.html">2.1</a></td><td>Eclair</td>   <td>7</td><td>3.4%</td></tr>
+<tr><td><a href="/about/versions/android-2.2.html">2.2</a></td><td>Froyo</td>    <td>8</td><td>12.9%</td></tr>
 <tr><td><a href="/about/versions/android-2.3.html">2.3 - 2.3.2</a>
                                    </td><td rowspan="2">Gingerbread</td>    <td>9</td><td>0.3%</td></tr>
 <tr><td><a href="/about/versions/android-2.3.3.html">2.3.3 - 2.3.7
-        </a></td><!-- Gingerbread -->                                       <td>10</td><td>57.2%</td></tr>
+        </a></td><!-- Gingerbread -->                                       <td>10</td><td>55.5%</td></tr>
 <tr><td><a href="/about/versions/android-3.1.html">3.1</a></td>
-                                                   <td rowspan="2">Honeycomb</td>      <td>12</td><td>0.5%</td></tr>
-<tr><td><a href="/about/versions/android-3.2.html">3.2</a></td>      <!-- Honeycomb --><td>13</td><td>1.6%</td></tr> 
-<tr><td><a href="/about/versions/android-4.0.html">4.0 - 4.0.2</a></td>
-                                                <td rowspan="2">Ice Cream Sandwich</td><td>14</td><td>0.1%</td></tr> 
+                                                   <td rowspan="2">Honeycomb</td>      <td>12</td><td>0.4%</td></tr>
+<tr><td><a href="/about/versions/android-3.2.html">3.2</a></td>      <!-- Honeycomb --><td>13</td><td>1.5%</td></tr>
 <tr><td><a href="/about/versions/android-4.0.3.html">4.0.3 - 4.0.4</a></td>
-                                                                     <!-- ICS     -->  <td>15</td><td>20.8%</td></tr> 
-<tr><td><a href="/about/versions/android-4.1.html">4.1</a></td>   <td>Jelly Bean</td><td>16</td><td>1.2%</td></tr> 
+                                                            <td>Ice Cream Sandwich</td><td>15</td><td>23.7%</td></tr> 
+<tr><td><a href="/about/versions/android-4.1.html">4.1</a></td>   <td>Jelly Bean</td><td>16</td><td>1.8%</td></tr> 
 </table>
 
 </div>
 
 <div class="col-8" style="margin-right:0">
 <img alt=""
-src="http://chart.apis.google.com/chart?&cht=p&chs=460x245&chd=t:4.3,14,57.5,2.1,20.9,1.2&chl=Eclair%20%26%20older|Froyo|Gingerbread|Honeycomb|Ice%20Cream%20Sandwich|Jelly%20Bean&chco=c4df9b,6fad0c&chf=bg,s,00000000" />
+src="http://chart.apis.google.com/chart?&cht=p&chs=460x245&chd=t:3.9,12.9,55.8,1.9,23.7,1.8&chl=Eclair%20%26%20older|Froyo|Gingerbread|Honeycomb|Ice%20Cream%20Sandwich|Jelly%20Bean&chco=c4df9b,6fad0c&chf=bg,s,00000000" />
 
 </div><!-- end dashboard-panel -->
 
-<p style="clear:both"><em>Data collected during a 14-day period ending on September 4, 2012</em></p>
+<p style="clear:both"><em>Data collected during a 14-day period ending on October 1, 2012</em></p>
 <!--
 <p style="font-size:.9em">* <em>Other: 0.1% of devices running obsolete versions</em></p>
 -->
@@ -81,9 +79,9 @@
 Google Play within a 14-day period ending on the date indicated on the x-axis.</p>
 
 <img alt="" height="250" width="660"
-src="http://chart.apis.google.com/chart?&cht=lc&chs=660x250&chxt=x,x,y,r&chf=bg,s,00000000&chxr=0,0,12|1,0,12|2,0,100|3,0,100&chxl=0%3A%7C03/01%7C03/15%7C04/01%7C04/15%7C05/01%7C05/15%7C06/01%7C06/15%7C07/01%7C07/15%7C08/01%7C08/15%7C09/01%7C1%3A%7C2012%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C2012%7C2%3A%7C0%25%7C25%25%7C50%25%7C75%25%7C100%25%7C3%3A%7C0%25%7C25%25%7C50%25%7C75%25%7C100%25&chxp=0,0,1,2,3,4,5,6,7,8,9,10,11,12&chxtc=0,5&chd=t:97.6,97.8,97.8,97.9,98.1,98.1,98.3,98.5,98.6,98.7,98.9,98.9,99.0|90.8,91.4,91.8,92.1,92.5,92.7,93.1,93.5,93.9,94.2,94.7,94.9,95.3|65.2,66.8,68.6,69.9,71.5,72.6,74.0,75.2,76.5,77.8,79.2,80.1,81.1|4.3,4.6,5.5,6.5,7.6,8.2,9.4,11.0,12.8,15.6,18.9,21.2,23.7|3.2,3.5,4.5,5.5,6.6,7.4,8.7,10.4,12.3,15.1,18.4,20.7,23.2|1.1,1.3,2.3,3.3,4.4,5.3,6.7,8.4,10.4,13.2,16.6,19.0,21.5|0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.8,0.9,1.1&chm=b,c3df9b,0,1,0|tAndroid%202.2,6c9729,1,0,15,,t::-5|b,b6dc7d,1,2,0|tAndroid%202.3.3,5b831d,2,0,15,,t::-5|b,aadb5e,2,3,0|b,9ddb3d,3,4,0|b,91da1e,4,5,0|tAndroid%204.0.3,253a06,5,8,15,,t::-5|b,80c414,5,6,0|B,6fad0c,6,7,0&chg=7,25&chdl=Android%202.1|Android%202.2|Android%202.3.3|Android%203.1|Android%203.2|Android%204.0.3|Android%204.1&chco=add274,a0d155,94d134,84c323,73ad18,62960f,507d08" />
+src="http://chart.apis.google.com/chart?&cht=lc&chs=660x250&chxt=x,x,y,r&chf=bg,s,00000000&chxr=0,0,12|1,0,12|2,0,100|3,0,100&chxl=0%3A%7C04/01%7C04/15%7C05/01%7C05/15%7C06/01%7C06/15%7C07/01%7C07/15%7C08/01%7C08/15%7C09/01%7C09/15%7C10/01%7C1%3A%7C2012%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C2012%7C2%3A%7C0%25%7C25%25%7C50%25%7C75%25%7C100%25%7C3%3A%7C0%25%7C25%25%7C50%25%7C75%25%7C100%25&chxp=0,0,1,2,3,4,5,6,7,8,9,10,11,12&chxtc=0,5&chd=t:97.8,97.9,98.1,98.1,98.3,98.5,98.6,98.7,98.9,98.9,99.0,99.1,99.2|91.8,92.1,92.5,92.7,93.1,93.5,93.9,94.2,94.7,94.9,95.3,95.5,95.8|68.6,69.9,71.5,72.6,74.0,75.2,76.5,77.8,79.2,80.1,81.1,82.0,82.9|5.5,6.5,7.6,8.2,9.4,11.0,12.8,15.6,18.9,21.2,23.7,25.5,27.4|4.5,5.5,6.6,7.4,8.7,10.4,12.3,15.1,18.4,20.7,23.2,25.1,27.0|2.3,3.3,4.4,5.3,6.7,8.4,10.4,13.2,16.6,19.0,21.5,23.5,25.5|0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.8,0.9,1.1,1.4,1.8&chm=b,c3df9b,0,1,0|tAndroid%202.2,6c9729,1,0,15,,t::-5|b,b6dc7d,1,2,0|tAndroid%202.3.3,5b831d,2,0,15,,t::-5|b,aadb5e,2,3,0|b,9ddb3d,3,4,0|b,91da1e,4,5,0|tAndroid%204.0.3,253a06,5,6,15,,t::-5|b,80c414,5,6,0|B,6fad0c,6,7,0&chg=7,25&chdl=Android%202.1|Android%202.2|Android%202.3.3|Android%203.1|Android%203.2|Android%204.0.3|Android%204.1&chco=add274,a0d155,94d134,84c323,73ad18,62960f,507d08" />
 
-<p><em>Last historical dataset collected during a 14-day period ending on September 1, 2012</em></p>
+<p><em>Last historical dataset collected during a 14-day period ending on October 1, 2012</em></p>
 
 
 
@@ -112,11 +110,11 @@
 
 
 <img alt="" style="float:right;"
-src="http://chart.googleapis.com/chart?cht=p&chs=400x250&chf=bg,s,00000000&chco=c4df9b,6fad0c&chl=Xlarge%7CLarge%7CNormal%7CSmall&chd=t%3A4.7,6.5,86,2.8" />
+src="http://chart.googleapis.com/chart?cht=p&chs=400x250&chf=bg,s,00000000&chco=c4df9b,6fad0c&chl=Xlarge%7CLarge%7CNormal%7CSmall&chd=t%3A4.6,6.1,86.6,2.7" />
 
 
 <img alt="" style="float:right;clear:right"
-src="http://chart.googleapis.com/chart?cht=p&chs=400x250&chf=bg,s,00000000&chco=c4df9b,6fad0c&chl=ldpi%7Cmdpi%7Chdpi%7Cxhdpi&chd=t%3A1.6,18.6,53.6,26.2" />
+src="http://chart.googleapis.com/chart?cht=p&chs=400x250&chf=bg,s,00000000&chco=c4df9b,6fad0c&chl=ldpi%7Cmdpi%7Chdpi%7Cxhdpi&chd=t%3A2.2,18,51.1,28.7" />
 
 <p>This section provides data about the relative number of active devices that have a particular
 screen configuration, defined by a combination of screen size and density. To simplify the way that
@@ -148,32 +146,32 @@
 <th scope="col">xhdpi</th>
 </tr>
 <tr><th scope="row">small</th> 
-<td>1.1%</td>     <!-- small/ldpi -->
+<td>1.7%</td>     <!-- small/ldpi -->
 <td></td>     <!-- small/mdpi -->
-<td>1.7%</td> <!-- small/hdpi -->
+<td>1.0%</td> <!-- small/hdpi -->
 <td></td>     <!-- small/xhdpi -->
 </tr> 
 <tr><th scope="row">normal</th> 
 <td>0.4%</td>  <!-- normal/ldpi -->
-<td>11.4%</td> <!-- normal/mdpi -->
-<td>51.9%</td> <!-- normal/hdpi -->
-<td>22.3%</td>      <!-- normal/xhdpi -->
+<td>11%</td> <!-- normal/mdpi -->
+<td>50.1%</td> <!-- normal/hdpi -->
+<td>25.1%</td>      <!-- normal/xhdpi -->
 </tr> 
 <tr><th scope="row">large</th> 
 <td>0.1%</td>     <!-- large/ldpi -->
-<td>2.5%</td> <!-- large/mdpi -->
+<td>2.4%</td> <!-- large/mdpi -->
 <td></td>     <!-- large/hdpi -->
-<td>3.9%</td>     <!-- large/xhdpi -->
+<td>3.6%</td>     <!-- large/xhdpi -->
 </tr> 
 <tr><th scope="row">xlarge</th> 
 <td></td>     <!-- xlarge/ldpi -->
-<td>4.7%</td> <!-- xlarge/mdpi -->
+<td>4.6%</td> <!-- xlarge/mdpi -->
 <td></td>     <!-- xlarge/hdpi -->
 <td></td>     <!-- xlarge/xhdpi -->
 </tr> 
 </table>
 
-<p style="clear:both"><em>Data collected during a 7-day period ending on September 4, 2012</em></p>
+<p style="clear:both"><em>Data collected during a 7-day period ending on October 1, 2012</em></p>
 
 
 
@@ -225,4 +223,4 @@
 
 
 
-<p style="clear:both"><em>Data collected during a 7-day period ending on September 4, 2012</em></p>
+<p style="clear:both"><em>Data collected during a 7-day period ending on October 1, 2012</em></p>
diff --git a/docs/html/distribute/googleplay/promote/brand.jd b/docs/html/distribute/googleplay/promote/brand.jd
index 875794a..cb6bf48 100644
--- a/docs/html/distribute/googleplay/promote/brand.jd
+++ b/docs/html/distribute/googleplay/promote/brand.jd
@@ -95,7 +95,7 @@
 
 <p>When referring to the mobile experience, use "Google Play" unless the text is clearly
 instructional for the user. For example, a marketing headline might read "Download our
-games on Google Play&trade;," but instructional text woud read "Download our games using the Google
+games on Google Play&trade;," but instructional text would read "Download our games using the Google
 Play&trade; Store app."
 
  <p>Any use of the Google Play name or icon needs to include this
@@ -117,8 +117,9 @@
 
 <p>You may use the Google Play Store icon, but you may not modify it.</p>
 
-<p>When labeling or referring to the icon, the name can be either the full app
-name, Google Play Store, or the app display name, Play Store.</p>
+<p>As mentioned above, when referring to the Google Play Store app in copy, use the full name:
+"Google Play Store." However, when labelling the Google Play Store icon directly, it's OK to use
+"Play Store" without "Google" (which is how the icon is labelled on a device).</p>
 
         
 <h4>Google Play badge</h4>
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index c015077..c2e6ee3 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1265,7 +1265,7 @@
 }
 
 bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) {
-    if (mSnapshot->isIgnored()) {
+    if (mSnapshot->isIgnored() || bottom <= top || right <= left) {
         return true;
     }
 
@@ -1951,6 +1951,11 @@
     // TODO: try clipping large paths to viewport
     PathRenderer::convexPathVertices(path, paint, mSnapshot->transform, vertexBuffer);
 
+    if (!vertexBuffer.getSize()) {
+        // no vertices to draw
+        return;
+    }
+
     setupDraw();
     setupDrawNoTexture();
     if (isAA) setupDrawAA();
diff --git a/libs/hwui/PathRenderer.cpp b/libs/hwui/PathRenderer.cpp
index 4a66c62..5b55c2b 100644
--- a/libs/hwui/PathRenderer.cpp
+++ b/libs/hwui/PathRenderer.cpp
@@ -323,6 +323,11 @@
     convexPathPerimeterVertices(path, threshInvScaleX * threshInvScaleX,
             threshInvScaleY * threshInvScaleY, tempVertices);
 
+    if (!tempVertices.size()) {
+        // path was empty, return without allocating vertex buffer
+        return;
+    }
+
 #if VERTEX_DEBUG
     for (unsigned int i = 0; i < tempVertices.size(); i++) {
         ALOGD("orig path: point at %f %f", tempVertices[i].position[0], tempVertices[i].position[1]);
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index 36c9c70..e5b9637 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -105,8 +105,13 @@
             mDefaultAudioVideo = new RouteInfo(mSystemCategory);
             mDefaultAudioVideo.mNameResId = com.android.internal.R.string.default_audio_route_name;
             mDefaultAudioVideo.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO | ROUTE_TYPE_LIVE_VIDEO;
-            addRoute(mDefaultAudioVideo);
+            addRouteStatic(mDefaultAudioVideo);
 
+            // This will select the active wifi display route if there is one.
+            updateWifiDisplayStatus(mDisplayService.getWifiDisplayStatus());
+
+            appContext.registerReceiver(new WifiDisplayStatusChangedReceiver(),
+                    new IntentFilter(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED));
             appContext.registerReceiver(new VolumeChangeReceiver(),
                     new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION));
 
@@ -116,13 +121,17 @@
             } catch (RemoteException e) {
             }
             if (newAudioRoutes != null) {
+                // This will select the active BT route if there is one and the current
+                // selected route is the default system route, or if there is no selected
+                // route yet.
                 updateAudioRoutes(newAudioRoutes);
             }
 
-            updateWifiDisplayStatus(mDisplayService.getWifiDisplayStatus());
-
-            appContext.registerReceiver(new WifiDisplayStatusChangedReceiver(),
-                    new IntentFilter(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED));
+            // Select the default route if the above didn't sync us up
+            // appropriately with relevant system state.
+            if (mSelectedRoute == null) {
+                selectRouteStatic(mDefaultAudioVideo.getSupportedTypes(), mDefaultAudioVideo);
+            }
         }
 
         void updateAudioRoutes(AudioRoutesInfo newRoutes) {
@@ -159,7 +168,7 @@
                         info.mName = mCurAudioRoutesInfo.mBluetoothName;
                         info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO;
                         sStatic.mBluetoothA2dpRoute = info;
-                        addRoute(sStatic.mBluetoothA2dpRoute);
+                        addRouteStatic(sStatic.mBluetoothA2dpRoute);
                     } else {
                         sStatic.mBluetoothA2dpRoute.mName = mCurAudioRoutesInfo.mBluetoothName;
                         dispatchRouteChanged(sStatic.mBluetoothA2dpRoute);
@@ -175,7 +184,8 @@
                         mSelectedRoute == mBluetoothA2dpRoute) {
                     selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mDefaultAudioVideo);
                 } else if (mCurAudioRoutesInfo.mMainType == AudioRoutesInfo.MAIN_SPEAKER &&
-                        mSelectedRoute == mDefaultAudioVideo && a2dpEnabled) {
+                        (mSelectedRoute == mDefaultAudioVideo || mSelectedRoute == null) &&
+                        a2dpEnabled) {
                     selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mBluetoothA2dpRoute);
                 }
             }
@@ -393,22 +403,21 @@
      * @see #removeUserRoute(UserRouteInfo)
      */
     public void addUserRoute(UserRouteInfo info) {
-        addRoute(info);
+        addRouteStatic(info);
     }
 
     /**
      * @hide Framework use only
      */
     public void addRouteInt(RouteInfo info) {
-        addRoute(info);
+        addRouteStatic(info);
     }
 
-    static void addRoute(RouteInfo info) {
+    static void addRouteStatic(RouteInfo info) {
         final RouteCategory cat = info.getCategory();
         if (!sStatic.mCategories.contains(cat)) {
             sStatic.mCategories.add(cat);
         }
-        final boolean onlyRoute = sStatic.mRoutes.isEmpty();
         if (cat.isGroupable() && !(info instanceof RouteGroup)) {
             // Enforce that any added route in a groupable category must be in a group.
             final RouteGroup group = new RouteGroup(info.getCategory());
@@ -422,10 +431,6 @@
             sStatic.mRoutes.add(info);
             dispatchRouteAdded(info);
         }
-
-        if (onlyRoute) {
-            selectRouteStatic(info.getSupportedTypes(), info);
-        }
     }
 
     /**
@@ -693,18 +698,25 @@
                 oldStatus.getRememberedDisplays() : new WifiDisplay[0];
         WifiDisplay[] newDisplays = newStatus.getRememberedDisplays();
         WifiDisplay[] availableDisplays = newStatus.getAvailableDisplays();
+        WifiDisplay activeDisplay = newStatus.getActiveDisplay();
 
         for (int i = 0; i < newDisplays.length; i++) {
             final WifiDisplay d = newDisplays[i];
             final WifiDisplay oldRemembered = findMatchingDisplay(d, oldDisplays);
             if (oldRemembered == null) {
-                addRoute(makeWifiDisplayRoute(d));
+                addRouteStatic(makeWifiDisplayRoute(d));
                 needScan = true;
             } else {
                 final boolean available = findMatchingDisplay(d, availableDisplays) != null;
                 final RouteInfo route = findWifiDisplayRoute(d);
                 updateWifiDisplayRoute(route, d, available, newStatus);
             }
+            if (d.equals(activeDisplay)) {
+                final RouteInfo activeRoute = findWifiDisplayRoute(d);
+                if (activeRoute != null) {
+                    selectRouteStatic(activeRoute.getSupportedTypes(), activeRoute);
+                }
+            }
         }
         for (int i = 0; i < oldDisplays.length; i++) {
             final WifiDisplay d = oldDisplays[i];
@@ -840,11 +852,11 @@
         // A predetermined connection status that can override mStatus
         private int mStatusCode;
 
-        static final int STATUS_NONE = 0;
-        static final int STATUS_SCANNING = 1;
-        static final int STATUS_CONNECTING = 2;
-        static final int STATUS_AVAILABLE = 3;
-        static final int STATUS_NOT_AVAILABLE = 4;
+        /** @hide */ public static final int STATUS_NONE = 0;
+        /** @hide */ public static final int STATUS_SCANNING = 1;
+        /** @hide */ public static final int STATUS_CONNECTING = 2;
+        /** @hide */ public static final int STATUS_AVAILABLE = 3;
+        /** @hide */ public static final int STATUS_NOT_AVAILABLE = 4;
 
         private Object mTag;
 
@@ -941,6 +953,13 @@
         }
 
         /**
+         * @hide
+         */
+        public int getStatusCode() {
+            return mStatusCode;
+        }
+
+        /**
          * @return A media type flag set describing which types this route supports.
          */
         public int getSupportedTypes() {
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index c8ce3cd..06c8e11 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -68,7 +68,7 @@
     // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
     // is properly propagated through your change.  Not doing so will result in a loss of user
     // settings.
-    private static final int DATABASE_VERSION = 89;
+    private static final int DATABASE_VERSION = 90;
 
     private Context mContext;
     private int mUserHandle;
@@ -1380,6 +1380,26 @@
             upgradeVersion = 89;
         }
 
+        if (upgradeVersion == 89) {
+            if (mUserHandle == UserHandle.USER_OWNER) {
+                db.beginTransaction();
+                try {
+                    String[] prefixesToMove = {
+                            Settings.Global.BLUETOOTH_HEADSET_PRIORITY_PREFIX,
+                            Settings.Global.BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX,
+                            Settings.Global.BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX,
+                    };
+
+                    movePrefixedSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, prefixesToMove);
+
+                    db.setTransactionSuccessful();
+                } finally {
+                    db.endTransaction();
+                }
+            }
+            upgradeVersion = 90;
+        }
+
         // *** Remember to update DATABASE_VERSION above!
 
         if (upgradeVersion != currentVersion) {
@@ -1446,6 +1466,44 @@
         }
     }
 
+    /**
+     * Move any settings with the given prefixes from the source table to the
+     * destination table.
+     */
+    private void movePrefixedSettingsToNewTable(
+            SQLiteDatabase db, String sourceTable, String destTable, String[] prefixesToMove) {
+        SQLiteStatement insertStmt = null;
+        SQLiteStatement deleteStmt = null;
+
+        db.beginTransaction();
+        try {
+            insertStmt = db.compileStatement("INSERT INTO " + destTable
+                    + " (name,value) SELECT name,value FROM " + sourceTable
+                    + " WHERE substr(name,0,?)=?");
+            deleteStmt = db.compileStatement(
+                    "DELETE FROM " + sourceTable + " WHERE substr(name,0,?)=?");
+
+            for (String prefix : prefixesToMove) {
+                insertStmt.bindLong(1, prefix.length() + 1);
+                insertStmt.bindString(2, prefix);
+                insertStmt.execute();
+
+                deleteStmt.bindLong(1, prefix.length() + 1);
+                deleteStmt.bindString(2, prefix);
+                deleteStmt.execute();
+            }
+            db.setTransactionSuccessful();
+        } finally {
+            db.endTransaction();
+            if (insertStmt != null) {
+                insertStmt.close();
+            }
+            if (deleteStmt != null) {
+                deleteStmt.close();
+            }
+        }
+    }
+
     private void upgradeLockPatternLocation(SQLiteDatabase db) {
         Cursor c = db.query(TABLE_SYSTEM, new String[] {"_id", "value"}, "name='lock_pattern'",
                 null, null, null, null);
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_hour.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_hour.png
index 979ca08..045a3d1 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_hour.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_hour.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_hour.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_hour.png
index 4dca96a..ee887e9d 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_hour.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_hour.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_hour.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_hour.png
index a293c0b..d1d29dc 100644
--- a/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_hour.png
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_hour.png
Binary files differ
diff --git a/packages/SystemUI/res/values-af/strings.xml b/packages/SystemUI/res/values-af/strings.xml
index e17505c..fe81191 100644
--- a/packages/SystemUI/res/values-af/strings.xml
+++ b/packages/SystemUI/res/values-af/strings.xml
@@ -153,7 +153,7 @@
     <string name="ethernet_label" msgid="7967563676324087464">"Ethernet"</string>
     <string name="quick_settings_airplane_mode_label" msgid="5510520633448831350">"Vliegtuigmodus"</string>
     <string name="quick_settings_battery_charging_label" msgid="490074774465309209">"Laai, <xliff:g id="NUMBER">%d</xliff:g><xliff:g id="PERCENT">%%</xliff:g>"</string>
-    <string name="quick_settings_battery_charged_label" msgid="8865413079414246081">"Gehef"</string>
+    <string name="quick_settings_battery_charged_label" msgid="8865413079414246081">"Gelaai"</string>
     <string name="quick_settings_bluetooth_label" msgid="6304190285170721401">"Bluetooth"</string>
     <string name="quick_settings_bluetooth_multiple_devices_label" msgid="3912245565613684735">"Bluetooth (<xliff:g id="NUMBER">%d</xliff:g> toestelle)"</string>
     <string name="quick_settings_bluetooth_off_label" msgid="8159652146149219937">"Bluetooth af"</string>
diff --git a/packages/SystemUI/res/values-ca/strings.xml b/packages/SystemUI/res/values-ca/strings.xml
index 16a412d..7dcbabf 100644
--- a/packages/SystemUI/res/values-ca/strings.xml
+++ b/packages/SystemUI/res/values-ca/strings.xml
@@ -173,7 +173,7 @@
     <string name="quick_settings_wifi_label" msgid="9135344704899546041">"Wi-Fi"</string>
     <string name="quick_settings_wifi_not_connected" msgid="7171904845345573431">"Desconnectat"</string>
     <string name="quick_settings_wifi_no_network" msgid="2221993077220856376">"No hi ha cap xarxa"</string>
-    <string name="quick_settings_wifi_off_label" msgid="7558778100843885864">"Wi-Fi desconnectat"</string>
+    <string name="quick_settings_wifi_off_label" msgid="7558778100843885864">"Wi-Fi desconnectada"</string>
     <string name="quick_settings_wifi_display_label" msgid="6893592964463624333">"Pantalla Wi-Fi"</string>
     <string name="quick_settings_wifi_display_no_connection_label" msgid="7834964244709912066">"No hi ha cap connexió amb una pantalla Wi-Fi"</string>
     <string name="quick_settings_brightness_dialog_title" msgid="8599674057673605368">"Brillantor"</string>
diff --git a/packages/SystemUI/res/values-da/strings.xml b/packages/SystemUI/res/values-da/strings.xml
index fde9916..e2f0d44 100644
--- a/packages/SystemUI/res/values-da/strings.xml
+++ b/packages/SystemUI/res/values-da/strings.xml
@@ -168,17 +168,12 @@
     <string name="quick_settings_settings_label" msgid="5326556592578065401">"Indstillinger"</string>
     <string name="quick_settings_time_label" msgid="4635969182239736408">"Tid"</string>
     <string name="quick_settings_user_label" msgid="5238995632130897840">"Mig"</string>
-    <!-- no translation found for quick_settings_wifi_label (9135344704899546041) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_not_connected (7171904845345573431) -->
-    <skip />
+    <string name="quick_settings_wifi_label" msgid="9135344704899546041">"Wi-Fi"</string>
+    <string name="quick_settings_wifi_not_connected" msgid="7171904845345573431">"Ikke forbundet"</string>
     <string name="quick_settings_wifi_no_network" msgid="2221993077220856376">"Intet netværk"</string>
-    <!-- no translation found for quick_settings_wifi_off_label (7558778100843885864) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_label (6893592964463624333) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_no_connection_label (7834964244709912066) -->
-    <skip />
+    <string name="quick_settings_wifi_off_label" msgid="7558778100843885864">"Wi-Fi slået fra"</string>
+    <string name="quick_settings_wifi_display_label" msgid="6893592964463624333">"Wi-Fi Display"</string>
+    <string name="quick_settings_wifi_display_no_connection_label" msgid="7834964244709912066">"Ingen forbindelse til Wi-Fi Display"</string>
     <string name="quick_settings_brightness_dialog_title" msgid="8599674057673605368">"Lysstyrke"</string>
     <string name="quick_settings_brightness_dialog_auto_brightness_label" msgid="5064982743784071218">"AUTO"</string>
 </resources>
diff --git a/packages/SystemUI/res/values-et/strings.xml b/packages/SystemUI/res/values-et/strings.xml
index 8113e8d..ce1c578 100644
--- a/packages/SystemUI/res/values-et/strings.xml
+++ b/packages/SystemUI/res/values-et/strings.xml
@@ -172,8 +172,8 @@
     <string name="quick_settings_wifi_not_connected" msgid="7171904845345573431">"Ühendus puudub"</string>
     <string name="quick_settings_wifi_no_network" msgid="2221993077220856376">"Võrku pole"</string>
     <string name="quick_settings_wifi_off_label" msgid="7558778100843885864">"WiFi-ühendus on väljas"</string>
-    <string name="quick_settings_wifi_display_label" msgid="6893592964463624333">"WiFi kuva"</string>
-    <string name="quick_settings_wifi_display_no_connection_label" msgid="7834964244709912066">"WiFi-ühenduse puudumise kuva"</string>
+    <string name="quick_settings_wifi_display_label" msgid="6893592964463624333">"WiFi-ekraan"</string>
+    <string name="quick_settings_wifi_display_no_connection_label" msgid="7834964244709912066">"WiFi-ekraani ühendus puudub"</string>
     <string name="quick_settings_brightness_dialog_title" msgid="8599674057673605368">"Heledus"</string>
     <string name="quick_settings_brightness_dialog_auto_brightness_label" msgid="5064982743784071218">"AUTOMAATNE"</string>
 </resources>
diff --git a/packages/SystemUI/res/values-nb/strings.xml b/packages/SystemUI/res/values-nb/strings.xml
index bbf3aed..f74383e 100644
--- a/packages/SystemUI/res/values-nb/strings.xml
+++ b/packages/SystemUI/res/values-nb/strings.xml
@@ -168,17 +168,12 @@
     <string name="quick_settings_settings_label" msgid="5326556592578065401">"Innstillinger"</string>
     <string name="quick_settings_time_label" msgid="4635969182239736408">"Tidspunkt"</string>
     <string name="quick_settings_user_label" msgid="5238995632130897840">"Meg"</string>
-    <!-- no translation found for quick_settings_wifi_label (9135344704899546041) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_not_connected (7171904845345573431) -->
-    <skip />
+    <string name="quick_settings_wifi_label" msgid="9135344704899546041">"Wi-Fi"</string>
+    <string name="quick_settings_wifi_not_connected" msgid="7171904845345573431">"Ikke tilkoblet"</string>
     <string name="quick_settings_wifi_no_network" msgid="2221993077220856376">"Ingen nettverk"</string>
-    <!-- no translation found for quick_settings_wifi_off_label (7558778100843885864) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_label (6893592964463624333) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_no_connection_label (7834964244709912066) -->
-    <skip />
+    <string name="quick_settings_wifi_off_label" msgid="7558778100843885864">"Wi-Fi er av"</string>
+    <string name="quick_settings_wifi_display_label" msgid="6893592964463624333">"Wi-Fi-skjerm"</string>
+    <string name="quick_settings_wifi_display_no_connection_label" msgid="7834964244709912066">"Ingen tilkobling til Wi-Fi-skjermen"</string>
     <string name="quick_settings_brightness_dialog_title" msgid="8599674057673605368">"Lysstyrke"</string>
     <string name="quick_settings_brightness_dialog_auto_brightness_label" msgid="5064982743784071218">"AUTO"</string>
 </resources>
diff --git a/packages/SystemUI/res/values-pt/strings.xml b/packages/SystemUI/res/values-pt/strings.xml
index 377a617..8730f80 100644
--- a/packages/SystemUI/res/values-pt/strings.xml
+++ b/packages/SystemUI/res/values-pt/strings.xml
@@ -170,17 +170,12 @@
     <string name="quick_settings_settings_label" msgid="5326556592578065401">"Configurações"</string>
     <string name="quick_settings_time_label" msgid="4635969182239736408">"Hora"</string>
     <string name="quick_settings_user_label" msgid="5238995632130897840">"Eu"</string>
-    <!-- no translation found for quick_settings_wifi_label (9135344704899546041) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_not_connected (7171904845345573431) -->
-    <skip />
+    <string name="quick_settings_wifi_label" msgid="9135344704899546041">"Wi-Fi"</string>
+    <string name="quick_settings_wifi_not_connected" msgid="7171904845345573431">"Não conectado"</string>
     <string name="quick_settings_wifi_no_network" msgid="2221993077220856376">"Sem rede"</string>
-    <!-- no translation found for quick_settings_wifi_off_label (7558778100843885864) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_label (6893592964463624333) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_no_connection_label (7834964244709912066) -->
-    <skip />
+    <string name="quick_settings_wifi_off_label" msgid="7558778100843885864">"Wi-Fi desligado"</string>
+    <string name="quick_settings_wifi_display_label" msgid="6893592964463624333">"Wi-Fi Display"</string>
+    <string name="quick_settings_wifi_display_no_connection_label" msgid="7834964244709912066">"Sem conexão Wi-Fi Display"</string>
     <string name="quick_settings_brightness_dialog_title" msgid="8599674057673605368">"Brilho"</string>
     <string name="quick_settings_brightness_dialog_auto_brightness_label" msgid="5064982743784071218">"AUTO"</string>
 </resources>
diff --git a/packages/SystemUI/res/values-ru/strings.xml b/packages/SystemUI/res/values-ru/strings.xml
index 69ac9bc..a117897 100644
--- a/packages/SystemUI/res/values-ru/strings.xml
+++ b/packages/SystemUI/res/values-ru/strings.xml
@@ -170,17 +170,12 @@
     <string name="quick_settings_settings_label" msgid="5326556592578065401">"Настройки"</string>
     <string name="quick_settings_time_label" msgid="4635969182239736408">"Время"</string>
     <string name="quick_settings_user_label" msgid="5238995632130897840">"Пользователь"</string>
-    <!-- no translation found for quick_settings_wifi_label (9135344704899546041) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_not_connected (7171904845345573431) -->
-    <skip />
+    <string name="quick_settings_wifi_label" msgid="9135344704899546041">"Wi-Fi"</string>
+    <string name="quick_settings_wifi_not_connected" msgid="7171904845345573431">"Нет соединения"</string>
     <string name="quick_settings_wifi_no_network" msgid="2221993077220856376">"Нет сети"</string>
-    <!-- no translation found for quick_settings_wifi_off_label (7558778100843885864) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_label (6893592964463624333) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_no_connection_label (7834964244709912066) -->
-    <skip />
+    <string name="quick_settings_wifi_off_label" msgid="7558778100843885864">"Модуль Wi-Fi отключен"</string>
+    <string name="quick_settings_wifi_display_label" msgid="6893592964463624333">"Экран, подключенный через Wi-Fi"</string>
+    <string name="quick_settings_wifi_display_no_connection_label" msgid="7834964244709912066">"Экран не подключен через Wi-Fi"</string>
     <string name="quick_settings_brightness_dialog_title" msgid="8599674057673605368">"Яркость"</string>
     <string name="quick_settings_brightness_dialog_auto_brightness_label" msgid="5064982743784071218">"АВТОНАСТРОЙКА"</string>
 </resources>
diff --git a/packages/SystemUI/res/values-sv/strings.xml b/packages/SystemUI/res/values-sv/strings.xml
index 8d7e8c4..728d61f 100644
--- a/packages/SystemUI/res/values-sv/strings.xml
+++ b/packages/SystemUI/res/values-sv/strings.xml
@@ -168,17 +168,12 @@
     <string name="quick_settings_settings_label" msgid="5326556592578065401">"Inställningar"</string>
     <string name="quick_settings_time_label" msgid="4635969182239736408">"Tid"</string>
     <string name="quick_settings_user_label" msgid="5238995632130897840">"Jag"</string>
-    <!-- no translation found for quick_settings_wifi_label (9135344704899546041) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_not_connected (7171904845345573431) -->
-    <skip />
+    <string name="quick_settings_wifi_label" msgid="9135344704899546041">"Wi-Fi"</string>
+    <string name="quick_settings_wifi_not_connected" msgid="7171904845345573431">"Ej ansluten"</string>
     <string name="quick_settings_wifi_no_network" msgid="2221993077220856376">"Inget nätverk"</string>
-    <!-- no translation found for quick_settings_wifi_off_label (7558778100843885864) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_label (6893592964463624333) -->
-    <skip />
-    <!-- no translation found for quick_settings_wifi_display_no_connection_label (7834964244709912066) -->
-    <skip />
+    <string name="quick_settings_wifi_off_label" msgid="7558778100843885864">"Wi-Fi är inaktiverat"</string>
+    <string name="quick_settings_wifi_display_label" msgid="6893592964463624333">"Wi-Fi visas"</string>
+    <string name="quick_settings_wifi_display_no_connection_label" msgid="7834964244709912066">"Ingen Wi-Fi-anslutning visas"</string>
     <string name="quick_settings_brightness_dialog_title" msgid="8599674057673605368">"Ljusstyrka"</string>
     <string name="quick_settings_brightness_dialog_auto_brightness_label" msgid="5064982743784071218">"AUTO"</string>
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index 0671e44..a98c4dc 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -261,6 +261,19 @@
             }
         }
 
+        @Override
+        public void onSurfaceRedrawNeeded(SurfaceHolder holder) {
+            if (DEBUG) {
+                Log.d(TAG, "onSurfaceRedrawNeeded:");
+            }
+            super.onSurfaceRedrawNeeded(holder);
+
+            synchronized (mLock) {
+                mRedrawNeeded = true;
+                drawFrameLocked();
+            }
+        }
+
         void drawFrameLocked() {
             if (!mVisible) {
                 if (DEBUG) {
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 3fea0a0..12e749d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1376,12 +1376,34 @@
 
     private void setStatusBarLowProfile(boolean lightsOut) {
         if (mLightsOutAnimation == null) {
-            mLightsOutAnimation = ObjectAnimator.ofFloat(mStatusBarContents, View.ALPHA, 0);
-            mLightsOutAnimation.setDuration(750);
+            final View notifications = mStatusBarView.findViewById(R.id.notification_icon_area);
+            final View systemIcons = mStatusBarView.findViewById(R.id.statusIcons);
+            final View signal = mStatusBarView.findViewById(R.id.signal_cluster);
+            final View battery = mStatusBarView.findViewById(R.id.battery);
+            final View clock = mStatusBarView.findViewById(R.id.clock);
 
-            mLightsOnAnimation = new AnimatorSet();
-            mLightsOnAnimation = ObjectAnimator.ofFloat(mStatusBarContents, View.ALPHA, 1);
-            mLightsOnAnimation.setDuration(250);
+            final AnimatorSet lightsOutAnim = new AnimatorSet();
+            lightsOutAnim.playTogether(
+                    ObjectAnimator.ofFloat(notifications, View.ALPHA, 0),
+                    ObjectAnimator.ofFloat(systemIcons, View.ALPHA, 0),
+                    ObjectAnimator.ofFloat(signal, View.ALPHA, 0),
+                    ObjectAnimator.ofFloat(battery, View.ALPHA, 0.5f),
+                    ObjectAnimator.ofFloat(clock, View.ALPHA, 0.5f)
+                );
+            lightsOutAnim.setDuration(750);
+
+            final AnimatorSet lightsOnAnim = new AnimatorSet();
+            lightsOnAnim.playTogether(
+                    ObjectAnimator.ofFloat(notifications, View.ALPHA, 1),
+                    ObjectAnimator.ofFloat(systemIcons, View.ALPHA, 1),
+                    ObjectAnimator.ofFloat(signal, View.ALPHA, 1),
+                    ObjectAnimator.ofFloat(battery, View.ALPHA, 1),
+                    ObjectAnimator.ofFloat(clock, View.ALPHA, 1)
+                );
+            lightsOnAnim.setDuration(250);
+
+            mLightsOutAnimation = lightsOutAnim;
+            mLightsOnAnimation = lightsOnAnim;
         }
 
         mLightsOutAnimation.cancel();
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 f3c2df1..d63d517 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -71,6 +71,7 @@
  *
  */
 class QuickSettings {
+    public static final boolean SHOW_IME_TILE = false;
 
     private Context mContext;
     private PanelBar mBar;
@@ -274,12 +275,7 @@
         timeTile.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                // TODO: Jump into the clock application
-                Intent intent = new Intent();
-                intent.setComponent(new ComponentName(
-                        "com.google.android.deskclock",
-                        "com.android.deskclock.DeskClock"));
-                startSettingsActivity(intent);
+                startSettingsActivity(android.provider.Settings.ACTION_DATE_SETTINGS);
             }
         });
         mModel.addTimeTile(timeTile, new QuickSettingsModel.RefreshCallback() {
@@ -566,32 +562,34 @@
         });
         parent.addView(wifiDisplayTile);
 
-        // IME
-        QuickSettingsTileView imeTile = (QuickSettingsTileView)
-                inflater.inflate(R.layout.quick_settings_tile, parent, false);
-        imeTile.setContent(R.layout.quick_settings_tile_ime, inflater);
-        imeTile.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                try {
-                    mBar.collapseAllPanels(true);
-                    Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
-                    PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
-                    pendingIntent.send();
-                } catch (Exception e) {}
-            }
-        });
-        mModel.addImeTile(imeTile, new QuickSettingsModel.RefreshCallback() {
-            @Override
-            public void refreshView(QuickSettingsTileView view, State state) {
-                TextView tv = (TextView) view.findViewById(R.id.ime_textview);
-                if (state.label != null) {
-                    tv.setText(state.label);
+        if (SHOW_IME_TILE) {
+            // IME
+            QuickSettingsTileView imeTile = (QuickSettingsTileView)
+                    inflater.inflate(R.layout.quick_settings_tile, parent, false);
+            imeTile.setContent(R.layout.quick_settings_tile_ime, inflater);
+            imeTile.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    try {
+                        mBar.collapseAllPanels(true);
+                        Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
+                        PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
+                        pendingIntent.send();
+                    } catch (Exception e) {}
                 }
-                view.setVisibility(state.enabled ? View.VISIBLE : View.GONE);
-            }
-        });
-        parent.addView(imeTile);
+            });
+            mModel.addImeTile(imeTile, new QuickSettingsModel.RefreshCallback() {
+                @Override
+                public void refreshView(QuickSettingsTileView view, State state) {
+                    TextView tv = (TextView) view.findViewById(R.id.ime_textview);
+                    if (state.label != null) {
+                        tv.setText(state.label);
+                    }
+                    view.setVisibility(state.enabled ? View.VISIBLE : View.GONE);
+                }
+            });
+            parent.addView(imeTile);
+        }
 
         // Bug reports
         QuickSettingsTileView bugreportTile = (QuickSettingsTileView)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
index 5adfeb1..6b9a321 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
@@ -184,7 +184,7 @@
     private State mLocationState = new State();
 
     private QuickSettingsTileView mImeTile;
-    private RefreshCallback mImeCallback;
+    private RefreshCallback mImeCallback = null;
     private State mImeState = new State();
 
     private QuickSettingsTileView mRotationLockTile;
@@ -551,7 +551,9 @@
         mImeState.enabled = (visible && needsToShowImeSwitchOngoingNotification(imm));
         mImeState.label = getCurrentInputMethodName(mContext, mContext.getContentResolver(),
                 imm, imis, mContext.getPackageManager());
-        mImeCallback.refreshView(mImeTile, mImeState);
+        if (mImeCallback != null) {
+            mImeCallback.refreshView(mImeTile, mImeState);
+        }
     }
     private static String getCurrentInputMethodName(Context context, ContentResolver resolver,
             InputMethodManager imm, List<InputMethodInfo> imis, PackageManager pm) {
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index c3bd988..76eec71 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -775,7 +775,7 @@
         if (keyguardShowing) {
             // since it took two seconds of long press to bring this up,
             // poke the wake lock so they have some time to see the dialog.
-            mKeyguardMediator.pokeWakelock();
+            mKeyguardMediator.userActivity();
         }
     }
 
@@ -1140,6 +1140,11 @@
                     | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                     | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                     | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
+            if (ActivityManager.isHighEndGfx()) {
+                lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
+                lp.privateFlags |=
+                        WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
+            }
             lp.format = PixelFormat.TRANSLUCENT;
             lp.setTitle("PointerLocation");
             WindowManager wm = (WindowManager)
@@ -4298,6 +4303,13 @@
         if (mKeyguardMediator != null) {
             mKeyguardMediator.setCurrentUser(newUserId);
         }
+        if (mStatusBarService != null) {
+            try {
+                mStatusBarService.setCurrentUser(newUserId);
+            } catch (RemoteException e) {
+                // oh well
+            }
+        }
     }
 
     @Override
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 14633c4..4d56700 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -234,7 +234,7 @@
 
         public void userActivity(long timeout) {
             if (mViewMediatorCallback != null) {
-                mViewMediatorCallback.pokeWakelock(timeout);
+                mViewMediatorCallback.userActivity(timeout);
             }
         }
 
@@ -638,7 +638,7 @@
             if (DEBUG) Log.d(TAG, "poking wake lock immediately");
         }
         if (mViewMediatorCallback != null) {
-            mViewMediatorCallback.pokeWakelock();
+            mViewMediatorCallback.wakeUp();
         }
     }
 
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
index 8714276..1977b529 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
@@ -76,6 +76,7 @@
 
                 case com.android.internal.R.drawable.ic_lockscreen_unlock_phantom:
                 case com.android.internal.R.drawable.ic_lockscreen_unlock:
+                    mCallback.userActivity(0);
                     mCallback.dismiss(false);
                 break;
             }
@@ -86,6 +87,7 @@
         }
 
         public void onGrabbed(View v, int handle) {
+            mCallback.userActivity(0);
             doTransition(mFadeView, 0.0f);
         }
 
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 1abcc10..a3a9c5f 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -155,6 +155,8 @@
                         WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
             }
             lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY;
+            lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
+            lp.userActivityTimeout = KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS;
             lp.setTitle(isActivity ? "KeyguardMock" : "Keyguard");
             mWindowLayoutParams = lp;
             mViewManager.addView(mKeyguardHost, lp);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
index 212a6bb..2c415db 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
@@ -104,7 +104,6 @@
         "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD";
 
     // used for handler messages
-    private static final int TIMEOUT = 1;
     private static final int SHOW = 2;
     private static final int HIDE = 3;
     private static final int RESET = 4;
@@ -167,12 +166,6 @@
     private UserManager mUserManager;
 
     /**
-     * Used to keep the device awake while the keyguard is showing, i.e for
-     * calls to {@link #pokeWakelock()}
-     */
-    private PowerManager.WakeLock mWakeLock;
-
-    /**
      * Used to keep the device awake while to ensure the keyguard finishes opening before
      * we sleep.
      */
@@ -215,8 +208,6 @@
      */
     private int mDelayedShowingSequence;
 
-    private int mWakelockSequence;
-
     /**
      * If the user has disabled the keyguard, then requests to exit, this is
      * how we'll ultimately let them know whether it was successful.  We use this
@@ -262,15 +253,16 @@
     public interface ViewMediatorCallback {
 
         /**
-         * Request the wakelock to be poked for the default amount of time.
+         * Wake the device immediately.
          */
-        void pokeWakelock();
+        void wakeUp();
 
         /**
-         * Request the wakelock to be poked for a specific amount of time.
+         * Reports user activity and requests that the screen stay on for the specified
+         * amount of time.
          * @param millis The amount of time in millis.
          */
-        void pokeWakelock(long millis);
+        void userActivity(long millis);
 
         /**
          * Report that the keyguard is done.
@@ -402,12 +394,12 @@
     };
 
     ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
-        public void pokeWakelock() {
-            KeyguardViewMediator.this.pokeWakelock();
+        public void wakeUp() {
+            KeyguardViewMediator.this.wakeUp();
         }
 
-        public void pokeWakelock(long holdMs) {
-            KeyguardViewMediator.this.pokeWakelock(holdMs);
+        public void userActivity(long holdMs) {
+            KeyguardViewMediator.this.userActivity(holdMs);
         }
 
         public void keyguardDone(boolean authenticated) {
@@ -424,19 +416,18 @@
         }
     };
 
-    public void pokeWakelock() {
-        pokeWakelock(AWAKE_INTERVAL_DEFAULT_MS);
+    public void wakeUp() {
+        mPM.wakeUp(SystemClock.uptimeMillis());
     }
 
-    public void pokeWakelock(long holdMs) {
-        synchronized (this) {
-            if (DBG_WAKE) Log.d(TAG, "pokeWakelock(" + holdMs + ")");
-            mWakeLock.acquire();
-            mHandler.removeMessages(TIMEOUT);
-            mWakelockSequence++;
-            Message msg = mHandler.obtainMessage(TIMEOUT, mWakelockSequence, 0);
-            mHandler.sendMessageDelayed(msg, holdMs);
-        }
+    public void userActivity() {
+        userActivity(AWAKE_INTERVAL_DEFAULT_MS);
+    }
+
+    public void userActivity(long holdMs) {
+        // We ignore the hold time.  Eventually we should remove it.
+        // Instead, the keyguard window has an explicit user activity timeout set on it.
+        mPM.userActivity(SystemClock.uptimeMillis(), false);
     }
 
     /**
@@ -448,9 +439,6 @@
         mContext = context;
         mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
         mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        mWakeLock = mPM.newWakeLock(
-                PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
-        mWakeLock.setReferenceCounted(false);
         mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
         mShowKeyguardWakeLock.setReferenceCounted(false);
 
@@ -737,7 +725,6 @@
             if (mHidden != isHidden) {
                 mHidden = isHidden;
                 updateActivityLockScreenState();
-                adjustUserActivityLocked();
                 adjustStatusBarLocked();
             }
         }
@@ -1050,9 +1037,6 @@
         @Override
         public void handleMessage(Message msg) {
             switch (msg.what) {
-                case TIMEOUT:
-                    handleTimeout(msg.arg1);
-                    return ;
                 case SHOW:
                     handleShow();
                     return ;
@@ -1103,9 +1087,8 @@
         if (DEBUG) Log.d(TAG, "handleKeyguardDone");
         handleHide();
         if (wakeup) {
-            mPM.wakeUp(SystemClock.uptimeMillis());
+            wakeUp();
         }
-        mWakeLock.release();
 
         sendUserPresentBroadcast();
     }
@@ -1137,21 +1120,6 @@
         }
     }
 
-    /**
-     * Handles the message sent by {@link #pokeWakelock}
-     * @param seq used to determine if anything has changed since the message
-     *   was sent.
-     * @see #TIMEOUT
-     */
-    private void handleTimeout(int seq) {
-        synchronized (KeyguardViewMediator.this) {
-            if (DEBUG) Log.d(TAG, "handleTimeout");
-            if (seq == mWakelockSequence) {
-                mWakeLock.release();
-            }
-        }
-    }
-
     private void playSounds(boolean locked) {
         // User feedback for keyguard.
 
@@ -1200,8 +1168,8 @@
             mKeyguardViewManager.show();
             mShowing = true;
             updateActivityLockScreenState();
-            adjustUserActivityLocked();
             adjustStatusBarLocked();
+            userActivity();
             try {
                 ActivityManagerNative.getDefault().closeSystemDialogs("lock");
             } catch (RemoteException e) {
@@ -1235,23 +1203,10 @@
             mKeyguardViewManager.hide();
             mShowing = false;
             updateActivityLockScreenState();
-            adjustUserActivityLocked();
             adjustStatusBarLocked();
         }
     }
 
-    private void adjustUserActivityLocked() {
-        // disable user activity if we are shown and not hidden
-        if (DEBUG) Log.d(TAG, "adjustUserActivityLocked mShowing: " + mShowing + " mHidden: " + mHidden);
-        boolean enabled = !mShowing || mHidden;
-        // FIXME: Replace this with a new timeout control mechanism.
-        //mRealPowerManager.enableUserActivity(enabled);
-        if (!enabled && mScreenOn) {
-            // reinstate our short screen timeout policy
-            pokeWakelock();
-        }
-    }
-
     private void adjustStatusBarLocked() {
         if (mStatusBarManager == null) {
             mStatusBarManager = (StatusBarManager)
@@ -1320,7 +1275,7 @@
             if (!mKeyguardViewManager.wakeWhenReadyTq(keyCode)) {
                 // poke wakelock ourselves if keyguard is no longer active
                 Log.w(TAG, "mKeyguardViewManager.wakeWhenReadyTq did not poke wake lock, so poke it ourselves");
-                pokeWakelock();
+                userActivity();
             }
 
             /**
@@ -1328,10 +1283,6 @@
              * release the handoff wakelock
              */
             mWakeAndHandOff.release();
-
-            if (!mWakeLock.isHeld()) {
-                Log.w(TAG, "mWakeLock not held in mKeyguardViewManager.wakeWhenReadyTq");
-            }
         }
     }
 
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index be0cec9..7862e17 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -1716,6 +1716,16 @@
 }
 
 void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
+    if (mFocusedWindowHandle != NULL) {
+        const InputWindowInfo* info = mFocusedWindowHandle->getInfo();
+        if (info->inputFeatures & InputWindowInfo::INPUT_FEATURE_DISABLE_USER_ACTIVITY) {
+#if DEBUG_DISPATCH_CYCLE
+            ALOGD("Not poking user activity: disabled by window '%s'.", info->name.string());
+#endif
+            return;
+        }
+    }
+
     int32_t eventType = USER_ACTIVITY_EVENT_OTHER;
     switch (eventEntry->type) {
     case EventEntry::TYPE_MOTION: {
diff --git a/services/input/InputWindow.h b/services/input/InputWindow.h
index 3118099..7bd3af7 100644
--- a/services/input/InputWindow.h
+++ b/services/input/InputWindow.h
@@ -110,6 +110,8 @@
 
     enum {
         INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES = 0x00000001,
+        INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002,
+        INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004,
     };
 
     sp<InputChannel> inputChannel;
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index ec58e43..f06bf8e 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -900,14 +900,28 @@
             Slog.d(TAG, "--- calledFromForegroundUserOrSystemProcess ? "
                     + "calling uid = " + uid + " system uid = " + Process.SYSTEM_UID
                     + " calling userId = " + userId + ", foreground user id = "
-                    + mSettings.getCurrentUserId());
+                    + mSettings.getCurrentUserId() + ", calling uid = " + Binder.getCallingPid());
         }
         if (uid == Process.SYSTEM_UID || userId == mSettings.getCurrentUserId()) {
             return true;
-        } else {
-            Slog.w(TAG, "--- IPC called from background users. Ignore. \n" + getStackTrace());
-            return false;
         }
+
+        // Caveat: A process which has INTERACT_ACROSS_USERS_FULL gets results for the
+        // foreground user, not for the user of that process. Accordingly InputMethodManagerService
+        // must not manage background users' states in any functions.
+        // Note that privacy-sensitive IPCs, such as setInputMethod, are still securely guarded
+        // by a token.
+        if (mContext.checkCallingOrSelfPermission(
+                android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
+                        == PackageManager.PERMISSION_GRANTED) {
+            if (DEBUG) {
+                Slog.d(TAG, "--- Access granted because the calling process has "
+                        + "the INTERACT_ACROSS_USERS_FULL permission");
+            }
+            return true;
+        }
+        Slog.w(TAG, "--- IPC called from background users. Ignore. \n" + getStackTrace());
+        return false;
     }
 
     private boolean bindCurrentInputMethodService(
@@ -1475,9 +1489,6 @@
                     final CharSequence title = mRes.getText(
                             com.android.internal.R.string.select_input_method);
                     final CharSequence imiLabel = imi.loadLabel(pm);
-                    if (DEBUG) {
-                        Slog.d(TAG, "--- imiLabel = " + imiLabel);
-                    }
                     final CharSequence summary = mCurrentSubtype != null
                             ? TextUtils.concat(mCurrentSubtype.getDisplayName(mContext,
                                         imi.getPackageName(), imi.getServiceInfo().applicationInfo),
@@ -1488,15 +1499,22 @@
                     mImeSwitcherNotification.setLatestEventInfo(
                             mContext, title, summary, mImeSwitchPendingIntent);
                     if (mNotificationManager != null) {
-                        mNotificationManager.notify(
+                        if (DEBUG) {
+                            Slog.d(TAG, "--- show notification: label =  " + imiLabel
+                                    + ", summary = " + summary);
+                        }
+                        mNotificationManager.notifyAsUser(null,
                                 com.android.internal.R.string.select_input_method,
-                                mImeSwitcherNotification);
+                                mImeSwitcherNotification, UserHandle.ALL);
                         mNotificationShown = true;
                     }
                 } else {
                     if (mNotificationShown && mNotificationManager != null) {
-                        mNotificationManager.cancel(
-                                com.android.internal.R.string.select_input_method);
+                        if (DEBUG) {
+                            Slog.d(TAG, "--- hide notification");
+                        }
+                        mNotificationManager.cancelAsUser(null,
+                                com.android.internal.R.string.select_input_method, UserHandle.ALL);
                         mNotificationShown = false;
                     }
                 }
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index a0c1552..a1bd3c5 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -228,6 +228,12 @@
     }
 
     private void loadProvidersLocked() {
+        // create a passive location provider, which is always enabled
+        PassiveProvider passiveProvider = new PassiveProvider(this);
+        addProviderLocked(passiveProvider);
+        mEnabledProviders.add(passiveProvider.getName());
+        mPassiveProvider = passiveProvider;
+
         if (GpsLocationProvider.isSupported()) {
             // Create a gps location provider
             GpsLocationProvider gpsProvider = new GpsLocationProvider(mContext, this);
@@ -237,12 +243,6 @@
             mRealProviders.put(LocationManager.GPS_PROVIDER, gpsProvider);
         }
 
-        // create a passive location provider, which is always enabled
-        PassiveProvider passiveProvider = new PassiveProvider(this);
-        addProviderLocked(passiveProvider);
-        mEnabledProviders.add(passiveProvider.getName());
-        mPassiveProvider = passiveProvider;
-
         /*
         Load package name(s) containing location provider support.
         These packages can contain services implementing location providers:
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 0312705..c512bc1 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -1577,9 +1577,16 @@
 
     private void warnOnNotMounted() {
         final StorageVolume primary = getPrimaryPhysicalVolume();
-        if (primary != null
-                && Environment.MEDIA_MOUNTED.equals(getVolumeState(primary.getPath()))) {
-            Slog.w(TAG, "getSecureContainerList() called when storage not mounted");
+        if (primary != null) {
+            boolean mounted = false;
+            try {
+                mounted = Environment.MEDIA_MOUNTED.equals(getVolumeState(primary.getPath()));
+            } catch (IllegalStateException e) {
+            }
+
+            if (!mounted) {
+                Slog.w(TAG, "getSecureContainerList() called when storage not mounted");
+            }
         }
     }
 
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 87b0eb3..5d9441b 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -64,7 +64,7 @@
             = new HashMap<IBinder,StatusBarNotification>();
 
     // for disabling the status bar
-    ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
+    final ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
     IBinder mSysUiVisToken = new Binder();
     int mDisabled = 0;
 
@@ -75,15 +75,17 @@
     int mImeWindowVis = 0;
     int mImeBackDisposition;
     IBinder mImeToken = null;
+    int mCurrentUserId;
 
     private class DisableRecord implements IBinder.DeathRecipient {
+        int userId;
         String pkg;
         int what;
         IBinder token;
 
         public void binderDied() {
             Slog.i(TAG, "binder died for pkg=" + pkg);
-            disable(0, token, pkg);
+            disableInternal(userId, 0, token, pkg);
             token.unlinkToDeath(this, 0);
         }
     }
@@ -151,20 +153,24 @@
     }
 
     public void disable(int what, IBinder token, String pkg) {
+        disableInternal(mCurrentUserId, what, token, pkg);
+    }
+
+    private void disableInternal(int userId, int what, IBinder token, String pkg) {
         enforceStatusBar();
 
         synchronized (mLock) {
-            disableLocked(what, token, pkg);
+            disableLocked(userId, what, token, pkg);
         }
     }
 
-    private void disableLocked(int what, IBinder token, String pkg) {
+    private void disableLocked(int userId, int what, IBinder token, String pkg) {
         // It's important that the the callback and the call to mBar get done
         // in the same order when multiple threads are calling this function
         // so they are paired correctly.  The messages on the handler will be
         // handled in the order they were enqueued, but will be outside the lock.
-        manageDisableListLocked(what, token, pkg);
-        final int net = gatherDisableActionsLocked();
+        manageDisableListLocked(userId, what, token, pkg);
+        final int net = gatherDisableActionsLocked(userId);
         if (net != mDisabled) {
             mDisabled = net;
             mHandler.post(new Runnable() {
@@ -312,7 +318,10 @@
 
         synchronized (mLock) {
             updateUiVisibilityLocked(vis, mask);
-            disableLocked(vis & StatusBarManager.DISABLE_MASK, mSysUiVisToken,
+            disableLocked(
+                    mCurrentUserId,
+                    vis & StatusBarManager.DISABLE_MASK,
+                    mSysUiVisToken,
                     "WindowManager.LayoutParams");
         }
     }
@@ -382,6 +391,12 @@
         }
     }
 
+    @Override
+    public void setCurrentUser(int newUserId) {
+        if (SPEW) Slog.d(TAG, "Setting current user to user " + newUserId);
+        mCurrentUserId = newUserId;
+    }
+
     private void enforceStatusBar() {
         mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
                 "StatusBarManagerService");
@@ -417,7 +432,7 @@
             }
         }
         synchronized (mLock) {
-            switches[0] = gatherDisableActionsLocked();
+            switches[0] = gatherDisableActionsLocked(mCurrentUserId);
             switches[1] = mSystemUiVisibility;
             switches[2] = mMenuVisible ? 1 : 0;
             switches[3] = mImeWindowVis;
@@ -518,9 +533,10 @@
     // ================================================================================
 
     // lock on mDisableRecords
-    void manageDisableListLocked(int what, IBinder token, String pkg) {
+    void manageDisableListLocked(int userId, int what, IBinder token, String pkg) {
         if (SPEW) {
-            Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
+            Slog.d(TAG, "manageDisableList userId=" + userId
+                    + " what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
         }
         // update the list
         final int N = mDisableRecords.size();
@@ -541,6 +557,7 @@
         } else {
             if (tok == null) {
                 tok = new DisableRecord();
+                tok.userId = userId;
                 try {
                     token.linkToDeath(tok, 0);
                 }
@@ -556,12 +573,15 @@
     }
 
     // lock on mDisableRecords
-    int gatherDisableActionsLocked() {
+    int gatherDisableActionsLocked(int userId) {
         final int N = mDisableRecords.size();
         // gather the new net flags
         int net = 0;
         for (int i=0; i<N; i++) {
-            net |= mDisableRecords.get(i).what;
+            final DisableRecord rec = mDisableRecords.get(i);
+            if (rec.userId == userId) {
+                net |= rec.what;
+            }
         }
         return net;
     }
@@ -593,13 +613,15 @@
         }
 
         synchronized (mLock) {
+            pw.println("  mDisabled=0x" + Integer.toHexString(mDisabled));
             final int N = mDisableRecords.size();
-            pw.println("  mDisableRecords.size=" + N
-                    + " mDisabled=0x" + Integer.toHexString(mDisabled));
+            pw.println("  mDisableRecords.size=" + N);
             for (int i=0; i<N; i++) {
                 DisableRecord tok = mDisableRecords.get(i);
-                pw.println("    [" + i + "] what=0x" + Integer.toHexString(tok.what)
-                                + " pkg=" + tok.pkg + " token=" + tok.token);
+                pw.println("    [" + i + "] userId=" + tok.userId
+                                + " what=0x" + Integer.toHexString(tok.what)
+                                + " pkg=" + tok.pkg
+                                + " token=" + tok.token);
             }
         }
     }
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index adb63f9..98794c9 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -21,6 +21,7 @@
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
+import android.app.TaskStackBuilder;
 import android.bluetooth.BluetoothAdapter;
 import android.content.BroadcastReceiver;
 import android.content.ContentResolver;
@@ -1766,9 +1767,10 @@
                 mNotification.when = 0;
                 mNotification.icon = ICON_NETWORKS_AVAILABLE;
                 mNotification.flags = Notification.FLAG_AUTO_CANCEL;
-                mNotification.contentIntent = PendingIntent.getActivityAsUser(mContext, 0,
-                        new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK), 0,
-                        null, UserHandle.CURRENT);
+                mNotification.contentIntent = TaskStackBuilder.create(mContext)
+                        .addNextIntentWithParentStack(
+                                new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK))
+                        .getPendingIntent(0, 0, null, UserHandle.CURRENT);
             }
 
             CharSequence title = mContext.getResources().getQuantityText(
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 3428326..35f1b59 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -11745,7 +11745,7 @@
             users = mStartedUserArray;
         } else {
             // Caller wants broadcast to go to one specific user.
-            users = mCurrentUserArray;
+            users = new int[] {userId};
         }
 
         // Figure out who all will receive this broadcast.
diff --git a/services/java/com/android/server/display/DisplayManagerService.java b/services/java/com/android/server/display/DisplayManagerService.java
index f348cb6..b8c6cd5 100644
--- a/services/java/com/android/server/display/DisplayManagerService.java
+++ b/services/java/com/android/server/display/DisplayManagerService.java
@@ -209,7 +209,7 @@
     public void setWindowManager(WindowManagerFuncs windowManagerFuncs) {
         synchronized (mSyncRoot) {
             mWindowManagerFuncs = windowManagerFuncs;
-            scheduleTraversalLocked();
+            scheduleTraversalLocked(false);
         }
     }
 
@@ -220,7 +220,7 @@
     public void setInputManager(InputManagerFuncs inputManagerFuncs) {
         synchronized (mSyncRoot) {
             mInputManagerFuncs = inputManagerFuncs;
-            scheduleTraversalLocked();
+            scheduleTraversalLocked(false);
         }
     }
 
@@ -264,7 +264,7 @@
                 display.setDisplayInfoOverrideFromWindowManagerLocked(info);
                 if (!mTempDisplayInfo.equals(display.getDisplayInfoLocked())) {
                     sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
-                    scheduleTraversalLocked();
+                    scheduleTraversalLocked(false);
                 }
             }
         }
@@ -527,7 +527,7 @@
 
             mDisplayDevices.add(device);
             addLogicalDisplayLocked(device);
-            scheduleTraversalLocked();
+            scheduleTraversalLocked(false);
         }
     }
 
@@ -543,7 +543,7 @@
 
             device.applyPendingDisplayDeviceInfoChangesLocked();
             if (updateLogicalDisplaysLocked()) {
-                scheduleTraversalLocked();
+                scheduleTraversalLocked(false);
             }
         }
     }
@@ -560,7 +560,7 @@
 
             mRemovedDisplayDevices.add(device);
             updateLogicalDisplaysLocked();
-            scheduleTraversalLocked();
+            scheduleTraversalLocked(false);
         }
     }
 
@@ -668,13 +668,15 @@
      *
      * @param displayId The logical display id to update.
      * @param hasContent True if the logical display has content.
+     * @param inTraversal True if called from WindowManagerService during a window traversal prior
+     * to call to performTraversalInTransactionFromWindowManager.
      */
-    public void setDisplayHasContent(int displayId, boolean hasContent) {
+    public void setDisplayHasContent(int displayId, boolean hasContent, boolean inTraversal) {
         synchronized (mSyncRoot) {
             LogicalDisplay display = mLogicalDisplays.get(displayId);
             if (display != null && display.hasContentLocked() != hasContent) {
                 display.setHasContentLocked(hasContent);
-                scheduleTraversalLocked();
+                scheduleTraversalLocked(inTraversal);
             }
         }
     }
@@ -741,10 +743,12 @@
 
     // Requests that performTraversalsInTransactionFromWindowManager be called at a
     // later time to apply changes to surfaces and displays.
-    private void scheduleTraversalLocked() {
+    private void scheduleTraversalLocked(boolean inTraversal) {
         if (!mPendingTraversal && mWindowManagerFuncs != null) {
             mPendingTraversal = true;
-            mHandler.sendEmptyMessage(MSG_REQUEST_TRAVERSAL);
+            if (!inTraversal) {
+                mHandler.sendEmptyMessage(MSG_REQUEST_TRAVERSAL);
+            }
         }
     }
 
@@ -911,7 +915,7 @@
         @Override
         public void onTraversalRequested() {
             synchronized (mSyncRoot) {
-                scheduleTraversalLocked();
+                scheduleTraversalLocked(false);
             }
         }
     }
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index 84adb83..a254d74 100755
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -40,10 +40,8 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
-import android.os.Looper;
 import android.os.Message;
 import android.os.PowerManager;
-import android.os.Process;
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.SystemClock;
@@ -75,7 +73,6 @@
 import java.util.Date;
 import java.util.Map.Entry;
 import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
 
 /**
  * A GPS implementation of LocationProvider used by LocationManager.
@@ -287,12 +284,8 @@
     private Bundle mLocationExtras = new Bundle();
     private ArrayList<Listener> mListeners = new ArrayList<Listener>();
 
-    // GpsLocationProvider's handler thread
-    private final Thread mThread;
-    // Handler for processing events in mThread.
+    // Handler for processing events
     private Handler mHandler;
-    // Used to signal when our main thread has initialized everything
-    private final CountDownLatch mInitializedLatch = new CountDownLatch(1);
 
     private String mAGpsApn;
     private int mAGpsDataConnectionState;
@@ -437,21 +430,6 @@
         mWakeupIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ALARM_WAKEUP), 0);
         mTimeoutIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ALARM_TIMEOUT), 0);
 
-        IntentFilter intentFilter = new IntentFilter();
-        intentFilter.addAction(Intents.DATA_SMS_RECEIVED_ACTION);
-        intentFilter.addDataScheme("sms");
-        intentFilter.addDataAuthority("localhost","7275");
-        context.registerReceiver(mBroadcastReciever, intentFilter);
-
-        intentFilter = new IntentFilter();
-        intentFilter.addAction(Intents.WAP_PUSH_RECEIVED_ACTION);
-        try {
-            intentFilter.addDataType("application/vnd.omaloc-supl-init");
-        } catch (IntentFilter.MalformedMimeTypeException e) {
-            Log.w(TAG, "Malformed SUPL init mime type");
-        }
-        context.registerReceiver(mBroadcastReciever, intentFilter);
-
         mConnMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
 
         // Battery statistics service to be notified when GPS turns on or off
@@ -487,26 +465,43 @@
             Log.w(TAG, "Could not open GPS configuration file " + PROPERTIES_FILE);
         }
 
-        // wait until we are fully initialized before returning
-        mThread = new GpsLocationProviderThread();
-        mThread.start();
-        while (true) {
-            try {
-                mInitializedLatch.await();
-                break;
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
+        // construct handler, listen for events
+        mHandler = new ProviderHandler();
+        listenForBroadcasts();
+
+        // also listen for PASSIVE_PROVIDER updates
+        mHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                LocationManager locManager =
+                        (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
+                locManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER,
+                        0, 0, new NetworkLocationListener(), mHandler.getLooper());                
             }
-        }
+        });
     }
 
-    private void initialize() {
-        // register our receiver on our thread rather than the main thread
+    private void listenForBroadcasts() {
         IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(Intents.DATA_SMS_RECEIVED_ACTION);
+        intentFilter.addDataScheme("sms");
+        intentFilter.addDataAuthority("localhost","7275");
+        mContext.registerReceiver(mBroadcastReciever, intentFilter, null, mHandler);
+
+        intentFilter = new IntentFilter();
+        intentFilter.addAction(Intents.WAP_PUSH_RECEIVED_ACTION);
+        try {
+            intentFilter.addDataType("application/vnd.omaloc-supl-init");
+        } catch (IntentFilter.MalformedMimeTypeException e) {
+            Log.w(TAG, "Malformed SUPL init mime type");
+        }
+        mContext.registerReceiver(mBroadcastReciever, intentFilter, null, mHandler);
+
+        intentFilter = new IntentFilter();
         intentFilter.addAction(ALARM_WAKEUP);
         intentFilter.addAction(ALARM_TIMEOUT);
         intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
-        mContext.registerReceiver(mBroadcastReciever, intentFilter);
+        mContext.registerReceiver(mBroadcastReciever, intentFilter, null, mHandler);
     }
 
     /**
@@ -1536,29 +1531,6 @@
         }
     };
 
-    private final class GpsLocationProviderThread extends Thread {
-
-        public GpsLocationProviderThread() {
-            super("GpsLocationProvider");
-        }
-
-        @Override
-        public void run() {
-            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
-            initialize();
-            Looper.prepare();
-
-            LocationManager locManager =
-                    (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
-            mHandler = new ProviderHandler();
-            // signal when we are initialized and ready to go
-            mInitializedLatch.countDown();
-            locManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER,
-                    0, 0, new NetworkLocationListener(), Looper.myLooper());
-            Looper.loop();
-        }
-    }
-
     private final class NetworkLocationListener implements LocationListener {
         @Override
         public void onLocationChanged(Location location) {
diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java
index ad85c0d..8b1e80f 100644
--- a/services/java/com/android/server/pm/Installer.java
+++ b/services/java/com/android/server/pm/Installer.java
@@ -254,10 +254,12 @@
         return execute(builder.toString());
     }
 
-    public int deleteCacheFiles(String name) {
+    public int deleteCacheFiles(String name, int userId) {
         StringBuilder builder = new StringBuilder("rmcache");
         builder.append(' ');
         builder.append(name);
+        builder.append(' ');
+        builder.append(userId);
         return execute(builder.toString());
     }
 
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index f096089..75bc265 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -8540,11 +8540,10 @@
             Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
             return false;
         }
-        // TODO: Pass userId to deleteCacheFiles
-        int retCode = mInstaller.deleteCacheFiles(packageName);
+        int retCode = mInstaller.deleteCacheFiles(packageName, userId);
         if (retCode < 0) {
             Slog.w(TAG, "Couldn't remove cache files for package: "
-                       + packageName);
+                       + packageName + " u" + userId);
             return false;
         }
         return true;
diff --git a/services/java/com/android/server/power/DisplayPowerController.java b/services/java/com/android/server/power/DisplayPowerController.java
index 5f4a786..4f8cdde 100644
--- a/services/java/com/android/server/power/DisplayPowerController.java
+++ b/services/java/com/android/server/power/DisplayPowerController.java
@@ -44,7 +44,6 @@
 import android.view.Display;
 
 import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.util.concurrent.Executor;
 
 /**
@@ -95,7 +94,8 @@
     // when it is especially dark outside.  The light sensor tends to perform
     // poorly at low light levels so we compensate for it by making an
     // assumption about the environment.
-    private static final boolean USE_TWILIGHT_ADJUSTMENT = true;
+    private static final boolean USE_TWILIGHT_ADJUSTMENT =
+            PowerManager.useTwilightAdjustmentFeature();
 
     // Specifies the maximum magnitude of the time of day adjustment.
     private static final float TWILIGHT_ADJUSTMENT_MAX_GAMMA = 1.5f;
diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java
index c2d47e5..ca86b7f 100644
--- a/services/java/com/android/server/power/PowerManagerService.java
+++ b/services/java/com/android/server/power/PowerManagerService.java
@@ -266,6 +266,11 @@
     // Use -1 to disable.
     private int mScreenBrightnessOverrideFromWindowManager = -1;
 
+    // The user activity timeout override from the window manager
+    // to allow the current foreground activity to override the user activity timeout.
+    // Use -1 to disable.
+    private long mUserActivityTimeoutOverrideFromWindowManager = -1;
+
     // The screen brightness setting override from the settings application
     // to temporarily adjust the brightness until next updated,
     // Use -1 to disable.
@@ -1156,6 +1161,9 @@
         if (isMaximumScreenOffTimeoutFromDeviceAdminEnforcedLocked()) {
             timeout = Math.min(timeout, mMaximumScreenOffTimeoutFromDeviceAdmin);
         }
+        if (mUserActivityTimeoutOverrideFromWindowManager >= 0) {
+            timeout = (int)Math.min(timeout, mUserActivityTimeoutOverrideFromWindowManager);
+        }
         return Math.max(timeout, MINIMUM_SCREEN_OFF_TIMEOUT);
     }
 
@@ -1573,18 +1581,6 @@
         }
     }
 
-    @Override // Binder call
-    public void clearUserActivityTimeout(long now, long timeout) {
-        // TODO Auto-generated method stub
-        // Only used by phone app, delete this
-    }
-
-    @Override // Binder call
-    public void setPokeLock(int pokey, IBinder lock, String tag) {
-        // TODO Auto-generated method stub
-        // Only used by phone app, delete this
-    }
-
     /**
      * Set the setting that determines whether the device stays on when plugged in.
      * The argument is a bit string, with each bit specifying a power source that,
@@ -1727,6 +1723,36 @@
     }
 
     /**
+     * Used by the window manager to override the user activity timeout based on the
+     * current foreground activity.  It can only be used to make the timeout shorter
+     * than usual, not longer.
+     *
+     * This method must only be called by the window manager.
+     *
+     * @param timeoutMillis The overridden timeout, or -1 to disable the override.
+     */
+    public void setUserActivityTimeoutOverrideFromWindowManager(long timeoutMillis) {
+        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
+
+        final long ident = Binder.clearCallingIdentity();
+        try {
+            setUserActivityTimeoutOverrideFromWindowManagerInternal(timeoutMillis);
+        } finally {
+            Binder.restoreCallingIdentity(ident);
+        }
+    }
+
+    private void setUserActivityTimeoutOverrideFromWindowManagerInternal(long timeoutMillis) {
+        synchronized (mLock) {
+            if (mUserActivityTimeoutOverrideFromWindowManager != timeoutMillis) {
+                mUserActivityTimeoutOverrideFromWindowManager = timeoutMillis;
+                mDirty |= DIRTY_SETTINGS;
+                updatePowerStateLocked();
+            }
+        }
+    }
+
+    /**
      * Used by the settings application and brightness control widgets to
      * temporarily override the current screen brightness setting so that the
      * user can observe the effect of an intended settings change without applying
@@ -1875,6 +1901,8 @@
             pw.println("  mScreenBrightnessModeSetting=" + mScreenBrightnessModeSetting);
             pw.println("  mScreenBrightnessOverrideFromWindowManager="
                     + mScreenBrightnessOverrideFromWindowManager);
+            pw.println("  mUserActivityTimeoutOverrideFromWindowManager="
+                    + mUserActivityTimeoutOverrideFromWindowManager);
             pw.println("  mTemporaryScreenBrightnessSettingOverride="
                     + mTemporaryScreenBrightnessSettingOverride);
             pw.println("  mTemporaryScreenAutoBrightnessAdjustmentSettingOverride="
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index b206d9b5..3f7b67b 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -18,19 +18,24 @@
 
 import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
 import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
+import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
 import static android.view.WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
 import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND;
 import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
 import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
-import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
 import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
 import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
 import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
+import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
 import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
+import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
 import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
+import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD;
+import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
+import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
 import static android.view.WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND;
 import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
 
@@ -593,7 +598,13 @@
         private boolean mSyswin = false;
         private float mScreenBrightness = -1;
         private float mButtonBrightness = -1;
+        private long mUserActivityTimeout = -1;
         private boolean mUpdateRotation = false;
+
+        private static final int DISPLAY_CONTENT_UNKNOWN = 0;
+        private static final int DISPLAY_CONTENT_MIRROR = 1;
+        private static final int DISPLAY_CONTENT_UNIQUE = 2;
+        private int mDisplayHasContent = DISPLAY_CONTENT_UNKNOWN;
     }
     final LayoutFields mInnerFields = new LayoutFields();
 
@@ -1118,10 +1129,6 @@
         if (win.mAppToken != null && addToToken) {
             win.mAppToken.allAppWindows.add(win);
         }
-
-        if (windows.size() == 1) {
-            mDisplayManagerService.setDisplayHasContent(win.getDisplayId(), true);
-        }
     }
 
     /** TODO(cmautner): Is this the same as {@link WindowState#canReceiveKeys()} */
@@ -1129,7 +1136,7 @@
         final int fl = w.mAttrs.flags
                 & (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM);
         if (fl == 0 || fl == (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)
-                || w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
+                || w.mAttrs.type == TYPE_APPLICATION_STARTING) {
             if (DEBUG_INPUT_METHOD) {
                 Slog.i(TAG, "isVisibleOrAdding " + w + ": " + w.isVisibleOrAdding());
                 if (!w.isVisibleOrAdding()) {
@@ -1177,7 +1184,7 @@
                 // is not actually looking to move the IME, look down below
                 // for a real window to target...
                 if (!willMove
-                        && w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
+                        && w.mAttrs.type == TYPE_APPLICATION_STARTING
                         && i > 0) {
                     WindowState wb = windows.get(i-1);
                     if (wb.mAppToken == w.mAppToken && canBeImeTarget(wb)) {
@@ -1576,7 +1583,7 @@
         while (i > 0) {
             i--;
             w = windows.get(i);
-            if ((w.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER)) {
+            if ((w.mAttrs.type == TYPE_WALLPAPER)) {
                 if (topCurW == null) {
                     topCurW = w;
                     topCurI = i;
@@ -2411,9 +2418,6 @@
 
         final WindowList windows = win.getWindowList();
         windows.remove(win);
-        if (windows.isEmpty()) {
-            mDisplayManagerService.setDisplayHasContent(win.getDisplayId(), false);
-        }
         mPendingRemove.remove(win);
         mWindowsChanged = true;
         if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Final remove of window: " + win);
@@ -2774,13 +2778,11 @@
                 win.mHScale = win.mVScale = 1;
             }
 
-            boolean imMayMove = (flagChanges&(
-                    WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
-                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)) != 0;
+            boolean imMayMove = (flagChanges & (FLAG_ALT_FOCUSABLE_IM | FLAG_NOT_FOCUSABLE)) != 0;
 
             final boolean isDefaultDisplay = win.isDefaultDisplay();
             boolean focusMayChange = isDefaultDisplay && (win.mViewVisibility != viewVisibility
-                    || ((flagChanges&WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) != 0)
+                    || ((flagChanges & FLAG_NOT_FOCUSABLE) != 0)
                     || (!win.mRelayoutCalled));
 
             boolean wallpaperMayMove = win.mViewVisibility != viewVisibility
@@ -3094,8 +3096,7 @@
             final int windowCount = windows.size();
             for (int i = 0; i < windowCount; i++) {
                 WindowState window = windows.get(i);
-                if (window.isVisibleLw() ||
-                        window.mAttrs.type == WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND) {
+                if (window.isVisibleLw() || window.mAttrs.type == TYPE_UNIVERSE_BACKGROUND) {
                     WindowInfo info = getWindowInfoForWindowStateLocked(window);
                     outInfos.add(info);
                 }
@@ -3149,8 +3150,7 @@
         info.type = window.mAttrs.type;
         info.displayId = window.getDisplayId();
         info.compatibilityScale = window.mGlobalScale;
-        info.visible = window.isVisibleLw()
-                || info.type == WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND;
+        info.visible = window.isVisibleLw() || info.type == TYPE_UNIVERSE_BACKGROUND;
         info.layer = window.mLayer;
         window.getTouchableRegion(mTempRegion);
         mTempRegion.getBounds(info.touchableRegion);
@@ -4375,7 +4375,7 @@
                         // an opaque window and our starting window transition animation
                         // can still work.  We just need to make sure the starting window
                         // is also showing the wallpaper.
-                        windowFlags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
+                        windowFlags |= FLAG_SHOW_WALLPAPER;
                     } else {
                         return;
                     }
@@ -5497,7 +5497,7 @@
                 final int N = windows.size();
                 for (int i=0; i<N; i++) {
                     WindowState w = windows.get(i);
-                    if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD) {
+                    if (w.mAttrs.type == TYPE_KEYGUARD) {
                         // Only if there is a keyguard attached to the window manager
                         // will we consider ourselves as having a keyguard.  If it
                         // isn't attached, we don't know if it wants to be shown or
@@ -5513,13 +5513,13 @@
                         return;
                     }
                     if (w.isDrawnLw()) {
-                        if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_BOOT_PROGRESS) {
+                        if (w.mAttrs.type == TYPE_BOOT_PROGRESS) {
                             haveBootMsg = true;
-                        } else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION) {
+                        } else if (w.mAttrs.type == TYPE_APPLICATION) {
                             haveApp = true;
-                        } else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER) {
+                        } else if (w.mAttrs.type == TYPE_WALLPAPER) {
                             haveWallpaper = true;
-                        } else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD) {
+                        } else if (w.mAttrs.type == TYPE_KEYGUARD) {
                             haveKeyguard = true;
                         }
                     }
@@ -5715,9 +5715,8 @@
             dw = displayInfo.logicalWidth;
             dh = displayInfo.logicalHeight;
 
-            int aboveAppLayer = mPolicy.windowTypeToLayerLw(
-                    WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER
-                    + TYPE_LAYER_OFFSET;
+            int aboveAppLayer = mPolicy.windowTypeToLayerLw(TYPE_APPLICATION)
+                    * TYPE_LAYER_MULTIPLIER + TYPE_LAYER_OFFSET;
             aboveAppLayer += TYPE_LAYER_MULTIPLIER;
 
             boolean isImeTarget = mInputMethodTarget != null
@@ -7994,8 +7993,7 @@
                 numRemoved++;
                 continue;
             } else if (lastBelow == i-1) {
-                if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER
-                        || w.mAttrs.type == WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND) {
+                if (w.mAttrs.type == TYPE_WALLPAPER || w.mAttrs.type == TYPE_UNIVERSE_BACKGROUND) {
                     lastBelow = i;
                 }
             }
@@ -8778,12 +8776,27 @@
                     && mInnerFields.mButtonBrightness < 0) {
                 mInnerFields.mButtonBrightness = w.mAttrs.buttonBrightness;
             }
+            if (!mInnerFields.mSyswin && w.mAttrs.userActivityTimeout >= 0
+                    && mInnerFields.mUserActivityTimeout < 0) {
+                mInnerFields.mUserActivityTimeout = w.mAttrs.userActivityTimeout;
+            }
+
+            final int type = attrs.type;
             if (canBeSeen
-                    && (attrs.type == WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG
-                     || attrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD
-                     || attrs.type == WindowManager.LayoutParams.TYPE_SYSTEM_ERROR)) {
+                    && (type == TYPE_SYSTEM_DIALOG
+                     || type == TYPE_KEYGUARD
+                     || type == TYPE_SYSTEM_ERROR)) {
                 mInnerFields.mSyswin = true;
             }
+
+            if (canBeSeen) {
+                if (type == TYPE_DREAM || type == TYPE_KEYGUARD) {
+                    mInnerFields.mDisplayHasContent = LayoutFields.DISPLAY_CONTENT_MIRROR;
+                } else if (mInnerFields.mDisplayHasContent
+                        == LayoutFields.DISPLAY_CONTENT_UNKNOWN) {
+                    mInnerFields.mDisplayHasContent = LayoutFields.DISPLAY_CONTENT_UNIQUE;
+                }
+            }
         }
 
         boolean opaqueDrawn = canBeSeen && w.isOpaqueDrawn();
@@ -8802,7 +8815,7 @@
                 final WindowStateAnimator winAnimator = w.mWinAnimator;
                 if (!mAnimator.isDimmingLocked(winAnimator)) {
                     final int width, height;
-                    if (attrs.type == WindowManager.LayoutParams.TYPE_BOOT_PROGRESS) {
+                    if (attrs.type == TYPE_BOOT_PROGRESS) {
                         final DisplayInfo displayInfo = w.mDisplayContent.getDisplayInfo();
                         width = displayInfo.logicalWidth;
                         height = displayInfo.logicalHeight;
@@ -8867,6 +8880,9 @@
         mInnerFields.mHoldScreen = null;
         mInnerFields.mScreenBrightness = -1;
         mInnerFields.mButtonBrightness = -1;
+        mInnerFields.mUserActivityTimeout = -1;
+        mInnerFields.mDisplayHasContent = LayoutFields.DISPLAY_CONTENT_UNKNOWN;
+
         mTransactionSequence++;
 
         final DisplayContent defaultDisplay = getDefaultDisplayContentLocked();
@@ -8886,10 +8902,6 @@
                 mStrictModeFlash.positionSurface(defaultDw, defaultDh);
             }
 
-            // Give the display manager a chance to adjust properties
-            // like display rotation if it needs to.
-            mDisplayManagerService.performTraversalInTransactionFromWindowManager();
-
             boolean focusDisplayed = false;
             boolean updateAllDrawn = false;
 
@@ -8905,6 +8917,11 @@
                 final int innerDh = displayInfo.appHeight;
                 final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
 
+                // Reset for each display unless we are forcing mirroring.
+                if (mInnerFields.mDisplayHasContent != LayoutFields.DISPLAY_CONTENT_MIRROR) {
+                    mInnerFields.mDisplayHasContent = LayoutFields.DISPLAY_CONTENT_UNKNOWN;
+                }
+
                 int repeats = 0;
                 do {
                     repeats++;
@@ -9024,9 +9041,8 @@
                         final boolean committed =
                                 winAnimator.commitFinishDrawingLocked(currentTime);
                         if (isDefaultDisplay && committed) {
-                            if ((w.mAttrs.flags
-                                    & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
-                                if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
+                            if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
+                                if (DEBUG_WALLPAPER) Slog.v(TAG,
                                         "First draw done in potential wallpaper target " + w);
                                 mInnerFields.mWallpaperMayChange = true;
                                 displayContent.pendingLayoutChanges |=
@@ -9042,7 +9058,8 @@
                         winAnimator.setSurfaceBoundariesLocked(recoveringMemory);
 
                         final AppWindowToken atoken = w.mAppToken;
-                        if (DEBUG_STARTING_WINDOW && atoken != null && w == atoken.startingWindow) {
+                        if (DEBUG_STARTING_WINDOW && atoken != null
+                                && w == atoken.startingWindow) {
                             Slog.d(TAG, "updateWindows: starting " + w + " isOnScreen="
                                 + w.isOnScreen() + " allDrawn=" + atoken.allDrawn
                                 + " freezingScreen=" + atoken.mAppAnimator.freezingScreen);
@@ -9054,8 +9071,7 @@
                                 atoken.numInterestingWindows = atoken.numDrawnWindows = 0;
                                 atoken.startingDisplayed = false;
                             }
-                            if ((w.isOnScreen() || winAnimator.mAttrType
-                                    == WindowManager.LayoutParams.TYPE_BASE_APPLICATION)
+                            if ((w.isOnScreen() || winAnimator.mAttrType == TYPE_BASE_APPLICATION)
                                     && !w.mExiting && !w.mDestroying) {
                                 if (WindowManagerService.DEBUG_VISIBILITY ||
                                         WindowManagerService.DEBUG_ORIENTATION) {
@@ -9098,6 +9114,22 @@
                     updateResizingWindows(w);
                 }
 
+                final boolean hasUniqueContent;
+                switch (mInnerFields.mDisplayHasContent) {
+                    case LayoutFields.DISPLAY_CONTENT_MIRROR:
+                        hasUniqueContent = isDefaultDisplay;
+                        break;
+                    case LayoutFields.DISPLAY_CONTENT_UNIQUE:
+                        hasUniqueContent = true;
+                        break;
+                    case LayoutFields.DISPLAY_CONTENT_UNKNOWN:
+                    default:
+                        hasUniqueContent = false;
+                        break;
+                }
+                mDisplayManagerService.setDisplayHasContent(displayId, hasUniqueContent,
+                        true /* inTraversal, must call performTraversalInTrans... below */);
+
                 if (!mInnerFields.mDimming && mAnimator.isDimmingLocked(displayId)) {
                     stopDimmingLocked(displayId);
                 }
@@ -9110,6 +9142,11 @@
             if (focusDisplayed) {
                 mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
             }
+
+            // Give the display manager a chance to adjust properties
+            // like display rotation if it needs to.
+            mDisplayManagerService.performTraversalInTransactionFromWindowManager();
+
         } catch (RuntimeException e) {
             Log.wtf(TAG, "Unhandled exception in Window Manager", e);
         } finally {
@@ -9320,6 +9357,8 @@
                 mPowerManager.setButtonBrightnessOverrideFromWindowManager(
                         toBrightnessOverride(mInnerFields.mButtonBrightness));
             }
+            mPowerManager.setUserActivityTimeoutOverrideFromWindowManager(
+                    mInnerFields.mUserActivityTimeout);
         }
 
         if (mTurnOnScreen) {
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java
index cd54c2e..8618cc8 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java
@@ -45,19 +45,40 @@
         mScript.set_gNoiseStrength(s);
     }
 
+    private int findHighBit(int v) {
+        int bit = 0;
+        while (v > 1) {
+            bit++;
+            v >>= 1;
+        }
+        return bit;
+    }
+
+
     public void createTest(android.content.res.Resources res) {
         int width = mInPixelsAllocation.getType().getX();
         int height = mInPixelsAllocation.getType().getY();
 
+        int noiseW = findHighBit(width);
+        int noiseH = findHighBit(height);
+        if (noiseW > 9) {
+            noiseW = 9;
+        }
+        if (noiseH > 9) {
+            noiseH = 9;
+        }
+        noiseW = 1 << noiseW;
+        noiseH = 1 << noiseH;
+
         Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS));
-        tb.setX(width);
-        tb.setY(height);
+        tb.setX(noiseW);
+        tb.setY(noiseH);
         mNoise = Allocation.createTyped(mRS, tb.create());
         mNoise2 = Allocation.createTyped(mRS, tb.create());
 
         mScript = new ScriptC_grain(mRS, res, R.raw.grain);
-        mScript.set_gWidth(width);
-        mScript.set_gHeight(height);
+        mScript.set_gWMask(noiseW - 1);
+        mScript.set_gHMask(noiseH - 1);
         mScript.set_gNoiseStrength(0.5f);
         mScript.set_gBlendSource(mNoise);
         mScript.set_gNoise(mNoise2);
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs
index ea42524..c8531f3 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs
@@ -38,15 +38,15 @@
  *  1  2  1
  */
 
-int32_t gWidth;
-int32_t gHeight;
+int32_t gWMask;
+int32_t gHMask;
 
 rs_allocation gBlendSource;
 void blend9(uchar *out, uint32_t x, uint32_t y) {
-    uint32_t x1 = min((int32_t)x+1, (int32_t)(gWidth -1));
-    uint32_t x2 = max((int32_t)x-1, (int32_t)0);
-    uint32_t y1 = min((int32_t)y+1, (int32_t)(gHeight -1));
-    uint32_t y2 = max((int32_t)y-1, (int32_t)0);
+    uint32_t x1 = (x-1) & gWMask;
+    uint32_t x2 = (x+1) & gWMask;
+    uint32_t y1 = (y-1) & gHMask;
+    uint32_t y2 = (y+1) & gHMask;
 
     uint p00 = 56 *  rsGetElementAt_uchar(gBlendSource, x1, y1);
     uint p01 = 114 * rsGetElementAt_uchar(gBlendSource, x, y1);
@@ -78,7 +78,7 @@
 rs_allocation gNoise;
 void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
     float4 ip = convert_float4(*in);
-    float pnoise = (float) rsGetElementAt_uchar(gNoise, x, y);
+    float pnoise = (float) rsGetElementAt_uchar(gNoise, x & gWMask, y & gHMask);
 
     float energy_level = ip.r + ip.g + ip.b;
     float energy_mask = (28.f - sqrt(energy_level)) * 0.03571f;
diff --git a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/CameraPreviewActivity.java b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/CameraPreviewActivity.java
index f21331f..89eec2c 100644
--- a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/CameraPreviewActivity.java
+++ b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/CameraPreviewActivity.java
@@ -305,8 +305,7 @@
 
             long t1 = java.lang.System.currentTimeMillis();
 
-            mFilterYuv.execute(data);
-            mFilterYuv.copyOut(mCallbackBitmap);
+            mFilterYuv.execute(data, mCallbackBitmap);
 
             long t2 = java.lang.System.currentTimeMillis();
             mTiming[mTimingSlot++] = t2 - t1;
diff --git a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/RsYuv.java b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/RsYuv.java
index cced198..978ae12 100644
--- a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/RsYuv.java
+++ b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/RsYuv.java
@@ -42,6 +42,7 @@
     private Allocation mAllocationOut;
     private Allocation mAllocationIn;
     private ScriptC_yuv mScript;
+    private ScriptIntrinsicYuvToRGB mYuv;
 
     RsYuv(RenderScript rs, Resources res, int width, int height) {
         mHeight = height;
@@ -50,6 +51,8 @@
         mScript = new ScriptC_yuv(mRS, res, R.raw.yuv);
         mScript.invoke_setSize(mWidth, mHeight);
 
+        mYuv = ScriptIntrinsicYuvToRGB.create(rs, Element.RGBA_8888(mRS));
+
         Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS));
         tb.setX(mWidth);
         tb.setY(mHeight);
@@ -58,34 +61,16 @@
         mAllocationIn = Allocation.createSized(rs, Element.U8(mRS), (mHeight * mWidth) +
                                                ((mHeight / 2) * (mWidth / 2) * 2));
 
-        mScript.bind_gYuvIn(mAllocationIn);
+        mYuv.setInput(mAllocationIn);
     }
 
     private long mTiming[] = new long[50];
     private int mTimingSlot = 0;
 
-    void execute(byte[] yuv) {
+    void execute(byte[] yuv, Bitmap b) {
         mAllocationIn.copyFrom(yuv);
-        mRS.finish();
-
-        long t1 = java.lang.System.currentTimeMillis();
-        mScript.forEach_root(mAllocationOut);
-        mRS.finish();
-        long t2 = java.lang.System.currentTimeMillis();
-
-        mTiming[mTimingSlot++] = t2 - t1;
-        if (mTimingSlot >= mTiming.length) {
-            float total = 0;
-            for (int i=0; i<mTiming.length; i++) {
-                total += (float)mTiming[i];
-            }
-            total /= mTiming.length;
-            Log.e("yuv", "core time = " + total);
-            mTimingSlot = 0;
-        }
-    }
-
-    void copyOut(Bitmap b) {
+        mYuv.forEach(mAllocationOut);
+        mScript.forEach_root(mAllocationOut, mAllocationOut);
         mAllocationOut.copyTo(b);
     }
 
diff --git a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/yuv.rs b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/yuv.rs
index 6057eff..884812d 100644
--- a/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/yuv.rs
+++ b/tests/RenderScriptTests/LivePreview/src/com/android/rs/livepreview/yuv.rs
@@ -3,8 +3,6 @@
 #pragma rs java_package_name(com.android.rs.livepreview)
 #pragma rs_fp_relaxed
 
-uchar *gYuvIn;
-
 static int gWidth;
 static int gHeight;
 static uchar crossProcess_tableR[256];
@@ -80,13 +78,9 @@
     return convert_uchar4(c);
 }
 
-void root(uchar4 *out, uint32_t x, uint32_t y) {
-    uchar Y = gYuvIn[(y * gWidth) + x];
-    uchar *uv = &gYuvIn[gWidth * gHeight];
-    uv += (((x>>1)<<1) + (y>>1) * gWidth);
-
-    uchar4 p = rsYuvToRGBA_uchar4(Y, uv[1], uv[0]);
-    p = crossProcess_i(p);
+void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
+    uchar4 p;
+    p = crossProcess_i(*in);
     p = vignette(p, x, y);
 
     out->rgba = p;
diff --git a/tests/StatusBar/src/com/android/statusbartest/PowerTest.java b/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
index e38bb6c..0cab10de 100644
--- a/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
@@ -21,9 +21,7 @@
 import android.os.IPowerManager;
 import android.content.ComponentName;
 import android.content.pm.PackageManager;
-import android.os.RemoteException;
 import android.os.Handler;
-import android.os.LocalPowerManager;
 import android.os.ServiceManager;
 import android.os.PowerManager;
 
@@ -106,69 +104,5 @@
                 }, 5000);
             }
         },
-        new Test("Touch events don't poke") {
-            public void run() {
-                mPokeState |= LocalPowerManager.POKE_LOCK_IGNORE_TOUCH_EVENTS;
-                try {
-                    mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG);
-                } catch (RemoteException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        },
-
-        new Test("Touch events poke") {
-            public void run() {
-                mPokeState &= ~LocalPowerManager.POKE_LOCK_IGNORE_TOUCH_EVENTS;
-                try {
-                    mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG);
-                } catch (RemoteException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        },
-        new Test("Short timeout") {
-            public void run() {
-                mPokeState &= ~LocalPowerManager.POKE_LOCK_TIMEOUT_MASK;
-                mPokeState |= LocalPowerManager.POKE_LOCK_SHORT_TIMEOUT;
-                try {
-                    mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG);
-                } catch (RemoteException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        },
-        new Test("Medium timeout") {
-            public void run() {
-                mPokeState &= ~LocalPowerManager.POKE_LOCK_TIMEOUT_MASK;
-                mPokeState |= LocalPowerManager.POKE_LOCK_MEDIUM_TIMEOUT;
-                try {
-                    mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG);
-                } catch (RemoteException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        },
-        new Test("Normal timeout") {
-            public void run() {
-                mPokeState &= ~LocalPowerManager.POKE_LOCK_TIMEOUT_MASK;
-                try {
-                    mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG);
-                } catch (RemoteException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        },
-        new Test("Illegal timeout") {
-            public void run() {
-                mPokeState |= LocalPowerManager.POKE_LOCK_SHORT_TIMEOUT
-                        | LocalPowerManager.POKE_LOCK_MEDIUM_TIMEOUT;
-                try {
-                    mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG);
-                } catch (RemoteException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        },
     };
 }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
index e882440..5e23f24 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -45,11 +45,6 @@
     }
 
     @Override
-    public void clearUserActivityTimeout(long arg0, long arg1) throws RemoteException {
-        // pass for now.
-    }
-
-    @Override
     public void crash(String arg0) throws RemoteException {
         // pass for now.
     }
@@ -95,11 +90,6 @@
     }
 
     @Override
-    public void setPokeLock(int arg0, IBinder arg1, String arg2) throws RemoteException {
-        // pass for now.
-    }
-
-    @Override
     public void setStayOnSetting(int arg0) throws RemoteException {
         // pass for now.
     }
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index ab9db88..db539e4 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -1624,7 +1624,7 @@
         Intent intent = new Intent(WifiManager.RSSI_CHANGED_ACTION);
         intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
         intent.putExtra(WifiManager.EXTRA_NEW_RSSI, newRssi);
-        mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+        mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
     }
 
     private void sendNetworkStateChangeBroadcast(String bssid) {