Merge "Start using some better sorting for intent resolution" into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index 058297a..fb60f1c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -570,7 +570,7 @@
     field public static final int fillViewport = 16843130; // 0x101017a
     field public static final int filter = 16843035; // 0x101011b
     field public static final int filterTouchesWhenObscured = 16843460; // 0x10102c4
-    field public static final int fingerprintDrawable = 16844025; // 0x10104f9
+    field public static final int fingerprintAuthDrawable = 16844025; // 0x10104f9
     field public static final int finishOnCloseSystemDialogs = 16843431; // 0x10102a7
     field public static final int finishOnTaskLaunch = 16842772; // 0x1010014
     field public static final int firstDayOfWeek = 16843581; // 0x101033d
diff --git a/api/system-current.txt b/api/system-current.txt
index ea2de6b..7816c3f 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -645,7 +645,7 @@
     field public static final int fillViewport = 16843130; // 0x101017a
     field public static final int filter = 16843035; // 0x101011b
     field public static final int filterTouchesWhenObscured = 16843460; // 0x10102c4
-    field public static final int fingerprintDrawable = 16844025; // 0x10104f9
+    field public static final int fingerprintAuthDrawable = 16844025; // 0x10104f9
     field public static final int finishOnCloseSystemDialogs = 16843431; // 0x10102a7
     field public static final int finishOnTaskLaunch = 16842772; // 0x1010014
     field public static final int firstDayOfWeek = 16843581; // 0x101033d
@@ -33516,6 +33516,10 @@
     field public static final int CALL_STATE_IDLE = 0; // 0x0
     field public static final int CALL_STATE_OFFHOOK = 2; // 0x2
     field public static final int CALL_STATE_RINGING = 1; // 0x1
+    field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe
+    field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1
+    field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0
+    field public static final int CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED = -1; // 0xffffffff
     field public static final int DATA_ACTIVITY_DORMANT = 4; // 0x4
     field public static final int DATA_ACTIVITY_IN = 1; // 0x1
     field public static final int DATA_ACTIVITY_INOUT = 3; // 0x3
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 68092c8..c3f2c43 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -2636,7 +2636,7 @@
 
     /**
      * Retrieve the official name associated with a user id.  This name is
-     * guaranteed to never change, though it is possibly for the underlying
+     * guaranteed to never change, though it is possible for the underlying
      * user id to be changed.  That is, if you are storing information about
      * user ids in persistent storage, you should use the string returned
      * by this function instead of the raw user-id.
diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java
index fda889f..d6b1142 100644
--- a/core/java/android/hardware/SensorManager.java
+++ b/core/java/android/hardware/SensorManager.java
@@ -1577,7 +1577,7 @@
      * Significant Motion, Step Counter etc.
      *
      * The tests which call this API need to have {@code
-     * android.permission.HARDWARE_TEST} permission which isn't
+     * android.permission.LOCATION_HADWARE} permission which isn't
      * available for third party applications.
      *
      * @param enable True to set the HAL in DATA_INJECTION mode.
@@ -1607,7 +1607,7 @@
      * the HAL is already in data injection mode.
      *
      * The tests which call this API need to have {@code
-     * android.permission.HARDWARE_TEST} permission which isn't
+     * android.permission.LOCATION_HARDWARE} permission which isn't
      * available for third party applications.
      *
      * @param sensor The sensor to inject.
diff --git a/core/java/android/hardware/SystemSensorManager.java b/core/java/android/hardware/SystemSensorManager.java
index 22a9e9c..d7960af 100644
--- a/core/java/android/hardware/SystemSensorManager.java
+++ b/core/java/android/hardware/SystemSensorManager.java
@@ -80,7 +80,7 @@
                 nativeClassInit();
             }
             mHasDataInjectionPermissions = context.checkSelfPermission(
-                    Manifest.permission.HARDWARE_TEST) == PackageManager.PERMISSION_GRANTED;
+                    Manifest.permission.LOCATION_HARDWARE) == PackageManager.PERMISSION_GRANTED;
         }
 
         // initialize the sensor list
@@ -233,7 +233,7 @@
     protected boolean enableDataInjectionImpl(boolean enable) {
         if (!mHasDataInjectionPermissions) {
             throw new SecurityException("Permission denial. Calling enableDataInjection without "
-                    + Manifest.permission.HARDWARE_TEST);
+                    + Manifest.permission.LOCATION_HARDWARE);
         }
         synchronized (mLock) {
             int ret = nativeEnableDataInjection(mNativeInstance, enable);
@@ -256,7 +256,7 @@
             long timestamp) {
         if (!mHasDataInjectionPermissions) {
             throw new SecurityException("Permission denial. Calling injectSensorData without "
-                    + Manifest.permission.HARDWARE_TEST);
+                    + Manifest.permission.LOCATION_HARDWARE);
         }
         synchronized (mLock) {
             if (!mDataInjectionMode) {
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
index c073ba5..ed167f0 100644
--- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
@@ -1924,6 +1924,28 @@
         return mCharacteristics;
     }
 
+    /**
+     * A high speed output surface can only be preview or hardware encoder surface.
+     *
+     * @param surface The high speed output surface to be checked.
+     */
+    private void checkHighSpeedSurfaceFormat(Surface surface) {
+        // TODO: remove this override since the default format should be
+        // ImageFormat.PRIVATE. b/9487482
+        final int HAL_FORMAT_RGB_START = 1; // HAL_PIXEL_FORMAT_RGBA_8888 from graphics.h
+        final int HAL_FORMAT_RGB_END = 5; // HAL_PIXEL_FORMAT_BGRA_8888 from graphics.h
+        int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface);
+        if (surfaceFormat >= HAL_FORMAT_RGB_START &&
+                surfaceFormat <= HAL_FORMAT_RGB_END) {
+            surfaceFormat = ImageFormat.PRIVATE;
+        }
+
+        if (surfaceFormat != ImageFormat.PRIVATE) {
+            throw new IllegalArgumentException("Surface format(" + surfaceFormat + ") is not"
+                    + " for preview or hardware video encoding!");
+        }
+    }
+
     private void checkConstrainedHighSpeedSurfaces(Collection<Surface> surfaces,
             Range<Integer> fpsRange) {
         if (surfaces == null || surfaces.size() == 0 || surfaces.size() > 2) {
@@ -1948,15 +1970,10 @@
         }
 
         for (Surface surface : surfaces) {
+            checkHighSpeedSurfaceFormat(surface);
+
             // Surface size must be supported high speed sizes.
             Size surfaceSize = SurfaceUtils.getSurfaceSize(surface);
-            int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface);
-
-            if (surfaceFormat != ImageFormat.PRIVATE) {
-                throw new IllegalArgumentException("Surface format is not for preview or"
-                        + " hardware video encoding" + surfaceFormat);
-            }
-
             if (!highSpeedSizes.contains(surfaceSize)) {
                 throw new IllegalArgumentException("Surface size " + surfaceSize.toString() + " is"
                         + " not part of the high speed supported size list " +
diff --git a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
index cc9d496..a3a998e 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
@@ -565,7 +565,7 @@
             throw new IllegalArgumentException("Surface was abandoned", e);
         }
 
-        return previewConsumer && (surfaceFormat == ImageFormat.PRIVATE);
+        return previewConsumer;
     }
 
     public static boolean isVideoEncoderConsumer(Surface output) {
@@ -583,7 +583,7 @@
             throw new IllegalArgumentException("Surface was abandoned", e);
         }
 
-        return videoEncoderConsumer && (surfaceFormat == ImageFormat.PRIVATE);
+        return videoEncoderConsumer;
     }
 
     /**
diff --git a/core/java/android/hardware/camera2/utils/SurfaceUtils.java b/core/java/android/hardware/camera2/utils/SurfaceUtils.java
index 32e74e2..40005a5 100644
--- a/core/java/android/hardware/camera2/utils/SurfaceUtils.java
+++ b/core/java/android/hardware/camera2/utils/SurfaceUtils.java
@@ -16,6 +16,7 @@
 
 package android.hardware.camera2.utils;
 
+import android.graphics.ImageFormat;
 import android.hardware.camera2.legacy.LegacyCameraDevice;
 import android.hardware.camera2.legacy.LegacyExceptionUtils.BufferQueueAbandonedException;
 import android.util.Size;
@@ -27,7 +28,7 @@
 public class SurfaceUtils {
 
     /**
-     * Check if a surface is for preview consumer.
+     * Check if a surface is for preview consumer based on consumer end point Gralloc usage flags.
      *
      * @param surface The surface to be checked.
      * @return true if the surface is for preview consumer, false otherwise.
@@ -37,7 +38,8 @@
     }
 
     /**
-     * Check if the surface is for hardware video encoder consumer.
+     * Check if the surface is for hardware video encoder consumer based on consumer end point
+     * Gralloc usage flags.
      *
      * @param surface The surface to be checked.
      * @return true if the surface is for hardware video encoder consumer, false otherwise.
diff --git a/core/java/android/os/storage/VolumeInfo.java b/core/java/android/os/storage/VolumeInfo.java
index 2622ee0..372725f 100644
--- a/core/java/android/os/storage/VolumeInfo.java
+++ b/core/java/android/os/storage/VolumeInfo.java
@@ -32,7 +32,9 @@
 import android.util.ArrayMap;
 import android.util.DebugUtils;
 import android.util.SparseArray;
+import android.util.SparseIntArray;
 
+import com.android.internal.R;
 import com.android.internal.util.IndentingPrintWriter;
 import com.android.internal.util.Preconditions;
 
@@ -80,6 +82,7 @@
 
     private static SparseArray<String> sStateToEnvironment = new SparseArray<>();
     private static ArrayMap<String, String> sEnvironmentToBroadcast = new ArrayMap<>();
+    private static SparseIntArray sStateToDescrip = new SparseIntArray();
 
     private static final Comparator<VolumeInfo>
             sDescriptionComparator = new Comparator<VolumeInfo>() {
@@ -116,6 +119,16 @@
         sEnvironmentToBroadcast.put(Environment.MEDIA_UNMOUNTABLE, Intent.ACTION_MEDIA_UNMOUNTABLE);
         sEnvironmentToBroadcast.put(Environment.MEDIA_REMOVED, Intent.ACTION_MEDIA_REMOVED);
         sEnvironmentToBroadcast.put(Environment.MEDIA_BAD_REMOVAL, Intent.ACTION_MEDIA_BAD_REMOVAL);
+
+        sStateToDescrip.put(VolumeInfo.STATE_UNMOUNTED, R.string.ext_media_status_unmounted);
+        sStateToDescrip.put(VolumeInfo.STATE_CHECKING, R.string.ext_media_status_checking);
+        sStateToDescrip.put(VolumeInfo.STATE_MOUNTED, R.string.ext_media_status_mounted);
+        sStateToDescrip.put(VolumeInfo.STATE_MOUNTED_READ_ONLY, R.string.ext_media_status_mounted_ro);
+        sStateToDescrip.put(VolumeInfo.STATE_FORMATTING, R.string.ext_media_status_formatting);
+        sStateToDescrip.put(VolumeInfo.STATE_EJECTING, R.string.ext_media_status_ejecting);
+        sStateToDescrip.put(VolumeInfo.STATE_UNMOUNTABLE, R.string.ext_media_status_unmountable);
+        sStateToDescrip.put(VolumeInfo.STATE_REMOVED, R.string.ext_media_status_removed);
+        sStateToDescrip.put(VolumeInfo.STATE_BAD_REMOVAL, R.string.ext_media_status_bad_removal);
     }
 
     /** vold state */
@@ -201,6 +214,10 @@
         return state;
     }
 
+    public int getStateDescription() {
+        return sStateToDescrip.get(state, 0);
+    }
+
     public @Nullable String getFsUuid() {
         return fsUuid;
     }
diff --git a/core/java/android/text/Spanned.java b/core/java/android/text/Spanned.java
index b4622e0..a785d1b 100644
--- a/core/java/android/text/Spanned.java
+++ b/core/java/android/text/Spanned.java
@@ -187,12 +187,11 @@
     public int getSpanFlags(Object tag);
 
     /**
-     * Return the first offset greater than or equal to <code>start</code>
-     * where a markup object of class <code>type</code> begins or ends,
-     * or <code>limit</code> if there are no starts or ends greater than or
-     * equal to <code>start</code> but less than <code>limit</code>.  Specify
-     * <code>null</code> or Object.class for the type if you want every
-     * transition regardless of type.
+     * Return the first offset greater than <code>start</code> where a markup
+     * object of class <code>type</code> begins or ends, or <code>limit</code>
+     * if there are no starts or ends greater than <code>start</code> but less
+     * than <code>limit</code>. Specify <code>null</code> or Object.class for
+     * the type if you want every transition regardless of type.
      */
     public int nextSpanTransition(int start, int limit, Class type);
 }
diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java
index f18b7ac..bd45007 100644
--- a/core/java/android/view/ViewPropertyAnimator.java
+++ b/core/java/android/view/ViewPropertyAnimator.java
@@ -80,18 +80,12 @@
 
     /**
      * The interpolator of the underlying Animator object. By default, we don't set the interpolator
-     * on the Animator and just use its default interpolator. If the interpolator is ever set on
-     * this Animator, then we use the interpolator that it was set to.
+     * on the Animator and just use its default interpolator. If the interpolator is set to a
+     * non-null value on this Animator, then we use the interpolator that it was set to.
      */
     private TimeInterpolator mInterpolator;
 
     /**
-     * A flag indicating whether the interpolator has been set on this object. If not, we don't set
-     * the interpolator on the underlying Animator, but instead just use its default interpolator.
-     */
-    private boolean mInterpolatorSet = false;
-
-    /**
      * Listener for the lifecycle events of the underlying ValueAnimator object.
      */
     private Animator.AnimatorListener mListener = null;
@@ -338,7 +332,6 @@
      * @return This object, allowing calls to methods in this class to be chained.
      */
     public ViewPropertyAnimator setInterpolator(TimeInterpolator interpolator) {
-        mInterpolatorSet = true;
         mInterpolator = interpolator;
         return this;
     }
@@ -349,7 +342,7 @@
      * @return The timing interpolator for this animation.
      */
     public TimeInterpolator getInterpolator() {
-        if (mInterpolatorSet) {
+        if (mInterpolator != null) {
             return mInterpolator;
         } else {
             // Just return the default from ValueAnimator, since that's what we'd get if
@@ -897,7 +890,7 @@
         if (mDurationSet) {
             animator.setDuration(mDuration);
         }
-        if (mInterpolatorSet) {
+        if (mInterpolator != null) {
             animator.setInterpolator(mInterpolator);
         }
         animator.start();
diff --git a/core/res/res/drawable-hdpi/ic_fingerprint_light_overlay.png b/core/res/res/drawable-hdpi/ic_fingerprint_light_overlay.png
deleted file mode 100644
index 0253c77..0000000
--- a/core/res/res/drawable-hdpi/ic_fingerprint_light_overlay.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_fingerprint_light_overlay.png b/core/res/res/drawable-mdpi/ic_fingerprint_light_overlay.png
deleted file mode 100644
index 5a1c61e..0000000
--- a/core/res/res/drawable-mdpi/ic_fingerprint_light_overlay.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_fingerprint_light_overlay.png b/core/res/res/drawable-xhdpi/ic_fingerprint_light_overlay.png
deleted file mode 100644
index 5f0c362..0000000
--- a/core/res/res/drawable-xhdpi/ic_fingerprint_light_overlay.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xxhdpi/ic_fingerprint_light_overlay.png b/core/res/res/drawable-xxhdpi/ic_fingerprint_light_overlay.png
deleted file mode 100644
index f4cf906..0000000
--- a/core/res/res/drawable-xxhdpi/ic_fingerprint_light_overlay.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xxxhdpi/ic_fingerprint_light_overlay.png b/core/res/res/drawable-xxxhdpi/ic_fingerprint_light_overlay.png
deleted file mode 100644
index dcdbed9..0000000
--- a/core/res/res/drawable-xxxhdpi/ic_fingerprint_light_overlay.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/ic_fingerprint.xml b/core/res/res/drawable/ic_fingerprint.xml
new file mode 100644
index 0000000..c19f00f
--- /dev/null
+++ b/core/res/res/drawable/ic_fingerprint.xml
@@ -0,0 +1,37 @@
+<!--
+  ~ Copyright (C) 2015 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
+  -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24.0dp"
+        android:height="24.0dp"
+        android:tint="?attr/colorControlNormal"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M17.5,4.47c-0.08,0.0 -0.16,-0.02 -0.24,-0.06C15.45,3.42 13.88,3.0 12.01,3.0c-1.87,0.0 -3.64,0.47 -5.25,1.4C6.52,4.54 6.22,4.46 6.08,4.22C5.94,3.98 6.02,3.67 6.26,3.54C8.03,2.52 9.96,2.0 12.01,2.0c2.02,0.0 3.79,0.47 5.73,1.53c0.24,0.13 0.33,0.44 0.2,0.68C17.85,4.38 17.68,4.47 17.5,4.47z"/>
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M3.95,9.72c-0.1,0.0 -0.19,-0.03 -0.28,-0.08C3.44,9.48 3.38,9.17 3.54,8.94c0.94,-1.4 2.14,-2.5 3.56,-3.28c2.99,-1.63 6.82,-1.63 9.81,-0.01c1.42,0.77 2.61,1.87 3.56,3.26c0.15,0.23 0.09,0.54 -0.13,0.69c-0.23,0.16 -0.54,0.09 -0.69,-0.13c-0.85,-1.26 -1.93,-2.24 -3.2,-2.94c-2.7,-1.47 -6.16,-1.46 -8.86,0.01C6.3,7.24 5.22,8.23 4.37,9.5C4.27,9.64 4.11,9.72 3.95,9.72z"/>
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M9.86,21.79c-0.13,0.0 -0.27,-0.05 -0.36,-0.16c-0.82,-0.87 -1.26,-1.43 -1.9,-2.63c-0.65,-1.23 -1.0,-2.73 -1.0,-4.33c0.0,-2.97 2.42,-5.39 5.39,-5.39s5.39,2.42 5.39,5.39c0.0,0.28 -0.22,0.5 -0.5,0.5s-0.5,-0.22 -0.5,-0.5c0.0,-2.42 -1.97,-4.39 -4.39,-4.39S7.6,12.24 7.6,14.66c0.0,1.44 0.3,2.78 0.88,3.86c0.61,1.15 1.02,1.64 1.75,2.42c0.19,0.2 0.18,0.52 -0.02,0.71C10.11,21.74 9.98,21.79 9.86,21.79z"/>
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M16.7,19.94c-1.14,0.0 -2.13,-0.3 -2.96,-0.89c-1.41,-1.01 -2.25,-2.65 -2.25,-4.38c0.0,-0.28 0.22,-0.5 0.5,-0.5s0.5,0.22 0.5,0.5c0.0,1.41 0.69,2.75 1.83,3.57c0.66,0.48 1.44,0.71 2.38,0.71c0.23,0.0 0.6,-0.02 0.98,-0.1c0.27,-0.05 0.53,0.13 0.58,0.4c0.05,0.27 -0.13,0.53 -0.4,0.58C17.3,19.93 16.83,19.94 16.7,19.94z"/>
+    <path
+        android:fillColor="#ffffff"
+        android:pathData="M14.76,22.0c-0.05,0.0 -0.09,-0.01 -0.14,-0.02c-1.51,-0.44 -2.51,-1.03 -3.53,-2.11c-1.32,-1.39 -2.05,-3.24 -2.05,-5.21c0.0,-1.62 1.32,-2.94 2.94,-2.94c1.62,0.0 2.94,1.32 2.94,2.94c0.0,1.07 0.87,1.94 1.94,1.94s1.94,-0.87 1.94,-1.94c0.0,-3.77 -3.07,-6.83 -6.83,-6.83c-2.68,0.0 -5.12,1.58 -6.23,4.02c-0.37,0.81 -0.56,1.76 -0.56,2.81c0.0,0.78 0.07,2.01 0.63,3.61c0.09,0.26 -0.04,0.55 -0.3,0.64c-0.26,0.09 -0.55,-0.04 -0.64,-0.3c-0.46,-1.31 -0.69,-2.6 -0.69,-3.95c0.0,-1.2 0.22,-2.28 0.65,-3.23c1.27,-2.8 4.07,-4.61 7.14,-4.61c4.32,0.0 7.83,3.51 7.83,7.83c0.0,1.62 -1.32,2.94 -2.94,2.94c-1.62,0.0 -2.94,-1.32 -2.94,-2.94c0.0,-1.07 -0.87,-1.94 -1.94,-1.94s-1.94,0.87 -1.94,1.94c0.0,1.71 0.63,3.32 1.77,4.52c0.9,0.95 1.74,1.45 3.08,1.84c0.27,0.08 0.42,0.35 0.34,0.62C15.18,21.86 14.98,22.0 14.76,22.0z"/>
+</vector>
diff --git a/core/res/res/drawable/ic_fingerprint_dark.xml b/core/res/res/drawable/ic_fingerprint_dark.xml
deleted file mode 100644
index 6eb6ada..0000000
--- a/core/res/res/drawable/ic_fingerprint_dark.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<!--
-  ~ Copyright (C) 2015 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
-  -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="32.0dp"
-        android:height="32.0dp"
-        android:viewportWidth="32.0"
-        android:viewportHeight="32.0">
-    <path
-        android:fillColor="?attr/colorControlNormal"
-        android:pathData="M23.7,5.9c-0.1,0.0 -0.2,0.0 -0.3,-0.1C21.0,4.5 18.6,3.9 16.0,3.9c-2.5,0.0 -4.6,0.6 -6.9,1.9C8.8,6.0 8.3,5.9 8.1,5.5C7.9,5.2 8.0,4.7 8.4,4.5c2.5,-1.4 4.9,-2.1 7.7,-2.1c2.8,0.0 5.4,0.7 8.0,2.1c0.4,0.2 0.5,0.6 0.3,1.0C24.2,5.7 24.0,5.9 23.7,5.9z"/>
-    <path
-        android:fillColor="?attr/colorControlNormal"
-        android:pathData="M5.3,13.2c-0.1,0.0 -0.3,0.0 -0.4,-0.1c-0.3,-0.2 -0.4,-0.7 -0.2,-1.0c1.3,-1.9 2.9,-3.4 4.9,-4.5c4.1,-2.2 9.3,-2.2 13.4,0.0c1.9,1.1 3.6,2.5 4.9,4.4c0.2,0.3 0.1,0.8 -0.2,1.0c-0.3,0.2 -0.8,0.1 -1.0,-0.2c-1.2,-1.7 -2.6,-3.0 -4.3,-4.0c-3.7,-2.0 -8.3,-2.0 -12.0,0.0c-1.7,0.9 -3.2,2.3 -4.3,4.0C5.7,13.1 5.5,13.2 5.3,13.2z"/>
-    <path
-        android:fillColor="?attr/colorControlNormal"
-        android:pathData="M13.3,29.6c-0.2,0.0 -0.4,-0.1 -0.5,-0.2c-1.1,-1.2 -1.7,-2.0 -2.6,-3.6c-0.9,-1.7 -1.4,-3.7 -1.4,-5.9c0.0,-4.1 3.3,-7.4 7.4,-7.4c4.1,0.0 7.4,3.3 7.4,7.4c0.0,0.4 -0.3,0.7 -0.7,0.7s-0.7,-0.3 -0.7,-0.7c0.0,-3.3 -2.7,-5.9 -5.9,-5.9c-3.3,0.0 -5.9,2.7 -5.9,5.9c0.0,2.0 0.4,3.8 1.2,5.2c0.8,1.6 1.4,2.2 2.4,3.3c0.3,0.3 0.3,0.8 0.0,1.0C13.7,29.5 13.5,29.6 13.3,29.6z"/>
-    <path
-        android:fillColor="?attr/colorControlNormal"
-        android:pathData="M22.6,27.1c-1.6,0.0 -2.9,-0.4 -4.1,-1.2c-1.9,-1.4 -3.1,-3.6 -3.1,-6.0c0.0,-0.4 0.3,-0.7 0.7,-0.7s0.7,0.3 0.7,0.7c0.0,1.9 0.9,3.7 2.5,4.8c0.9,0.6 1.9,1.0 3.2,1.0c0.3,0.0 0.8,0.0 1.3,-0.1c0.4,-0.1 0.8,0.2 0.8,0.6c0.1,0.4 -0.2,0.8 -0.6,0.8C23.4,27.1 22.8,27.1 22.6,27.1z"/>
-    <path
-        android:fillColor="?attr/colorControlNormal"
-        android:pathData="M20.0,29.9c-0.1,0.0 -0.1,0.0 -0.2,0.0c-2.1,-0.6 -3.4,-1.4 -4.8,-2.9c-1.8,-1.9 -2.8,-4.4 -2.8,-7.1c0.0,-2.2 1.8,-4.1 4.1,-4.1c2.2,0.0 4.1,1.8 4.1,4.1c0.0,1.4 1.2,2.6 2.6,2.6c1.4,0.0 2.6,-1.2 2.6,-2.6c0.0,-5.1 -4.2,-9.3 -9.3,-9.3c-3.6,0.0 -6.9,2.1 -8.4,5.4C7.3,17.1 7.0,18.4 7.0,19.8c0.0,1.1 0.1,2.7 0.9,4.9c0.1,0.4 -0.1,0.8 -0.4,0.9c-0.4,0.1 -0.8,-0.1 -0.9,-0.4c-0.6,-1.8 -0.9,-3.6 -0.9,-5.4c0.0,-1.6 0.3,-3.1 0.9,-4.4c1.7,-3.8 5.6,-6.3 9.8,-6.3c5.9,0.0 10.7,4.8 10.7,10.7c0.0,2.2 -1.8,4.1 -4.1,4.1s-4.0,-1.8 -4.0,-4.1c0.0,-1.4 -1.2,-2.6 -2.6,-2.6c-1.4,0.0 -2.6,1.2 -2.6,2.6c0.0,2.3 0.9,4.5 2.4,6.1c1.2,1.3 2.4,2.0 4.2,2.5c0.4,0.1 0.6,0.5 0.5,0.9C20.6,29.7 20.3,29.9 20.0,29.9z"/>
-</vector>
diff --git a/core/res/res/drawable/ic_fingerprint_light.xml b/core/res/res/drawable/ic_fingerprint_light.xml
deleted file mode 100644
index 223d16b..0000000
--- a/core/res/res/drawable/ic_fingerprint_light.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-    Copyright (C) 2015 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.
--->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-    <item>
-        <shape android:shape="oval">
-            <solid android:color="?attr/colorAccent"/>
-            <size
-                android:width="40dp"
-                android:height="40dp"/>
-        </shape>
-    </item>
-    <item>
-        <bitmap android:src="@drawable/ic_fingerprint_light_overlay"/>
-    </item>
-</layer-list>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 0f66950..bb442eb 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -561,15 +561,18 @@
         <!-- Image elements -->
         <!-- ============== -->
         <eat-comment />
-
+i
         <!-- Background that can be used behind parts of a UI that provide
              details on data the user is selecting.  For example, this is
              the background element of PreferenceActivity's embedded
              preference fragment. -->
         <attr name="detailsElementBackground" format="reference" />
 
-        <!-- Drawable that should be used to indicate that an app is waiting for a fingerprint scan. -->
-        <attr name="fingerprintDrawable" format="reference" />
+        <!-- Icon that should be used to indicate that an app is waiting for a fingerprint scan.
+             This should be used whenever an app is requesting the user to place a finger on the
+             fingerprint sensor. It can be combined with other drawables such as colored circles, so
+             the appearance matches the branding of the app requesting the fingerprint scan.-->
+        <attr name="fingerprintAuthDrawable" format="reference" />
 
         <!-- ============ -->
         <!-- Panel styles -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index bbf4005..54cfa03 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2690,5 +2690,5 @@
   <public type="attr" name="supportsLaunchVoiceAssistFromKeyguard" />
   <public type="attr" name="scrollIndicators" />
   <public type="attr" name="hyphenationFrequency" />
-  <public type="attr" name="fingerprintDrawable" />
+  <public type="attr" name="fingerprintAuthDrawable" />
 </resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 21abb1b..28274ae 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1519,9 +1519,9 @@
     <string name="policylab_disableCamera">Disable cameras</string>
     <!-- Description of policy access to disable all device cameras [CHAR LIMIT=110]-->
     <string name="policydesc_disableCamera">Prevent use of all device cameras.</string>
-    <!-- Title of policy access to disable all device cameras [CHAR LIMIT=30]-->
+    <!-- Title of policy access to disable keyguard features [CHAR LIMIT=30]-->
     <string name="policylab_disableKeyguardFeatures">Disable some screen lock features</string>
-    <!-- Description of policy access to disable all device cameras [CHAR LIMIT=110]-->
+    <!-- Description of policy access to disable keyguard features. [CHAR LIMIT=110]-->
     <string name="policydesc_disableKeyguardFeatures">Prevent use of some screen lock features.</string>
 
     <!-- The order of these is important, don't reorder without changing Contacts.java --> <skip />
@@ -3028,9 +3028,14 @@
     <string name="ext_media_ready_notification_message">For transferring photos and media</string>
 
     <!-- Notification title when external media is unmountable (corrupt) [CHAR LIMIT=30] -->
-    <string name="ext_media_unmountable_notification_title">Damaged <xliff:g id="name" example="SD card">%s</xliff:g></string>
+    <string name="ext_media_unmountable_notification_title">Corrupted <xliff:g id="name" example="SD card">%s</xliff:g></string>
     <!-- Notification body when external media is unmountable (corrupt) [CHAR LIMIT=NONE] -->
-    <string name="ext_media_unmountable_notification_message"><xliff:g id="name" example="SD card">%s</xliff:g> is damaged; try reformatting it</string>
+    <string name="ext_media_unmountable_notification_message"><xliff:g id="name" example="SD card">%s</xliff:g> is corrupt. Touch to fix.</string>
+
+    <!-- Notification title when external media is unsupported [CHAR LIMIT=30] -->
+    <string name="ext_media_unsupported_notification_title">Unsupported <xliff:g id="name" example="SD card">%s</xliff:g></string>
+    <!-- Notification body when external media is unsupported [CHAR LIMIT=NONE] -->
+    <string name="ext_media_unsupported_notification_message">This device doesn\u2019t support this <xliff:g id="name" example="SD card">%s</xliff:g>. Touch to set up in a supported format.</string>
 
     <!-- Notification title when external media is unsafely removed [CHAR LIMIT=30] -->
     <string name="ext_media_badremoval_notification_title"><xliff:g id="name" example="SD card">%s</xliff:g> unexpectedly removed</string>
@@ -3048,7 +3053,7 @@
     <string name="ext_media_unmounting_notification_message">Don\'t remove</string>
 
     <!-- Notification action to setup external media [CHAR LIMIT=20] -->
-    <string name="ext_media_init_action">Setup</string>
+    <string name="ext_media_init_action">Set up</string>
     <!-- Notification action to unmount external media [CHAR LIMIT=20] -->
     <string name="ext_media_unmount_action">Eject</string>
     <!-- Notification action to browse external media [CHAR LIMIT=20] -->
@@ -3074,6 +3079,29 @@
     <!-- Notification title when moving data to external storage failed [CHAR LIMIT=64] -->
     <string name="ext_media_move_failure_message">Data left at original location</string>
 
+    <!-- Short summary of storage media status when removed [CHAR LIMIT=32] -->
+    <string name="ext_media_status_removed">Removed</string>
+    <!-- Short summary of storage media status when unmounted [CHAR LIMIT=32] -->
+    <string name="ext_media_status_unmounted">Ejected</string>
+    <!-- Short summary of storage media status when checking [CHAR LIMIT=32] -->
+    <string name="ext_media_status_checking">Checking\u2026</string>
+    <!-- Short summary of storage media status when mounted [CHAR LIMIT=32] -->
+    <string name="ext_media_status_mounted">Ready</string>
+    <!-- Short summary of storage media status when mounted read-only [CHAR LIMIT=32] -->
+    <string name="ext_media_status_mounted_ro">Read-only</string>
+    <!-- Short summary of storage media status when removed unsafely [CHAR LIMIT=32] -->
+    <string name="ext_media_status_bad_removal">Removed unsafely</string>
+    <!-- Short summary of storage media status when unmountable [CHAR LIMIT=32] -->
+    <string name="ext_media_status_unmountable">Corrupted</string>
+    <!-- Short summary of storage media status when unsupported [CHAR LIMIT=32] -->
+    <string name="ext_media_status_unsupported">Unsupported</string>
+    <!-- Short summary of storage media status when ejecting [CHAR LIMIT=32] -->
+    <string name="ext_media_status_ejecting">Ejecting\u2026</string>
+    <!-- Short summary of storage media status when formatting [CHAR LIMIT=32] -->
+    <string name="ext_media_status_formatting">Formatting\u2026</string>
+    <!-- Short summary of storage media status when missing [CHAR LIMIT=32] -->
+    <string name="ext_media_status_missing">Not inserted</string>
+
     <!-- Shown in LauncherActivity when the requested target Intent didn't return any matching Activities, leaving the list empty. -->
     <string name="activity_list_empty">No matching activities found.</string>
 
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 099f6c1..8900688 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2291,5 +2291,20 @@
   <java-symbol type="string" name="config_radio_access_family" />
   <java-symbol type="string" name="notification_inbox_ellipsis" />
   <java-symbol type="bool" name="config_mainBuiltInDisplayIsRound" />
+
   <java-symbol type="attr" name="seekBarDialogPreferenceStyle" />
+  <java-symbol type="string" name="ext_media_status_removed" />
+  <java-symbol type="string" name="ext_media_status_unmounted" />
+  <java-symbol type="string" name="ext_media_status_checking" />
+  <java-symbol type="string" name="ext_media_status_mounted" />
+  <java-symbol type="string" name="ext_media_status_mounted_ro" />
+  <java-symbol type="string" name="ext_media_status_bad_removal" />
+  <java-symbol type="string" name="ext_media_status_unmountable" />
+  <java-symbol type="string" name="ext_media_status_unsupported" />
+  <java-symbol type="string" name="ext_media_status_ejecting" />
+  <java-symbol type="string" name="ext_media_status_formatting" />
+  <java-symbol type="string" name="ext_media_status_missing" />
+  <java-symbol type="string" name="ext_media_unsupported_notification_message" />
+  <java-symbol type="string" name="ext_media_unsupported_notification_title" />
+
 </resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 1230b5e..ecf00f0 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -387,6 +387,7 @@
         <item name="buttonBarNegativeButtonStyle">?attr/buttonBarButtonStyle</item>
         <item name="buttonBarNeutralButtonStyle">?attr/buttonBarButtonStyle</item>
         <item name="segmentedButtonStyle">@style/SegmentedButton</item>
+        <item name="fingerprintAuthDrawable">@drawable/ic_fingerprint</item>
 
         <!-- SearchView attributes -->
         <item name="searchViewStyle">@style/Widget.Holo.SearchView</item>
diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml
index 9fe8df4..295b453 100644
--- a/core/res/res/values/themes_material.xml
+++ b/core/res/res/values/themes_material.xml
@@ -305,7 +305,6 @@
         <item name="preferenceFragmentListStyle">@style/PreferenceFragmentList.Material</item>
         <item name="preferenceFragmentPaddingSide">@dimen/preference_fragment_padding_side_material</item>
         <item name="detailsElementBackground">?attr/colorBackground</item>
-        <item name="fingerprintDrawable">@drawable/ic_fingerprint_dark</item>
 
         <!-- PreferenceFrameLayout attributes -->
         <item name="preferenceFrameLayoutStyle">@style/Widget.Material.PreferenceFrameLayout</item>
@@ -662,7 +661,6 @@
         <item name="preferenceFragmentListStyle">@style/PreferenceFragmentList.Material</item>
         <item name="preferenceFragmentPaddingSide">@dimen/preference_fragment_padding_side_material</item>
         <item name="detailsElementBackground">?attr/colorBackground</item>
-        <item name="fingerprintDrawable">@drawable/ic_fingerprint_light</item>
 
         <!-- PreferenceFrameLayout attributes -->
         <item name="preferenceFrameLayoutStyle">@style/Widget.Material.PreferenceFrameLayout</item>
diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java
index 64863c2..1355635 100644
--- a/media/java/android/media/SoundPool.java
+++ b/media/java/android/media/SoundPool.java
@@ -35,6 +35,7 @@
 import android.util.AndroidRuntimeException;
 import android.util.Log;
 
+import com.android.internal.app.IAppOpsCallback;
 import com.android.internal.app.IAppOpsService;
 
 
@@ -125,10 +126,12 @@
 
     private EventHandler mEventHandler;
     private SoundPool.OnLoadCompleteListener mOnLoadCompleteListener;
+    private boolean mHasAppOpsPlayAudio;
 
     private final Object mLock;
     private final AudioAttributes mAttributes;
     private final IAppOpsService mAppOps;
+    private final IAppOpsCallback mAppOpsCallback;
 
     /**
      * Constructor. Constructs a SoundPool object with the following
@@ -159,6 +162,24 @@
         mAttributes = attributes;
         IBinder b = ServiceManager.getService(Context.APP_OPS_SERVICE);
         mAppOps = IAppOpsService.Stub.asInterface(b);
+        // initialize mHasAppOpsPlayAudio
+        updateAppOpsPlayAudio();
+        // register a callback to monitor whether the OP_PLAY_AUDIO is still allowed
+        mAppOpsCallback = new IAppOpsCallback.Stub() {
+            public void opChanged(int op, String packageName) {
+                synchronized (mLock) {
+                    if (op == AppOpsManager.OP_PLAY_AUDIO) {
+                        updateAppOpsPlayAudio();
+                    }
+                }
+            }
+        };
+        try {
+            mAppOps.startWatchingMode(AppOpsManager.OP_PLAY_AUDIO,
+                    ActivityThread.currentPackageName(), mAppOpsCallback);
+        } catch (RemoteException e) {
+            mHasAppOpsPlayAudio = false;
+        }
     }
 
     /**
@@ -168,7 +189,16 @@
      * object. The SoundPool can no longer be used and the reference
      * should be set to null.
      */
-    public native final void release();
+    public final void release() {
+        try {
+            mAppOps.stopWatchingMode(mAppOpsCallback);
+        } catch (RemoteException e) {
+            // nothing to do here, the SoundPool is being released anyway
+        }
+        native_release();
+    }
+
+    private native final void native_release();
 
     protected void finalize() { release(); }
 
@@ -466,13 +496,17 @@
         if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
             return false;
         }
+        return !mHasAppOpsPlayAudio;
+    }
+
+    private void updateAppOpsPlayAudio() {
         try {
             final int mode = mAppOps.checkAudioOperation(AppOpsManager.OP_PLAY_AUDIO,
                     mAttributes.getUsage(),
                     Process.myUid(), ActivityThread.currentPackageName());
-            return mode != AppOpsManager.MODE_ALLOWED;
+            mHasAppOpsPlayAudio = (mode == AppOpsManager.MODE_ALLOWED);
         } catch (RemoteException e) {
-            return false;
+            mHasAppOpsPlayAudio = false;
         }
     }
 
diff --git a/media/jni/android_media_ImageWriter.cpp b/media/jni/android_media_ImageWriter.cpp
index 294cd84..634ba64 100644
--- a/media/jni/android_media_ImageWriter.cpp
+++ b/media/jni/android_media_ImageWriter.cpp
@@ -293,7 +293,8 @@
         res = native_window_set_usage(anw.get(), GRALLOC_USAGE_SW_WRITE_OFTEN);
         if (res != OK) {
             ALOGE("%s: Configure usage %08x for format %08x failed: %s (%d)",
-                    __FUNCTION__, GRALLOC_USAGE_SW_WRITE_OFTEN, format, strerror(-res), res);
+                  __FUNCTION__, static_cast<unsigned int>(GRALLOC_USAGE_SW_WRITE_OFTEN),
+                  format, strerror(-res), res);
             jniThrowRuntimeException(env, "Failed to SW_WRITE_OFTEN configure usage");
             return 0;
         }
diff --git a/media/jni/soundpool/android_media_SoundPool.cpp b/media/jni/soundpool/android_media_SoundPool.cpp
index fc4cf05..ab3e340 100644
--- a/media/jni/soundpool/android_media_SoundPool.cpp
+++ b/media/jni/soundpool/android_media_SoundPool.cpp
@@ -286,7 +286,7 @@
         "(Ljava/lang/Object;ILjava/lang/Object;)I",
         (void*)android_media_SoundPool_native_setup
     },
-    {   "release",
+    {   "native_release",
         "()V",
         (void*)android_media_SoundPool_release
     }
diff --git a/native/android/Android.mk b/native/android/Android.mk
index 12fdf71..1742bee 100644
--- a/native/android/Android.mk
+++ b/native/android/Android.mk
@@ -16,6 +16,7 @@
     obb.cpp \
     sensor.cpp \
     storage_manager.cpp \
+    trace.cpp \
 
 LOCAL_SHARED_LIBRARIES := \
     liblog \
diff --git a/native/android/trace.cpp b/native/android/trace.cpp
new file mode 100644
index 0000000..db52220
--- /dev/null
+++ b/native/android/trace.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#include <android/trace.h>
+#include <cutils/trace.h>
+
+bool ATrace_isEnabled() {
+    return atrace_is_tag_enabled(ATRACE_TAG_APP);
+}
+
+void ATrace_beginSection(const char* sectionName) {
+    atrace_begin(ATRACE_TAG_APP, sectionName);
+}
+
+void ATrace_endSection() {
+    atrace_end(ATRACE_TAG_APP);
+}
diff --git a/packages/DocumentsUI/res/values/strings.xml b/packages/DocumentsUI/res/values/strings.xml
index 9794273..943104d 100644
--- a/packages/DocumentsUI/res/values/strings.xml
+++ b/packages/DocumentsUI/res/values/strings.xml
@@ -45,7 +45,7 @@
     <!-- Menu item title that deletes the selected documents [CHAR LIMIT=24] -->
     <string name="menu_delete">Delete</string>
     <!-- Menu item title that selects all documents in the current directory [CHAR LIMIT=24] -->
-    <string name="menu_select_all">Select All</string>
+    <string name="menu_select_all">Select all</string>
     <!-- Menu item title that copies the selected documents [CHAR LIMIT=24] -->
     <string name="menu_copy">Copy to\u2026</string>
 
diff --git a/packages/Keyguard/res/layout/keyguard_pattern_view.xml b/packages/Keyguard/res/layout/keyguard_pattern_view.xml
index 0f5431e..09c01de 100644
--- a/packages/Keyguard/res/layout/keyguard_pattern_view.xml
+++ b/packages/Keyguard/res/layout/keyguard_pattern_view.xml
@@ -31,8 +31,7 @@
     android:clipToPadding="false"
     androidprv:layout_maxWidth="@dimen/keyguard_security_width"
     androidprv:layout_maxHeight="@dimen/keyguard_security_height"
-    android:gravity="center_horizontal"
-    android:contentDescription="@string/keyguard_accessibility_pattern_unlock">
+    android:gravity="center_horizontal">
 
     <FrameLayout
         android:layout_width="match_parent"
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPINView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPINView.java
index d0be855..ac9dc85 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPINView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPINView.java
@@ -22,6 +22,9 @@
 import android.view.ViewGroup;
 import android.view.animation.AnimationUtils;
 
+import com.android.settingslib.animation.AppearAnimationUtils;
+import com.android.settingslib.animation.DisappearAnimationUtils;
+
 /**
  * Displays a PIN pad for unlocking.
  */
@@ -115,7 +118,7 @@
                 .setDuration(500)
                 .setInterpolator(mAppearAnimationUtils.getInterpolator())
                 .translationY(0);
-        mAppearAnimationUtils.startAnimation(mViews,
+        mAppearAnimationUtils.startAnimation2d(mViews,
                 new Runnable() {
                     @Override
                     public void run() {
@@ -132,7 +135,7 @@
                 .setDuration(280)
                 .setInterpolator(mDisappearAnimationUtils.getInterpolator())
                 .translationY(mDisappearYTranslation);
-        mDisappearAnimationUtils.startAnimation(mViews,
+        mDisappearAnimationUtils.startAnimation2d(mViews,
                 new Runnable() {
                     @Override
                     public void run() {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
index a9b2978..1bd0bb4 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
@@ -36,6 +36,9 @@
 import com.android.internal.widget.LockPatternChecker;
 import com.android.internal.widget.LockPatternUtils;
 import com.android.internal.widget.LockPatternView;
+import com.android.settingslib.animation.AppearAnimationCreator;
+import com.android.settingslib.animation.AppearAnimationUtils;
+import com.android.settingslib.animation.DisappearAnimationUtils;
 
 import java.util.List;
 
@@ -325,7 +328,7 @@
                 .setDuration(500)
                 .setInterpolator(mAppearAnimationUtils.getInterpolator())
                 .translationY(0);
-        mAppearAnimationUtils.startAnimation(
+        mAppearAnimationUtils.startAnimation2d(
                 mLockPatternView.getCellStates(),
                 new Runnable() {
                     @Override
@@ -353,7 +356,7 @@
                 .setDuration(300)
                 .setInterpolator(mDisappearAnimationUtils.getInterpolator())
                 .translationY(-mDisappearAnimationUtils.getStartTranslation());
-        mDisappearAnimationUtils.startAnimation(mLockPatternView.getCellStates(),
+        mDisappearAnimationUtils.startAnimation2d(mLockPatternView.getCellStates(),
                 new Runnable() {
                     @Override
                     public void run() {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java
index ed0d4afe..23834a3 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java
@@ -150,13 +150,6 @@
         // Set selected property on so the view can send accessibility events.
         mPasswordEntry.setSelected(true);
 
-        // Poke the wakelock any time the text is selected or modified
-        mPasswordEntry.setOnClickListener(new OnClickListener() {
-            public void onClick(View v) {
-                onUserInput();
-            }
-        });
-
         mPasswordEntry.setUserActivityListener(new PasswordTextView.UserActivityListener() {
             @Override
             public void onUserActivity() {
diff --git a/packages/SettingsLib/res/values/dimens.xml b/packages/SettingsLib/res/values/dimens.xml
new file mode 100644
index 0000000..1c4b05f
--- /dev/null
+++ b/packages/SettingsLib/res/values/dimens.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2015 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
+  -->
+<resources>
+
+    <!-- The y translation to apply at the start in appear animations. -->
+    <dimen name="appear_y_translation_start">32dp</dimen>
+
+    <!-- The translation for disappearing security views after having solved them. -->
+    <dimen name="disappear_y_translation">-32dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/packages/Keyguard/src/com/android/keyguard/AppearAnimationCreator.java b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationCreator.java
similarity index 86%
rename from packages/Keyguard/src/com/android/keyguard/AppearAnimationCreator.java
rename to packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationCreator.java
index e4706b6..8a61e4e 100644
--- a/packages/Keyguard/src/com/android/keyguard/AppearAnimationCreator.java
+++ b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationCreator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2015 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.
@@ -14,13 +14,13 @@
  * limitations under the License
  */
 
-package com.android.keyguard;
+package com.android.settingslib.animation;
 
 import android.view.animation.Interpolator;
 
 /**
  * An interface which can create animations when starting an appear animation with
- * {@link com.android.keyguard.AppearAnimationUtils}
+ * {@link AppearAnimationUtils}
  */
 public interface AppearAnimationCreator<T> {
      void createAnimation(T animatedObject, long delay, long duration,
diff --git a/packages/Keyguard/src/com/android/keyguard/AppearAnimationUtils.java b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java
similarity index 85%
rename from packages/Keyguard/src/com/android/keyguard/AppearAnimationUtils.java
rename to packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java
index 9045fe3..441474d 100644
--- a/packages/Keyguard/src/com/android/keyguard/AppearAnimationUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2015 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.
@@ -14,13 +14,15 @@
  * limitations under the License
  */
 
-package com.android.keyguard;
+package com.android.settingslib.animation;
 
 import android.content.Context;
 import android.view.View;
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
 
+import com.android.settingslib.R;
+
 /**
  * A class to make nice appear transitions for views in a tabular layout.
  */
@@ -33,7 +35,7 @@
     private final AppearAnimationProperties mProperties = new AppearAnimationProperties();
     protected final float mDelayScale;
     private final long mDuration;
-    protected boolean mScaleTranslationWithRow;
+    protected RowTranslationScaler mRowTranslationScaler;
     protected boolean mAppearing;
 
     public AppearAnimationUtils(Context ctx) {
@@ -49,19 +51,18 @@
                 R.dimen.appear_y_translation_start) * translationScaleFactor;
         mDelayScale = delayScaleFactor;
         mDuration = duration;
-        mScaleTranslationWithRow = false;
         mAppearing = true;
     }
 
-    public void startAnimation(View[][] objects, final Runnable finishListener) {
-        startAnimation(objects, finishListener, this);
+    public void startAnimation2d(View[][] objects, final Runnable finishListener) {
+        startAnimation2d(objects, finishListener, this);
     }
 
     public void startAnimation(View[] objects, final Runnable finishListener) {
         startAnimation(objects, finishListener, this);
     }
 
-    public <T> void startAnimation(T[][] objects, final Runnable finishListener,
+    public <T> void startAnimation2d(T[][] objects, final Runnable finishListener,
             AppearAnimationCreator<T> creator) {
         AppearAnimationProperties properties = getDelays(objects);
         startAnimations(properties, objects, finishListener, creator);
@@ -86,8 +87,13 @@
             if (properties.maxDelayRowIndex == row && properties.maxDelayColIndex == 0) {
                 endRunnable = finishListener;
             }
+            float translationScale = mRowTranslationScaler != null
+                    ? mRowTranslationScaler.getRowTranslationScale(row, properties.delays.length)
+                    : 1f;
+            float translation = translationScale * mStartTranslation;
             creator.createAnimation(objects[row], delay, mDuration,
-                    mStartTranslation, true /* appearing */, mInterpolator, endRunnable);
+                    mAppearing ? translation : -translation,
+                    mAppearing, mInterpolator, endRunnable);
         }
     }
 
@@ -99,10 +105,10 @@
         }
         for (int row = 0; row < properties.delays.length; row++) {
             long[] columns = properties.delays[row];
-            float translation = mScaleTranslationWithRow
-                    ? (float) (Math.pow((properties.delays.length - row), 2)
-                    / properties.delays.length * mStartTranslation)
-                    : mStartTranslation;
+            float translationScale = mRowTranslationScaler != null
+                    ? mRowTranslationScaler.getRowTranslationScale(row, properties.delays.length)
+                    : 1f;
+            float translation = translationScale * mStartTranslation;
             for (int col = 0; col < columns.length; col++) {
                 long delay = columns[col];
                 Runnable endRunnable = null;
@@ -193,4 +199,8 @@
         public int maxDelayRowIndex;
         public int maxDelayColIndex;
     }
+
+    public interface RowTranslationScaler {
+        float getRowTranslationScale(int row, int numRows);
+    }
 }
diff --git a/packages/Keyguard/src/com/android/keyguard/DisappearAnimationUtils.java b/packages/SettingsLib/src/com/android/settingslib/animation/DisappearAnimationUtils.java
similarity index 65%
rename from packages/Keyguard/src/com/android/keyguard/DisappearAnimationUtils.java
rename to packages/SettingsLib/src/com/android/settingslib/animation/DisappearAnimationUtils.java
index 517d96a..a444ff0 100644
--- a/packages/Keyguard/src/com/android/keyguard/DisappearAnimationUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/animation/DisappearAnimationUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2015 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.
@@ -14,7 +14,7 @@
  * limitations under the License
  */
 
-package com.android.keyguard;
+package com.android.settingslib.animation;
 
 import android.content.Context;
 import android.view.animation.AnimationUtils;
@@ -28,17 +28,31 @@
     public DisappearAnimationUtils(Context ctx) {
         this(ctx, DEFAULT_APPEAR_DURATION,
                 1.0f, 1.0f,
-                AnimationUtils.loadInterpolator(ctx, android.R.interpolator.linear_out_slow_in));
+                AnimationUtils.loadInterpolator(ctx, android.R.interpolator.fast_out_linear_in));
     }
 
     public DisappearAnimationUtils(Context ctx, long duration, float translationScaleFactor,
             float delayScaleFactor, Interpolator interpolator) {
+        this(ctx, duration, translationScaleFactor, delayScaleFactor, interpolator,
+                ROW_TRANSLATION_SCALER);
+    }
+
+    public DisappearAnimationUtils(Context ctx, long duration, float translationScaleFactor,
+            float delayScaleFactor, Interpolator interpolator, RowTranslationScaler rowScaler) {
         super(ctx, duration, translationScaleFactor, delayScaleFactor, interpolator);
-        mScaleTranslationWithRow = true;
+        mRowTranslationScaler = rowScaler;
         mAppearing = false;
     }
 
     protected long calculateDelay(int row, int col) {
         return (long) ((row * 60 + col * (Math.pow(row, 0.4) + 0.4) * 10) * mDelayScale);
     }
+
+    private static final RowTranslationScaler ROW_TRANSLATION_SCALER = new RowTranslationScaler() {
+
+        @Override
+        public float getRowTranslationScale(int row, int numRows) {
+            return (float) (Math.pow((numRows - row), 2) / numRows);
+        }
+    };
 }
diff --git a/packages/SystemUI/res/layout/keyguard_bottom_area.xml b/packages/SystemUI/res/layout/keyguard_bottom_area.xml
index 5d0367e..48af565 100644
--- a/packages/SystemUI/res/layout/keyguard_bottom_area.xml
+++ b/packages/SystemUI/res/layout/keyguard_bottom_area.xml
@@ -33,7 +33,8 @@
         android:gravity="center_horizontal"
         android:textStyle="italic"
         android:textColor="#ffffff"
-        android:textAppearance="?android:attr/textAppearanceSmall" />
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:accessibilityLiveRegion="polite" />
 
     <FrameLayout
         android:id="@+id/preview_container"
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index de5639b..260d81b 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -135,8 +135,6 @@
     <!-- The maximum number of items to be displayed in quick settings -->
     <integer name="quick_settings_detail_max_item_count">7</integer>
 
-    <integer name="blinds_pop_duration_ms">10</integer>
-
     <!-- Should "4G" be shown instead of "LTE" when the network is NETWORK_TYPE_LTE? -->
     <bool name="config_show4GForLTE">true</bool>
 
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index d972111..a2a2e5f 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -850,7 +850,7 @@
     <string name="guest_notification_title">Guest user</string>
 
     <!-- Text of the notification shown to a new guest user [CHAR LIMIT=60] -->
-    <string name="guest_notification_text">Remove guest to delete apps and data</string>
+    <string name="guest_notification_text">To delete apps and data, remove guest user</string>
 
     <!-- Remove action in the notification shown to a new guest user [CHAR LIMIT=30] -->
     <string name="guest_notification_remove_action">REMOVE GUEST</string>
diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
index fece07f..b0e2afa 100644
--- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
@@ -25,6 +25,7 @@
 import android.os.Vibrator;
 import android.util.Log;
 import android.view.Gravity;
+import android.view.HapticFeedbackConstants;
 import android.view.MotionEvent;
 import android.view.ScaleGestureDetector;
 import android.view.ScaleGestureDetector.OnScaleGestureListener;
@@ -64,15 +65,6 @@
     // 2f: maximum brightness is stretching a 1U to 3U, or a 4U to 6U
     private static final float STRETCH_INTERVAL = 2f;
 
-    // level of glow for a touch, without overstretch
-    // overstretch fills the range (GLOW_BASE, 1.0]
-    private static final float GLOW_BASE = 0.5f;
-
-    private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
-            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
-            .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
-            .build();
-
     @SuppressWarnings("unused")
     private Context mContext;
 
@@ -94,13 +86,11 @@
     private float mLastSpanY;
     private int mTouchSlop;
     private float mLastMotionY;
-    private int mPopDuration;
     private float mPullGestureMinXSpan;
     private Callback mCallback;
     private ScaleGestureDetector mSGD;
     private ViewScaler mScaler;
     private ObjectAnimator mScaleAnimation;
-    private Vibrator mVibrator;
     private boolean mEnabled = true;
     private ExpandableView mResizedView;
     private float mCurrentHeight;
@@ -174,7 +164,6 @@
         mScaler = new ViewScaler();
         mGravity = Gravity.TOP;
         mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f);
-        mPopDuration = mContext.getResources().getInteger(R.integer.blinds_pop_duration_ms);
         mPullGestureMinXSpan = mContext.getResources().getDimension(R.dimen.pull_span_min);
 
         final ViewConfiguration configuration = ViewConfiguration.get(mContext);
@@ -452,7 +441,9 @@
                     }
 
                     if (!mHasPopped) {
-                        vibrate(mPopDuration);
+                        if (mEventSource != null) {
+                            mEventSource.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+                        }
                         mHasPopped = true;
                     }
 
@@ -600,16 +591,5 @@
     public void onlyObserveMovements(boolean onlyMovements) {
         mOnlyMovements = onlyMovements;
     }
-
-    /**
-     * Triggers haptic feedback.
-     */
-    private synchronized void vibrate(long duration) {
-        if (mVibrator == null) {
-            mVibrator = (android.os.Vibrator)
-                    mContext.getSystemService(Context.VIBRATOR_SERVICE);
-        }
-        mVibrator.vibrate(duration, VIBRATION_ATTRIBUTES);
-    }
 }
 
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index 3e122da..1e7ee98 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -116,7 +116,6 @@
                         | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
         WindowManager.LayoutParams lp = getLayoutParams();
         mWindowManager.addView(mView, lp);
-        mBar.getNavigationBarView().setDelegateView(mView);
         if (visible) {
             mView.show(true /* show */, false /* animate */);
         }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 25e3d10..49eb9b2 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -360,7 +360,7 @@
     }
 
     private void handleShowDetailTile(TileRecord r, boolean show) {
-        if ((mDetailRecord != null) == show) return;
+        if ((mDetailRecord != null) == show && mDetailRecord == r) return;
 
         if (show) {
             r.detailAdapter = r.tile.getDetailAdapter();
@@ -373,7 +373,8 @@
     }
 
     private void handleShowDetailImpl(Record r, boolean show, int x, int y) {
-        if ((mDetailRecord != null) == show) return;  // already in right state
+        boolean visibleDiff = (mDetailRecord != null) != show;
+        if (!visibleDiff && mDetailRecord == r) return;  // already in right state
         DetailAdapter detailAdapter = null;
         AnimatorListener listener = null;
         if (show) {
@@ -399,7 +400,7 @@
                     mContext.getString(detailAdapter.getTitle())));
             setDetailRecord(r);
             listener = mHideGridContentWhenDone;
-            if (r instanceof TileRecord) {
+            if (r instanceof TileRecord && visibleDiff) {
                 ((TileRecord) r).openingDetail = true;
             }
         } else {
@@ -411,7 +412,9 @@
         }
         sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
         fireShowingDetail(show ? detailAdapter : null);
-        mClipper.animateCircularClip(x, y, show, listener);
+        if (visibleDiff) {
+            mClipper.animateCircularClip(x, y, show, listener);
+        }
     }
 
     private void setGridContentVisibility(boolean visible) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index c0b3a9b..7cde44c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -21,15 +21,8 @@
 import android.animation.ObjectAnimator;
 import android.animation.ValueAnimator;
 import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapShader;
 import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
 import android.graphics.RectF;
-import android.graphics.Shader;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.view.View;
@@ -100,7 +93,6 @@
     private boolean mDark;
 
     private int mBgTint = 0;
-    private final int mRoundedRectCornerRadius;
 
     /**
      * Flag to indicate that the notification has been touched once and the second touch will
@@ -126,10 +118,8 @@
     private NotificationBackgroundView mBackgroundDimmed;
     private ObjectAnimator mBackgroundAnimator;
     private RectF mAppearAnimationRect = new RectF();
-    private PorterDuffColorFilter mAppearAnimationFilter;
     private float mAnimationTranslationY;
     private boolean mDrawingAppearAnimation;
-    private Paint mAppearPaint = new Paint();
     private ValueAnimator mAppearAnimator;
     private float mAppearAnimationFraction = -1.0f;
     private float mAppearAnimationTranslation;
@@ -151,9 +141,6 @@
         mLinearInterpolator = new LinearInterpolator();
         setClipChildren(false);
         setClipToPadding(false);
-        mAppearAnimationFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_ATOP);
-        mRoundedRectCornerRadius = getResources().getDimensionPixelSize(
-                R.dimen.notification_material_rounded_rect_radius);
         mLegacyColor = context.getColor(R.color.notification_legacy_background_color);
         mNormalColor = context.getColor(R.color.notification_material_background_color);
         mLowPriorityColor = context.getColor(
@@ -540,9 +527,7 @@
 
     private void startAppearAnimation(boolean isAppearing, float translationDirection, long delay,
             long duration, final Runnable onFinishedRunnable) {
-        if (mAppearAnimator != null) {
-            mAppearAnimator.cancel();
-        }
+        cancelAppearAnimation();
         mAnimationTranslationY = translationDirection * getActualHeight();
         if (mAppearAnimationFraction == -1.0f) {
             // not initialized yet, we start anew
@@ -613,6 +598,17 @@
         mAppearAnimator.start();
     }
 
+    private void cancelAppearAnimation() {
+        if (mAppearAnimator != null) {
+            mAppearAnimator.cancel();
+        }
+    }
+
+    public void cancelAppearDrawing() {
+        cancelAppearAnimation();
+        enableAppearDrawing(false);
+    }
+
     private void updateAppearRect() {
         float inverseFraction = (1.0f - mAppearAnimationFraction);
         float translationFraction = mCurrentAppearInterpolator.getInterpolation(inverseFraction);
@@ -652,20 +648,26 @@
     }
 
     private void updateAppearAnimationAlpha() {
-        int backgroundColor = getBgColor();
-        if (backgroundColor != -1) {
-            float contentAlphaProgress = mAppearAnimationFraction;
-            contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END);
-            contentAlphaProgress = Math.min(1.0f, contentAlphaProgress);
-            contentAlphaProgress = mCurrentAlphaInterpolator.getInterpolation(contentAlphaProgress);
-            int sourceColor = Color.argb((int) (255 * (1.0f - contentAlphaProgress)),
-                    Color.red(backgroundColor), Color.green(backgroundColor),
-                    Color.blue(backgroundColor));
-            mAppearAnimationFilter.setColor(sourceColor);
-            mAppearPaint.setColorFilter(mAppearAnimationFilter);
-        }
+        float contentAlphaProgress = mAppearAnimationFraction;
+        contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END);
+        contentAlphaProgress = Math.min(1.0f, contentAlphaProgress);
+        contentAlphaProgress = mCurrentAlphaInterpolator.getInterpolation(contentAlphaProgress);
+        setContentAlpha(contentAlphaProgress);
     }
 
+    private void setContentAlpha(float contentAlpha) {
+        int layerType = contentAlpha == 0.0f || contentAlpha == 1.0f ? LAYER_TYPE_NONE
+                : LAYER_TYPE_HARDWARE;
+        View contentView = getContentView();
+        int currentLayerType = contentView.getLayerType();
+        if (currentLayerType != layerType) {
+            contentView.setLayerType(layerType, null);
+        }
+        contentView.setAlpha(contentAlpha);
+    }
+
+    protected abstract View getContentView();
+
     private int getBgColor() {
         if (mBgTint != 0) {
             return mBgTint;
@@ -699,41 +701,24 @@
      */
     private void enableAppearDrawing(boolean enable) {
         if (enable != mDrawingAppearAnimation) {
-            if (enable) {
-                if (getWidth() == 0 || getActualHeight() == 0) {
-                    // TODO: This should not happen, but it can during expansion. Needs
-                    // investigation
-                    return;
-                }
-                Bitmap bitmap = Bitmap.createBitmap(getWidth(), getActualHeight(),
-                        Bitmap.Config.ARGB_8888);
-                Canvas canvas = new Canvas(bitmap);
-                draw(canvas);
-                mAppearPaint.setShader(new BitmapShader(bitmap, Shader.TileMode.CLAMP,
-                        Shader.TileMode.CLAMP));
-            } else {
-                mAppearPaint.setShader(null);
-            }
             mDrawingAppearAnimation = enable;
+            if (!enable) {
+                setContentAlpha(1.0f);
+            }
             invalidate();
         }
     }
 
     @Override
     protected void dispatchDraw(Canvas canvas) {
-        if (!mDrawingAppearAnimation) {
-            super.dispatchDraw(canvas);
-        } else {
-            drawAppearRect(canvas);
+        if (mDrawingAppearAnimation) {
+            canvas.save();
+            canvas.translate(0, mAppearAnimationTranslation);
         }
-    }
-
-    private void drawAppearRect(Canvas canvas) {
-        canvas.save();
-        canvas.translate(0, mAppearAnimationTranslation);
-        canvas.drawRoundRect(mAppearAnimationRect, mRoundedRectCornerRadius,
-                mRoundedRectCornerRadius, mAppearPaint);
-        canvas.restore();
+        super.dispatchDraw(canvas);
+        if (mDrawingAppearAnimation) {
+            canvas.restore();
+        }
     }
 
     public void setOnActivatedListener(OnActivatedListener onActivatedListener) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 4cce1a4..ef8c5db 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -1848,11 +1848,8 @@
             }
         }
 
-        if (onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0) {
-            mKeyguardIconOverflowContainer.setVisibility(View.VISIBLE);
-        } else {
-            mKeyguardIconOverflowContainer.setVisibility(View.GONE);
-        }
+        mStackScroller.updateOverflowContainerVisibility(onKeyguard
+                && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0);
 
         mStackScroller.changeViewPosition(mDismissView, mStackScroller.getChildCount() - 1);
         mStackScroller.changeViewPosition(mEmptyShadeView, mStackScroller.getChildCount() - 2);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java
deleted file mode 100644
index 2dc521e..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package com.android.systemui.statusbar;
-
-import android.app.StatusBarManager;
-import android.content.res.Resources;
-import android.graphics.RectF;
-import android.view.MotionEvent;
-import android.view.View;
-import com.android.systemui.R;
-import com.android.systemui.statusbar.phone.PhoneStatusBar;
-
-public class DelegateViewHelper {
-    private View mDelegateView;
-    private View mSourceView;
-    private PhoneStatusBar mBar;
-    private int[] mTempPoint = new int[2];
-    private float[] mDownPoint = new float[2];
-    private float mTriggerThreshhold;
-    private boolean mPanelShowing;
-
-    RectF mInitialTouch = new RectF();
-    private boolean mStarted;
-    private boolean mSwapXY = false;
-    private boolean mDisabled;
-
-    public DelegateViewHelper(View sourceView) {
-        setSourceView(sourceView);
-    }
-
-    public void setDelegateView(View view) {
-        mDelegateView = view;
-    }
-
-    public void setBar(PhoneStatusBar phoneStatusBar) {
-        mBar = phoneStatusBar;
-    }
-
-    public boolean onInterceptTouchEvent(MotionEvent event) {
-        if (mSourceView == null || mDelegateView == null || mBar.shouldDisableNavbarGestures()) {
-            return false;
-        }
-
-        mSourceView.getLocationOnScreen(mTempPoint);
-        final float sourceX = mTempPoint[0];
-        final float sourceY = mTempPoint[1];
-
-        final int action = event.getAction();
-        switch (action) {
-            case MotionEvent.ACTION_DOWN:
-                mPanelShowing = mDelegateView.getVisibility() == View.VISIBLE;
-                mDownPoint[0] = event.getX();
-                mDownPoint[1] = event.getY();
-                mStarted = mInitialTouch.contains(mDownPoint[0] + sourceX, mDownPoint[1] + sourceY);
-                break;
-        }
-
-        if (!mStarted) {
-            return false;
-        }
-
-        if (!mDisabled && !mPanelShowing && action == MotionEvent.ACTION_MOVE) {
-            final int historySize = event.getHistorySize();
-            for (int k = 0; k < historySize + 1; k++) {
-                float x = k < historySize ? event.getHistoricalX(k) : event.getX();
-                float y = k < historySize ? event.getHistoricalY(k) : event.getY();
-                final float distance = mSwapXY ? (mDownPoint[0] - x) : (mDownPoint[1] - y);
-                if (distance > mTriggerThreshhold) {
-                    mBar.invokeAssistGesture(false /* vibrate */);
-                    mPanelShowing = true;
-                    break;
-                }
-            }
-        }
-
-        if (action == MotionEvent.ACTION_DOWN) {
-            mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, true);
-        } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
-            mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, false);
-        }
-
-        mDelegateView.getLocationOnScreen(mTempPoint);
-        final float delegateX = mTempPoint[0];
-        final float delegateY = mTempPoint[1];
-
-        float deltaX = sourceX - delegateX;
-        float deltaY = sourceY - delegateY;
-        event.offsetLocation(deltaX, deltaY);
-        mDelegateView.dispatchTouchEvent(event);
-        event.offsetLocation(-deltaX, -deltaY);
-        return mPanelShowing;
-    }
-
-    public void abortCurrentGesture() {
-        if (mStarted) {
-            mStarted = false;
-            mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, false);
-        }
-    }
-
-    public void setSourceView(View view) {
-        mSourceView = view;
-        if (mSourceView != null) {
-            Resources r = mSourceView.getContext().getResources();
-            mTriggerThreshhold = r.getDimensionPixelSize(R.dimen.navigation_bar_min_swipe_distance);
-        }
-    }
-
-    /**
-     * Selects the initial touch region based on a list of views.  This is meant to be called by
-     * a container widget on children over which the initial touch should be detected.  Note this
-     * will compute a minimum bound that contains all specified views.
-     *
-     * @param views
-     */
-    public void setInitialTouchRegion(View ... views) {
-        RectF bounds = new RectF();
-        int p[] = new int[2];
-        for (int i = 0; i < views.length; i++) {
-            View view = views[i];
-            if (view == null) continue;
-            view.getLocationOnScreen(p);
-            if (i == 0) {
-                bounds.set(p[0], p[1], p[0] + view.getWidth(), p[1] + view.getHeight());
-            } else {
-                bounds.union(p[0], p[1], p[0] + view.getWidth(), p[1] + view.getHeight());
-            }
-        }
-        mInitialTouch.set(bounds);
-    }
-
-    /**
-     * When rotation is set to NO_SENSOR, then this allows swapping x/y for gesture detection
-     * @param swap
-     */
-    public void setSwapXY(boolean swap) {
-        mSwapXY = swap;
-    }
-
-    public void setDisabled(boolean disabled) {
-        mDisabled = disabled;
-    }
-}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index d444ea8..b88e5ca 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -856,6 +856,11 @@
     }
 
     @Override
+    protected View getContentView() {
+        return getShowingLayout();
+    }
+
+    @Override
     public void setActualHeight(int height, boolean notifyListeners) {
         super.setActualHeight(height, notifyListeners);
         int contentHeight = calculateContentHeightFromActualHeight(height);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
index a18fff2..d77e050 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
@@ -24,16 +24,21 @@
 import android.view.View;
 import android.view.ViewOutlineProvider;
 
+import com.android.systemui.R;
+
 /**
  * Like {@link ExpandableView}, but setting an outline for the height and clipping.
  */
 public abstract class ExpandableOutlineView extends ExpandableView {
 
     private final Rect mOutlineRect = new Rect();
+    protected final int mRoundedRectCornerRadius;
     private boolean mCustomOutline;
 
     public ExpandableOutlineView(Context context, AttributeSet attrs) {
         super(context, attrs);
+        mRoundedRectCornerRadius = getResources().getDimensionPixelSize(
+                R.dimen.notification_material_rounded_rect_radius);
         setOutlineProvider(new ViewOutlineProvider() {
             @Override
             public void getOutline(View view, Outline outline) {
@@ -43,7 +48,7 @@
                             getWidth(),
                             Math.max(getActualHeight(), mClipTopAmount));
                 } else {
-                    outline.setRect(mOutlineRect);
+                    outline.setRoundRect(mOutlineRect, mRoundedRectCornerRadius);
                 }
             }
         });
@@ -66,12 +71,14 @@
             setOutlineRect(rect.left, rect.top, rect.right, rect.bottom);
         } else {
             mCustomOutline = false;
+            setClipToOutline(false);
             invalidateOutline();
         }
     }
 
     protected void setOutlineRect(float left, float top, float right, float bottom) {
         mCustomOutline = true;
+        setClipToOutline(true);
 
         mOutlineRect.set((int) left, (int) top, (int) right, (int) bottom);
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index 3feec9e..03d0482 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -43,6 +43,7 @@
     private ArrayList<View> mMatchParentViews = new ArrayList<View>();
     private int mClipTopOptimization;
     private static Rect mClipRect = new Rect();
+    private boolean mWillBeGone;
 
     public ExpandableView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -339,6 +340,12 @@
         outRect.top += getTranslationY() + getClipTopAmount();
     }
 
+    @Override
+    public void getBoundsOnScreen(Rect outRect, boolean clipToParent) {
+        super.getBoundsOnScreen(outRect, clipToParent);
+        outRect.bottom = (int) (outRect.top + getActualHeight());
+    }
+
     public int getContentHeight() {
         return mActualHeight - getBottomDecorHeight();
     }
@@ -374,6 +381,14 @@
         updateClipping();
     }
 
+    public boolean willBeGone() {
+        return mWillBeGone;
+    }
+
+    public void setWillBeGone(boolean willBeGone) {
+        mWillBeGone = willBeGone;
+    }
+
     /**
      * A listener notifying when {@link #getActualHeight} changes.
      */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java
index 5fa7070..9653b67 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.view.View;
 import android.widget.TextView;
 
 import com.android.systemui.R;
@@ -32,6 +33,7 @@
     private NotificationOverflowIconsView mIconsView;
     private ViewInvertHelper mViewInvertHelper;
     private boolean mDark;
+    private View mContent;
 
     public NotificationOverflowContainer(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -43,7 +45,8 @@
         mIconsView = (NotificationOverflowIconsView) findViewById(R.id.overflow_icons_view);
         mIconsView.setMoreText((TextView) findViewById(R.id.more_text));
         mIconsView.setOverflowIndicator(findViewById(R.id.more_icon_overflow));
-        mViewInvertHelper = new ViewInvertHelper(findViewById(R.id.content),
+        mContent = findViewById(R.id.content);
+        mViewInvertHelper = new ViewInvertHelper(mContent,
                 NotificationPanelView.DOZE_ANIMATION_DURATION);
     }
 
@@ -59,6 +62,11 @@
         }
     }
 
+    @Override
+    protected View getContentView() {
+        return mContent;
+    }
+
     public NotificationOverflowIconsView getIconsView() {
         return mIconsView;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java
index 64d80cc..2f66c41 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java
@@ -32,7 +32,6 @@
     protected View mContent;
     private boolean mIsVisible;
     private boolean mAnimating;
-    private boolean mWillBeGone;
 
     public StackScrollerDecorView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -134,13 +133,5 @@
         mContent.animate().cancel();
     }
 
-    public boolean willBeGone() {
-        return mWillBeGone;
-    }
-
-    public void setWillBeGone(boolean willBeGone) {
-        mWillBeGone = willBeGone;
-    }
-
     protected abstract View findContentView();
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 636c511..f40f5016 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -47,7 +47,6 @@
 import android.widget.LinearLayout;
 
 import com.android.systemui.R;
-import com.android.systemui.statusbar.DelegateViewHelper;
 import com.android.systemui.statusbar.policy.DeadZone;
 import com.android.systemui.statusbar.policy.KeyButtonView;
 
@@ -79,7 +78,6 @@
     private Drawable mRecentLandIcon;
 
     private NavigationBarViewTaskSwitchHelper mTaskSwitchHelper;
-    private DelegateViewHelper mDelegateHelper;
     private DeadZone mDeadZone;
     private final NavigationBarTransitions mBarTransitions;
 
@@ -92,7 +90,6 @@
 
     private OnVerticalChangedListener mOnVerticalChangedListener;
     private boolean mIsLayoutRtl;
-    private boolean mDelegateIntercepted;
 
     private class NavTransitionListener implements TransitionListener {
         private boolean mBackTransitioning;
@@ -180,7 +177,6 @@
         mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
         mVertical = false;
         mShowMenu = false;
-        mDelegateHelper = new DelegateViewHelper(this);
         mTaskSwitchHelper = new NavigationBarViewTaskSwitchHelper(context);
 
         getIcons(res);
@@ -192,13 +188,8 @@
         return mBarTransitions;
     }
 
-    public void setDelegateView(View view) {
-        mDelegateHelper.setDelegateView(view);
-    }
-
     public void setBar(PhoneStatusBar phoneStatusBar) {
         mTaskSwitchHelper.setBar(phoneStatusBar);
-        mDelegateHelper.setBar(phoneStatusBar);
     }
 
     public void setOnVerticalChangedListener(OnVerticalChangedListener onVerticalChangedListener) {
@@ -208,44 +199,21 @@
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
-        initDownStates(event);
-        if (!mDelegateIntercepted && mTaskSwitchHelper.onTouchEvent(event)) {
+        if (mTaskSwitchHelper.onTouchEvent(event)) {
             return true;
         }
         if (mDeadZone != null && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
             mDeadZone.poke(event);
         }
-        if (mDelegateHelper != null && mDelegateIntercepted) {
-            boolean ret = mDelegateHelper.onInterceptTouchEvent(event);
-            if (ret) return true;
-        }
         return super.onTouchEvent(event);
     }
 
-    private void initDownStates(MotionEvent ev) {
-        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
-            mDelegateIntercepted = false;
-        }
-    }
-
     @Override
     public boolean onInterceptTouchEvent(MotionEvent event) {
-        initDownStates(event);
-        boolean intercept = mTaskSwitchHelper.onInterceptTouchEvent(event);
-        if (!intercept) {
-            mDelegateIntercepted = mDelegateHelper.onInterceptTouchEvent(event);
-            intercept = mDelegateIntercepted;
-        } else {
-            MotionEvent cancelEvent = MotionEvent.obtain(event);
-            cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
-            mDelegateHelper.onInterceptTouchEvent(cancelEvent);
-            cancelEvent.recycle();
-        }
-        return intercept;
+        return mTaskSwitchHelper.onInterceptTouchEvent(event);
     }
 
     public void abortCurrentGesture() {
-        mDelegateHelper.abortCurrentGesture();
         getHomeButton().abortCurrentGesture();
     }
 
@@ -461,10 +429,6 @@
             Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
         }
 
-        // swap to x coordinate if orientation is not in vertical
-        if (mDelegateHelper != null) {
-            mDelegateHelper.setSwapXY(mVertical);
-        }
         updateTaskSwitchHelper();
 
         setNavigationIconHints(mNavigationIconHints, true);
@@ -476,12 +440,6 @@
     }
 
     @Override
-    protected void onLayout(boolean changed, int l, int t, int r, int b) {
-        super.onLayout(changed, l, t, r, b);
-        mDelegateHelper.setInitialTouchRegion(getHomeButton(), getBackButton(), getRecentsButton());
-    }
-
-    @Override
     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
         if (DEBUG) Log.d(TAG, String.format(
                     "onSizeChanged: (%dx%d) old: (%dx%d)", w, h, oldw, oldh));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 9e1af82..a750572 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -487,6 +487,7 @@
         mStatusBar.dismissPopups();
         mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */,
                 true /* cancelAnimators */);
+        mNotificationStackScroller.resetScrollPosition();
     }
 
     public void closeQs() {
@@ -1716,12 +1717,16 @@
         float alphaQsExpansion = 1 - Math.min(1, getQsExpansionFraction() * 2);
         mKeyguardStatusBar.setAlpha(Math.min(getKeyguardContentsAlpha(), alphaQsExpansion)
                 * mKeyguardStatusBarAnimateAlpha);
+        mKeyguardStatusBar.setVisibility(mKeyguardStatusBar.getAlpha() != 0f ? VISIBLE : INVISIBLE);
         setQsTranslation(mQsExpansionHeight);
     }
 
     private void updateKeyguardBottomAreaAlpha() {
-        mKeyguardBottomArea.setAlpha(
-                Math.min(getKeyguardContentsAlpha(), 1 - getQsExpansionFraction()));
+        float alpha = Math.min(getKeyguardContentsAlpha(), 1 - getQsExpansionFraction());
+        mKeyguardBottomArea.setAlpha(alpha);
+        mKeyguardBottomArea.setImportantForAccessibility(alpha == 0f
+                ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
+                : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
     }
 
     private float getNotificationsTopY() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
index 54bd3e9..552a0b2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
@@ -81,10 +81,13 @@
     }
 
     public void setBouncerShowing(boolean showing) {
+        int important = showing ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
+                : IMPORTANT_FOR_ACCESSIBILITY_AUTO;
+
+        setImportantForAccessibility(important);
+
         if (mPanelHolder != null) {
-            mPanelHolder.setImportantForAccessibility(
-                    showing ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
-                            : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
+            mPanelHolder.setImportantForAccessibility(important);
         }
     }
 
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 a5b18f9..33e8e59 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -707,7 +707,7 @@
                         R.layout.status_bar_notification_keyguard_overflow, mStackScroller, false);
         mKeyguardIconOverflowContainer.setOnActivatedListener(this);
         mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener);
-        mStackScroller.addView(mKeyguardIconOverflowContainer);
+        mStackScroller.setOverflowContainer(mKeyguardIconOverflowContainer);
 
         SpeedBumpView speedBump = (SpeedBumpView) LayoutInflater.from(mContext).inflate(
                         R.layout.status_bar_notification_speed_bump, mStackScroller, false);
@@ -1861,6 +1861,9 @@
 
     public void setQsExpanded(boolean expanded) {
         mStatusBarWindowManager.setQsExpanded(expanded);
+        mKeyguardStatusView.setImportantForAccessibility(expanded
+                ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
+                : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
     }
 
     public boolean isGoingToNotificationShade() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
index 1460e5f..5cf6156 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
@@ -30,7 +30,7 @@
 import android.view.animation.AnimationUtils;
 import android.widget.FrameLayout;
 
-import com.android.keyguard.AppearAnimationUtils;
+import com.android.settingslib.animation.AppearAnimationUtils;
 import com.android.systemui.R;
 import com.android.systemui.qs.tiles.UserDetailItemView;
 import com.android.systemui.statusbar.phone.KeyguardStatusBarView;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index d8f6bcd..1bf4547 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -43,6 +43,7 @@
 import com.android.systemui.statusbar.ExpandableNotificationRow;
 import com.android.systemui.statusbar.ExpandableView;
 import com.android.systemui.statusbar.NotificationData;
+import com.android.systemui.statusbar.NotificationOverflowContainer;
 import com.android.systemui.statusbar.SpeedBumpView;
 import com.android.systemui.statusbar.StackScrollerDecorView;
 import com.android.systemui.statusbar.StatusBarState;
@@ -226,6 +227,7 @@
     private boolean mTrackingHeadsUp;
     private ScrimController mScrimController;
     private boolean mForceNoOverlappingRendering;
+    private NotificationOverflowContainer mOverflowContainer;
 
     public NotificationStackScrollLayout(Context context) {
         this(context, null);
@@ -1368,17 +1370,11 @@
         int childCount = getChildCount();
         int count = 0;
         for (int i = 0; i < childCount; i++) {
-            View child = getChildAt(i);
-            if (child.getVisibility() != View.GONE) {
+            ExpandableView child = (ExpandableView) getChildAt(i);
+            if (child.getVisibility() != View.GONE && !child.willBeGone()) {
                 count++;
             }
         }
-        if (mDismissView.willBeGone()) {
-            count--;
-        }
-        if (mEmptyShadeView.willBeGone()) {
-            count--;
-        }
         return count;
     }
 
@@ -2234,6 +2230,11 @@
         }
     }
 
+    public void resetScrollPosition() {
+        mScroller.abortAnimation();
+        mOwnScrollY = 0;
+    }
+
     private void setIsExpanded(boolean isExpanded) {
         boolean changed = isExpanded != mIsExpanded;
         mIsExpanded = isExpanded;
@@ -2291,6 +2292,10 @@
 
     public void onChildAnimationFinished() {
         requestChildrenUpdate();
+        runAnimationFinishedRunnables();
+    }
+
+    private void runAnimationFinishedRunnables() {
         for (Runnable runnable : mAnimationFinishedRunnables) {
             runnable.run();
         }
@@ -2348,6 +2353,7 @@
         if (mListener != null) {
             mListener.onChildLocationsChanged(this);
         }
+        runAnimationFinishedRunnables();
     }
 
     public void setSpeedBumpView(SpeedBumpView speedBumpView) {
@@ -2470,7 +2476,7 @@
                 mEmptyShadeView.setVisibility(newVisibility);
                 mEmptyShadeView.setWillBeGone(false);
                 updateContentHeight();
-                notifyHeightChangeListener(mDismissView);
+                notifyHeightChangeListener(mEmptyShadeView);
             } else {
                 Runnable onFinishedRunnable = new Runnable() {
                     @Override
@@ -2478,7 +2484,7 @@
                         mEmptyShadeView.setVisibility(GONE);
                         mEmptyShadeView.setWillBeGone(false);
                         updateContentHeight();
-                        notifyHeightChangeListener(mDismissView);
+                        notifyHeightChangeListener(mEmptyShadeView);
                     }
                 };
                 if (mAnimationsEnabled) {
@@ -2492,6 +2498,45 @@
         }
     }
 
+    public void setOverflowContainer(NotificationOverflowContainer overFlowContainer) {
+        mOverflowContainer = overFlowContainer;
+        addView(mOverflowContainer);
+    }
+
+    public void updateOverflowContainerVisibility(boolean visible) {
+        int oldVisibility = mOverflowContainer.willBeGone() ? GONE
+                : mOverflowContainer.getVisibility();
+        final int newVisibility = visible ? VISIBLE : GONE;
+        if (oldVisibility != newVisibility) {
+            Runnable onFinishedRunnable = new Runnable() {
+                @Override
+                public void run() {
+                    mOverflowContainer.setVisibility(newVisibility);
+                    mOverflowContainer.setWillBeGone(false);
+                    updateContentHeight();
+                    notifyHeightChangeListener(mOverflowContainer);
+                }
+            };
+            if (!mAnimationsEnabled || !mIsExpanded) {
+                mOverflowContainer.cancelAppearDrawing();
+                onFinishedRunnable.run();
+            } else if (newVisibility != GONE) {
+                mOverflowContainer.performAddAnimation(0,
+                        StackStateAnimator.ANIMATION_DURATION_STANDARD);
+                mOverflowContainer.setVisibility(newVisibility);
+                mOverflowContainer.setWillBeGone(false);
+                updateContentHeight();
+                notifyHeightChangeListener(mOverflowContainer);
+            } else {
+                mOverflowContainer.performRemoveAnimation(
+                        StackStateAnimator.ANIMATION_DURATION_STANDARD,
+                        0.0f,
+                        onFinishedRunnable);
+                mOverflowContainer.setWillBeGone(true);
+            }
+        }
+    }
+
     public void updateDismissView(boolean visible) {
         int oldVisibility = mDismissView.willBeGone() ? GONE : mDismissView.getVisibility();
         int newVisibility = visible ? VISIBLE : GONE;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
index feae590..a70ad43 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
@@ -210,7 +210,10 @@
         int oldVisibility = view.getVisibility();
         int newVisibility = becomesInvisible ? View.INVISIBLE : View.VISIBLE;
         if (newVisibility != oldVisibility) {
-            view.setVisibility(newVisibility);
+            if (!(view instanceof ExpandableView) || !((ExpandableView) view).willBeGone()) {
+                // We don't want views to change visibility when they are animating to GONE
+                view.setVisibility(newVisibility);
+            }
         }
 
         // apply yTranslation
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
index c31244c..c995c8e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java
@@ -285,6 +285,10 @@
         boolean scaleChanging = child.getScaleX() != viewState.scale;
         float childAlpha = child.getVisibility() == View.INVISIBLE ? 0.0f : child.getAlpha();
         boolean alphaChanging = viewState.alpha != childAlpha;
+        if (child instanceof ExpandableView) {
+            // We don't want views to change visibility when they are animating to GONE
+            alphaChanging &= !((ExpandableView) child).willBeGone();
+        }
 
         // start translationY animation
         if (yTranslationChanging) {
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 6e52358..25ca167 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -514,6 +514,7 @@
     boolean mDreamingLockscreen;
     boolean mDreamingSleepTokenNeeded;
     SleepToken mDreamingSleepToken;
+    SleepToken mScreenOffSleepToken;
     boolean mKeyguardSecure;
     boolean mKeyguardSecureIncludingHidden;
     volatile boolean mKeyguardOccluded;
@@ -5385,6 +5386,7 @@
     public void screenTurnedOff() {
         if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turned off...");
 
+        updateScreenOffSleepToken(true);
         synchronized (mLock) {
             mScreenOnEarly = false;
             mScreenOnFully = false;
@@ -5399,6 +5401,7 @@
     public void screenTurningOn(final ScreenOnListener screenOnListener) {
         if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on...");
 
+        updateScreenOffSleepToken(false);
         synchronized (mLock) {
             mScreenOnEarly = true;
             mScreenOnFully = false;
@@ -6021,6 +6024,20 @@
         } else {
             if (mDreamingSleepToken != null) {
                 mDreamingSleepToken.release();
+                mDreamingSleepToken = null;
+            }
+        }
+    }
+
+    private void updateScreenOffSleepToken(boolean acquire) {
+        if (acquire) {
+            if (mScreenOffSleepToken == null) {
+                mScreenOffSleepToken = mActivityManagerInternal.acquireSleepToken("ScreenOff");
+            }
+        } else {
+            if (mScreenOffSleepToken != null) {
+                mScreenOffSleepToken.release();
+                mScreenOffSleepToken = null;
             }
         }
     }
diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
index 7b58755..f02d109 100644
--- a/telephony/java/android/telephony/SignalStrength.java
+++ b/telephony/java/android/telephony/SignalStrength.java
@@ -469,7 +469,12 @@
     }
 
     /**
-     * Get signal level as an int from 0..4
+     * Retrieve an abstract level value for the overall signal strength.
+     *
+     * @return a single integer from 0 to 4 representing the general signal quality.
+     *     This may take into account many different radio technology inputs.
+     *     0 represents very poor signal strength
+     *     while 4 represents a very strong signal strength.
      */
     public int getLevel() {
         int level;
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 393888d..1cc275d 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -3501,13 +3501,13 @@
     /**
      * Values used to return status for hasCarrierPrivileges call.
      */
-    /** @hide */
+    /** @hide */ @SystemApi
     public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1;
-    /** @hide */
+    /** @hide */ @SystemApi
     public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0;
-    /** @hide */
+    /** @hide */ @SystemApi
     public static final int CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED = -1;
-    /** @hide */
+    /** @hide */ @SystemApi
     public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2;
 
     /**