Merge "Fix FloatingToolbar look and animation for RTL." into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index be6e873..5a9be90 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -23629,6 +23629,7 @@
     field public static final java.lang.String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources";
     field public static final java.lang.String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts";
     field public static final java.lang.String DISALLOW_MOUNT_PHYSICAL_MEDIA = "no_physical_media";
+    field public static final java.lang.String DISALLOW_NETWORK_RESET = "no_network_reset";
     field public static final java.lang.String DISALLOW_OUTGOING_BEAM = "no_outgoing_beam";
     field public static final java.lang.String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls";
     field public static final java.lang.String DISALLOW_REMOVE_USER = "no_remove_user";
@@ -34644,6 +34645,7 @@
     ctor public GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener, android.os.Handler);
     ctor public GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener, android.os.Handler, boolean);
     method public boolean isLongpressEnabled();
+    method public boolean onGenericMotionEvent(android.view.MotionEvent);
     method public boolean onTouchEvent(android.view.MotionEvent);
     method public void setIsLongpressEnabled(boolean);
     method public void setOnDoubleTapListener(android.view.GestureDetector.OnDoubleTapListener);
diff --git a/api/system-current.txt b/api/system-current.txt
index a072bd7..b4315fe 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -25552,6 +25552,7 @@
     field public static final java.lang.String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources";
     field public static final java.lang.String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts";
     field public static final java.lang.String DISALLOW_MOUNT_PHYSICAL_MEDIA = "no_physical_media";
+    field public static final java.lang.String DISALLOW_NETWORK_RESET = "no_network_reset";
     field public static final java.lang.String DISALLOW_OUTGOING_BEAM = "no_outgoing_beam";
     field public static final java.lang.String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls";
     field public static final java.lang.String DISALLOW_REMOVE_USER = "no_remove_user";
@@ -36902,6 +36903,7 @@
     ctor public GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener, android.os.Handler);
     ctor public GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener, android.os.Handler, boolean);
     method public boolean isLongpressEnabled();
+    method public boolean onGenericMotionEvent(android.view.MotionEvent);
     method public boolean onTouchEvent(android.view.MotionEvent);
     method public void setIsLongpressEnabled(boolean);
     method public void setOnDoubleTapListener(android.view.GestureDetector.OnDoubleTapListener);
diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java
index 14bfac5..579634f 100644
--- a/core/java/android/content/res/ColorStateList.java
+++ b/core/java/android/content/res/ColorStateList.java
@@ -382,6 +382,14 @@
                     defaultAlphaMod = 1.0f;
                 }
 
+                // Extract the theme attributes, if any, before attempting to
+                // read from the typed array. This prevents a crash if we have
+                // unresolved attrs.
+                themeAttrsList[i] = a.extractThemeAttrs(themeAttrsList[i]);
+                if (themeAttrsList[i] != null) {
+                    hasUnresolvedAttrs = true;
+                }
+
                 final int baseColor = a.getColor(
                         R.styleable.ColorStateListItem_color, mColors[i]);
                 final float alphaMod = a.getFloat(
@@ -391,12 +399,6 @@
                 // Account for any configuration changes.
                 mChangingConfigurations |= a.getChangingConfigurations();
 
-                // Extract the theme attributes, if any.
-                themeAttrsList[i] = a.extractThemeAttrs(themeAttrsList[i]);
-                if (themeAttrsList[i] != null) {
-                    hasUnresolvedAttrs = true;
-                }
-
                 a.recycle();
             }
         }
diff --git a/core/java/android/hardware/camera2/CameraCaptureSession.java b/core/java/android/hardware/camera2/CameraCaptureSession.java
index b3e7cfc..c22ee5f 100644
--- a/core/java/android/hardware/camera2/CameraCaptureSession.java
+++ b/core/java/android/hardware/camera2/CameraCaptureSession.java
@@ -654,16 +654,22 @@
 
         /**
          * This method is called when the camera device has started capturing
-         * the output image for the request, at the beginning of image exposure.
+         * the output image for the request, at the beginning of image exposure, or
+         * when the camera device has started processing an input image for a reprocess
+         * request.
          *
-         * <p>This callback is invoked right as the capture of a frame begins,
-         * so it is the most appropriate time for playing a shutter sound,
-         * or triggering UI indicators of capture.</p>
+         * <p>For a regular capture request, this callback is invoked right as
+         * the capture of a frame begins, so it is the most appropriate time
+         * for playing a shutter sound, or triggering UI indicators of capture.</p>
          *
          * <p>The request that is being used for this capture is provided, along
-         * with the actual timestamp for the start of exposure. This timestamp
-         * matches the timestamp that will be included in
-         * {@link CaptureResult#SENSOR_TIMESTAMP the result timestamp field},
+         * with the actual timestamp for the start of exposure. For a reprocess
+         * request, this timestamp will be the input image's start of exposure
+         * which matches {@link CaptureResult#SENSOR_TIMESTAMP the result timestamp field}
+         * of the {@link TotalCaptureResult} that was used to
+         * {@link CameraDevice#createReprocessCaptureRequest create the reprocess request}.
+         * This timestamp matches the timestamps that will be
+         * included in {@link CaptureResult#SENSOR_TIMESTAMP the result timestamp field},
          * and in the buffers sent to each output Surface. These buffer
          * timestamps are accessible through, for example,
          * {@link android.media.Image#getTimestamp() Image.getTimestamp()} or
@@ -679,7 +685,9 @@
          *
          * @param session the session returned by {@link CameraDevice#createCaptureSession}
          * @param request the request for the capture that just begun
-         * @param timestamp the timestamp at start of capture, in nanoseconds.
+         * @param timestamp the timestamp at start of capture for a regular request, or
+         *                  the timestamp at the input image's start of capture for a
+         *                  reprocess request, in nanoseconds.
          * @param frameNumber the frame number for this capture
          *
          * @see android.media.MediaActionSound
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 4fe257c..d5867a9 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -1068,20 +1068,35 @@
 
     /**
      * <p>The correction coefficients to correct for this camera device's
-     * radial lens distortion.</p>
-     * <p>Three cofficients <code>[kappa_1, kappa_2, kappa_3]</code> that
-     * can be used to correct the lens's radial geometric
-     * distortion with the mapping equations:</p>
-     * <pre><code> x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 )
-     * y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 )
+     * radial and tangential lens distortion.</p>
+     * <p>Three radial distortion coefficients <code>[kappa_1, kappa_2,
+     * kappa_3]</code> and two tangential distortion coefficients
+     * <code>[kappa_4, kappa_5]</code> that can be used to correct the
+     * lens's geometric distortion with the mapping equations:</p>
+     * <pre><code> x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+     *        kappa_4 * (2 * x_i * y_i) + kappa_5 * ( r^2 + 2 * x_i^2 )
+     *  y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+     *        kappa_5 * (2 * x_i * y_i) + kappa_4 * ( r^2 + 2 * y_i^2 )
      * </code></pre>
-     * <p>where <code>[x_i, y_i]</code> are normalized coordinates with <code>(0,0)</code>
-     * at the lens optical center, and <code>[-1, 1]</code> are the edges of
-     * the active pixel array; and where <code>[x_c, y_c]</code> are the
-     * corrected normalized coordinates with radial distortion
-     * removed; and <code>r^2 = x_i^2 + y_i^2</code>.</p>
+     * <p>Here, <code>[x_c, y_c]</code> are the coordinates to sample in the
+     * input image that correspond to the pixel values in the
+     * corrected image at the coordinate <code>[x_i, y_i]</code>:</p>
+     * <pre><code> correctedImage(x_i, y_i) = sample_at(x_c, y_c, inputImage)
+     * </code></pre>
+     * <p>The pixel coordinates are defined in a normalized
+     * coordinate system related to the
+     * android.lens.intrinsicCalibration calibration fields.
+     * Both <code>[x_i, y_i]</code> and <code>[x_c, y_c]</code> have <code>(0,0)</code> at the
+     * lens optical center <code>[c_x, c_y]</code>. The maximum magnitudes
+     * of both x and y coordinates are normalized to be 1 at the
+     * edge further from the optical center, so the range
+     * for both dimensions is <code>-1 &lt;= x &lt;= 1</code>.</p>
+     * <p>Finally, <code>r</code> represents the radial distance from the
+     * optical center, <code>r^2 = x_i^2 + y_i^2</code>, and its magnitude
+     * is therefore no larger than <code>|r| &lt;= sqrt(2)</code>.</p>
+     * <p>The distortion model used is the Brown-Conrady model.</p>
      * <p><b>Units</b>:
-     * Coefficients for a 6th-degree even radial polynomial.</p>
+     * Unitless coefficients.</p>
      * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
      */
     @PublicKey
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index f4017d0..df6c986 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -2649,20 +2649,35 @@
 
     /**
      * <p>The correction coefficients to correct for this camera device's
-     * radial lens distortion.</p>
-     * <p>Three cofficients <code>[kappa_1, kappa_2, kappa_3]</code> that
-     * can be used to correct the lens's radial geometric
-     * distortion with the mapping equations:</p>
-     * <pre><code> x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 )
-     * y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 )
+     * radial and tangential lens distortion.</p>
+     * <p>Three radial distortion coefficients <code>[kappa_1, kappa_2,
+     * kappa_3]</code> and two tangential distortion coefficients
+     * <code>[kappa_4, kappa_5]</code> that can be used to correct the
+     * lens's geometric distortion with the mapping equations:</p>
+     * <pre><code> x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+     *        kappa_4 * (2 * x_i * y_i) + kappa_5 * ( r^2 + 2 * x_i^2 )
+     *  y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+     *        kappa_5 * (2 * x_i * y_i) + kappa_4 * ( r^2 + 2 * y_i^2 )
      * </code></pre>
-     * <p>where <code>[x_i, y_i]</code> are normalized coordinates with <code>(0,0)</code>
-     * at the lens optical center, and <code>[-1, 1]</code> are the edges of
-     * the active pixel array; and where <code>[x_c, y_c]</code> are the
-     * corrected normalized coordinates with radial distortion
-     * removed; and <code>r^2 = x_i^2 + y_i^2</code>.</p>
+     * <p>Here, <code>[x_c, y_c]</code> are the coordinates to sample in the
+     * input image that correspond to the pixel values in the
+     * corrected image at the coordinate <code>[x_i, y_i]</code>:</p>
+     * <pre><code> correctedImage(x_i, y_i) = sample_at(x_c, y_c, inputImage)
+     * </code></pre>
+     * <p>The pixel coordinates are defined in a normalized
+     * coordinate system related to the
+     * android.lens.intrinsicCalibration calibration fields.
+     * Both <code>[x_i, y_i]</code> and <code>[x_c, y_c]</code> have <code>(0,0)</code> at the
+     * lens optical center <code>[c_x, c_y]</code>. The maximum magnitudes
+     * of both x and y coordinates are normalized to be 1 at the
+     * edge further from the optical center, so the range
+     * for both dimensions is <code>-1 &lt;= x &lt;= 1</code>.</p>
+     * <p>Finally, <code>r</code> represents the radial distance from the
+     * optical center, <code>r^2 = x_i^2 + y_i^2</code>, and its magnitude
+     * is therefore no larger than <code>|r| &lt;= sqrt(2)</code>.</p>
+     * <p>The distortion model used is the Brown-Conrady model.</p>
      * <p><b>Units</b>:
-     * Coefficients for a 6th-degree even radial polynomial.</p>
+     * Unitless coefficients.</p>
      * <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
      */
     @PublicKey
@@ -2988,6 +3003,10 @@
      * timestamps measure time in the same timebase as {@link android.os.SystemClock#elapsedRealtimeNanos }, and they can
      * be compared to other timestamps from other subsystems that
      * are using that base.</p>
+     * <p>For reprocessing, the timestamp will match the start of exposure of
+     * the input image, i.e. {@link CaptureResult#SENSOR_TIMESTAMP the
+     * timestamp} in the TotalCaptureResult that was used to create the
+     * reprocess capture request.</p>
      * <p><b>Units</b>: Nanoseconds</p>
      * <p><b>Range of valid values:</b><br>
      * &gt; 0</p>
diff --git a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
index 2de846c..943e421 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
@@ -752,12 +752,14 @@
                     CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES          ,
                     CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE                   ,
                     CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP                    ,
+                    CameraCharacteristics.CONTROL_AE_LOCK_AVAILABLE                       ,
                     CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES                      ,
                     CameraCharacteristics.CONTROL_AVAILABLE_EFFECTS                       ,
                     CameraCharacteristics.CONTROL_AVAILABLE_MODES                         ,
                     CameraCharacteristics.CONTROL_AVAILABLE_SCENE_MODES                   ,
                     CameraCharacteristics.CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES     ,
                     CameraCharacteristics.CONTROL_AWB_AVAILABLE_MODES                     ,
+                    CameraCharacteristics.CONTROL_AWB_LOCK_AVAILABLE                      ,
                     CameraCharacteristics.CONTROL_MAX_REGIONS                             ,
                     CameraCharacteristics.FLASH_INFO_AVAILABLE                            ,
                     CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL                   ,
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index dfd523a..50eed3e 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -685,8 +685,6 @@
         final String bootimage = SystemProperties.get("ro.bootimage.build.fingerprint");
         final String requiredBootloader = SystemProperties.get("ro.build.expect.bootloader");
         final String currentBootloader = SystemProperties.get("ro.bootloader");
-        final String requiredRecovery = SystemProperties.get("ro.expect.recovery_id");
-        final String currentRecovery = SystemProperties.get("ro.recovery_id");
         final String requiredRadio = SystemProperties.get("ro.build.expect.baseband");
         final String currentRadio = SystemProperties.get("gsm.version.baseband");
 
@@ -703,6 +701,7 @@
             }
         }
 
+        /* TODO: Figure out issue with checks failing
         if (!TextUtils.isEmpty(bootimage)) {
             if (!Objects.equals(system, bootimage)) {
                 Slog.e(TAG, "Mismatched fingerprints; system reported " + system
@@ -719,15 +718,6 @@
             }
         }
 
-        if (!TextUtils.isEmpty(requiredRecovery)) {
-            if (!Objects.equals(currentRecovery, requiredRecovery)) {
-                Slog.e(TAG, "Mismatched recovery version: build requires " + requiredRecovery
-                        + " but runtime reports " + currentRecovery);
-                return false;
-            }
-        }
-
-        /* TODO: uncomment when new bootloader lands b/20860620
         if (!TextUtils.isEmpty(requiredRadio)) {
             if (!Objects.equals(currentRadio, requiredRadio)) {
                 Slog.e(TAG, "Mismatched radio version: build requires " + requiredRadio
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index a81b83f..ef7e747 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -200,6 +200,20 @@
     public static final String DISALLOW_CONFIG_TETHERING = "no_config_tethering";
 
     /**
+     * Specifies if a user is disallowed from resetting network settings
+     * from Settings. This can only be set by device owners and profile owners on the primary user.
+     * The default value is <code>false</code>.
+     * <p/>This restriction has no effect on secondary users and managed profiles since only the
+     * primary user can reset the network settings of the device.
+     *
+     * <p/>Key for user restrictions.
+     * <p/>Type: Boolean
+     * @see #setUserRestrictions(Bundle)
+     * @see #getUserRestrictions()
+     */
+    public static final String DISALLOW_NETWORK_RESET = "no_network_reset";
+
+    /**
      * Specifies if a user is disallowed from factory resetting
      * from Settings. This can only be set by device owners and profile owners on the primary user.
      * The default value is <code>false</code>.
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index b93a4a5..8952807 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -18,7 +18,6 @@
 
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
-import android.os.SystemProperties;
 import android.view.WindowInsets;
 
 import com.android.internal.R;
@@ -161,9 +160,11 @@
         final Rect mOverscanInsets = new Rect();
         final Rect mContentInsets = new Rect();
         final Rect mStableInsets = new Rect();
+        final Rect mOutsets = new Rect();
         final Rect mDispatchedOverscanInsets = new Rect();
         final Rect mDispatchedContentInsets = new Rect();
         final Rect mDispatchedStableInsets = new Rect();
+        final Rect mDispatchedOutsets = new Rect();
         final Rect mFinalSystemInsets = new Rect();
         final Rect mFinalStableInsets = new Rect();
         final Configuration mConfiguration = new Configuration();
@@ -268,7 +269,7 @@
         final BaseIWindow mWindow = new BaseIWindow() {
             @Override
             public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
-                    Rect visibleInsets, Rect stableInsets, boolean reportDraw,
+                    Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
                     Configuration newConfig) {
                 Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
                         reportDraw ? 1 : 0);
@@ -658,30 +659,35 @@
                         mInputEventReceiver = new WallpaperInputEventReceiver(
                                 mInputChannel, Looper.myLooper());
                     }
-                    
+
                     mSurfaceHolder.mSurfaceLock.lock();
                     mDrawingAllowed = true;
 
                     if (!fixedSize) {
                         mLayout.surfaceInsets.set(mIWallpaperEngine.mDisplayPadding);
+                        mLayout.surfaceInsets.left += mOutsets.left;
+                        mLayout.surfaceInsets.top += mOutsets.top;
+                        mLayout.surfaceInsets.right += mOutsets.right;
+                        mLayout.surfaceInsets.bottom += mOutsets.bottom;
                     } else {
                         mLayout.surfaceInsets.set(0, 0, 0, 0);
                     }
                     final int relayoutResult = mSession.relayout(
                         mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                             View.VISIBLE, 0, mWinFrame, mOverscanInsets, mContentInsets,
-                            mVisibleInsets, mStableInsets, mConfiguration, mSurfaceHolder.mSurface);
+                            mVisibleInsets, mStableInsets, mOutsets, mConfiguration,
+                            mSurfaceHolder.mSurface);
 
                     if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
                             + ", frame=" + mWinFrame);
-                    
+
                     int w = mWinFrame.width();
                     int h = mWinFrame.height();
 
                     if (!fixedSize) {
                         final Rect padding = mIWallpaperEngine.mDisplayPadding;
-                        w += padding.left + padding.right;
-                        h += padding.top + padding.bottom;
+                        w += padding.left + padding.right + mOutsets.left + mOutsets.right;
+                        h += padding.top + padding.bottom + mOutsets.top + mOutsets.bottom;
                         mOverscanInsets.left += padding.left;
                         mOverscanInsets.top += padding.top;
                         mOverscanInsets.right += padding.right;
@@ -705,9 +711,14 @@
                         mCurHeight = h;
                     }
 
+                    if (DEBUG) {
+                        Log.v(TAG, "Wallpaper size has changed: (" + mCurWidth + ", " + mCurHeight);
+                    }
+
                     insetsChanged |= !mDispatchedOverscanInsets.equals(mOverscanInsets);
                     insetsChanged |= !mDispatchedContentInsets.equals(mContentInsets);
                     insetsChanged |= !mDispatchedStableInsets.equals(mStableInsets);
+                    insetsChanged |= !mDispatchedOutsets.equals(mOutsets);
 
                     mSurfaceHolder.setSurfaceFrameSize(w, h);
                     mSurfaceHolder.mSurfaceLock.unlock();
@@ -767,14 +778,21 @@
 
                         if (insetsChanged) {
                             mDispatchedOverscanInsets.set(mOverscanInsets);
+                            mDispatchedOverscanInsets.left += mOutsets.left;
+                            mDispatchedOverscanInsets.top += mOutsets.top;
+                            mDispatchedOverscanInsets.right += mOutsets.right;
+                            mDispatchedOverscanInsets.bottom += mOutsets.bottom;
                             mDispatchedContentInsets.set(mContentInsets);
                             mDispatchedStableInsets.set(mStableInsets);
+                            mDispatchedOutsets.set(mOutsets);
                             mFinalSystemInsets.set(mDispatchedOverscanInsets);
                             mFinalStableInsets.set(mDispatchedStableInsets);
-                            mFinalSystemInsets.bottom = mIWallpaperEngine.mDisplayPadding.bottom;
                             WindowInsets insets = new WindowInsets(mFinalSystemInsets,
                                     null, mFinalStableInsets,
                                     getResources().getConfiguration().isScreenRound());
+                            if (DEBUG) {
+                                Log.v(TAG, "dispatching insets=" + insets);
+                            }
                             onApplyWindowInsets(insets);
                         }
 
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index f7027f9..f176240 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -1121,7 +1121,6 @@
      * closest to the specified horizontal position.
      */
     public int getOffsetForHorizontal(int line, float horiz) {
-        // TODO: use Paint.getOffsetForAdvance to avoid binary search
         int max = getLineEnd(line) - 1;
         int min = getLineStart(line);
         Directions dirs = getLineDirections(line);
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java
index 605b91d..479242c 100644
--- a/core/java/android/text/TextLine.java
+++ b/core/java/android/text/TextLine.java
@@ -739,14 +739,16 @@
 
         float ret = 0;
 
+        int contextLen = contextEnd - contextStart;
         if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineColor != 0 || runIsRtl))) {
             if (mCharsValid) {
-                ret = wp.getRunAdvance(mChars, start, contextEnd, contextStart, contextEnd,
-                        runIsRtl, end);
+                ret = wp.getTextRunAdvances(mChars, start, runLen,
+                        contextStart, contextLen, runIsRtl, null, 0);
             } else {
                 int delta = mStart;
-                ret = wp.getRunAdvance(mText, delta + start, delta + contextEnd,
-                        delta + contextStart, delta + contextEnd, runIsRtl, delta + end);
+                ret = wp.getTextRunAdvances(mText, delta + start,
+                        delta + end, delta + contextStart, delta + contextEnd,
+                        runIsRtl, null, 0);
             }
         }
 
diff --git a/core/java/android/view/GestureDetector.java b/core/java/android/view/GestureDetector.java
index b8544c6..ff0af6b 100644
--- a/core/java/android/view/GestureDetector.java
+++ b/core/java/android/view/GestureDetector.java
@@ -32,6 +32,9 @@
  *  <li>In the {@link View#onTouchEvent(MotionEvent)} method ensure you call
  *          {@link #onTouchEvent(MotionEvent)}. The methods defined in your callback
  *          will be executed when the events occur.
+ *  <li>If listening for {@link OnStylusButtonPressListener#onStylusButtonPress(MotionEvent)}
+ *          you must call {@link #onGenericMotionEvent(MotionEvent)}
+ *          in {@link View#onGenericMotionEvent(MotionEvent)}.
  * </ul>
  */
 public class GestureDetector {
@@ -149,12 +152,14 @@
     }
 
     /**
-     * The listener that is used to notify when a stylus button press occurs.
+     * The listener that is used to notify when a stylus button press occurs. When listening for a
+     * stylus button press ensure that you call {@link #onGenericMotionEvent(MotionEvent)} in
+     * {@link View#onGenericMotionEvent(MotionEvent)}.
      */
     public interface OnStylusButtonPressListener {
         /**
          * Notified when a stylus button press occurs. This is when the stylus
-         * is touching the screen and the {@value MotionEvent#BUTTON_SECONDARY}
+         * is touching the screen and the {@value MotionEvent#BUTTON_STYLUS_PRIMARY}
          * is pressed.
          *
          * @param e The motion event that occurred during the stylus button
@@ -241,6 +246,7 @@
     private boolean mInStylusButtonPress;
     private boolean mAlwaysInTapRegion;
     private boolean mAlwaysInBiggerTapRegion;
+    private boolean mIgnoreNextUpEvent;
 
     private MotionEvent mCurrentDownEvent;
     private MotionEvent mPreviousUpEvent;
@@ -552,18 +558,7 @@
             break;
 
         case MotionEvent.ACTION_DOWN:
-            if (mStylusButtonListener != null
-                    && ev.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS
-                    && (ev.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) {
-                if (mStylusButtonListener.onStylusButtonPress(ev)) {
-                    mInStylusButtonPress = true;
-                    handled = true;
-                    mHandler.removeMessages(LONG_PRESS);
-                    mHandler.removeMessages(TAP);
-                }
-            }
-
-            if (mDoubleTapListener != null && !mInStylusButtonPress) {
+            if (mDoubleTapListener != null) {
                 boolean hadTapMessage = mHandler.hasMessages(TAP);
                 if (hadTapMessage) mHandler.removeMessages(TAP);
                 if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage &&
@@ -592,7 +587,7 @@
             mInLongPress = false;
             mDeferConfirmSingleTap = false;
 
-            if (mIsLongpressEnabled && !mInStylusButtonPress) {
+            if (mIsLongpressEnabled) {
                 mHandler.removeMessages(LONG_PRESS);
                 mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime()
                         + TAP_TIMEOUT + LONGPRESS_TIMEOUT);
@@ -602,16 +597,6 @@
             break;
 
         case MotionEvent.ACTION_MOVE:
-            if (mStylusButtonListener != null && !mInStylusButtonPress && !mInLongPress
-                    && ev.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS
-                    && (ev.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) {
-                if (mStylusButtonListener.onStylusButtonPress(ev)) {
-                    mInStylusButtonPress = true;
-                    handled = true;
-                    mHandler.removeMessages(LONG_PRESS);
-                    mHandler.removeMessages(TAP);
-                }
-            }
             if (mInLongPress || mInStylusButtonPress) {
                 break;
             }
@@ -652,15 +637,12 @@
             } else if (mInLongPress) {
                 mHandler.removeMessages(TAP);
                 mInLongPress = false;
-            } else if (mInStylusButtonPress) {
-                mHandler.removeMessages(TAP);
-                mInStylusButtonPress = false;
-            } else if (mAlwaysInTapRegion) {
+            } else if (mAlwaysInTapRegion && !mIgnoreNextUpEvent) {
                 handled = mListener.onSingleTapUp(ev);
                 if (mDeferConfirmSingleTap && mDoubleTapListener != null) {
                     mDoubleTapListener.onSingleTapConfirmed(ev);
                 }
-            } else {
+            } else if (!mIgnoreNextUpEvent) {
 
                 // A fling must travel the minimum tap distance
                 final VelocityTracker velocityTracker = mVelocityTracker;
@@ -687,6 +669,7 @@
             }
             mIsDoubleTapping = false;
             mDeferConfirmSingleTap = false;
+            mIgnoreNextUpEvent = false;
             mHandler.removeMessages(SHOW_PRESS);
             mHandler.removeMessages(LONG_PRESS);
             break;
@@ -702,6 +685,43 @@
         return handled;
     }
 
+    /**
+     * Analyzes the given generic motion event and if applicable triggers the
+     * appropriate callbacks on the {@link OnGestureListener} supplied.
+     *
+     * @param ev The current motion event.
+     * @return true if the {@link OnGestureListener} consumed the event,
+     *              else false.
+     */
+    public boolean onGenericMotionEvent(MotionEvent ev) {
+        if (mInputEventConsistencyVerifier != null) {
+            mInputEventConsistencyVerifier.onGenericMotionEvent(ev, 0);
+        }
+
+        switch (ev.getActionMasked()) {
+            case MotionEvent.ACTION_BUTTON_PRESS:
+                if (mStylusButtonListener != null && !mInStylusButtonPress && !mInLongPress
+                        && ev.getActionButton() == MotionEvent.BUTTON_STYLUS_PRIMARY) {
+                    if (mStylusButtonListener.onStylusButtonPress(ev)) {
+                        mInStylusButtonPress = true;
+                        mHandler.removeMessages(LONG_PRESS);
+                        mHandler.removeMessages(TAP);
+                        return true;
+                    }
+                }
+                break;
+
+            case MotionEvent.ACTION_BUTTON_RELEASE:
+                if (mInStylusButtonPress
+                        && ev.getActionButton() == MotionEvent.BUTTON_STYLUS_PRIMARY) {
+                    mInStylusButtonPress = false;
+                    mIgnoreNextUpEvent = true;
+                }
+                break;
+        }
+        return false;
+    }
+
     private void cancel() {
         mHandler.removeMessages(SHOW_PRESS);
         mHandler.removeMessages(LONG_PRESS);
@@ -715,6 +735,7 @@
         mDeferConfirmSingleTap = false;
         mInLongPress = false;
         mInStylusButtonPress = false;
+        mIgnoreNextUpEvent = false;
     }
 
     private void cancelTaps() {
@@ -727,6 +748,7 @@
         mDeferConfirmSingleTap = false;
         mInLongPress = false;
         mInStylusButtonPress = false;
+        mIgnoreNextUpEvent = false;
     }
 
     private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp,
diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl
index 0fefdc7..9cf3759 100644
--- a/core/java/android/view/IWindow.aidl
+++ b/core/java/android/view/IWindow.aidl
@@ -46,7 +46,7 @@
     void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);
 
     void resized(in Rect frame, in Rect overscanInsets, in Rect contentInsets,
-            in Rect visibleInsets, in Rect stableInsets, boolean reportDraw,
+            in Rect visibleInsets, in Rect stableInsets, in Rect outsets, boolean reportDraw,
             in Configuration newConfig);
     void moved(int newX, int newY);
     void dispatchAppVisibility(boolean visible);
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index fc0148f..19253dd 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -79,11 +79,13 @@
      * contents to make sure the user can see it.  This is different than
      * <var>outContentInsets</var> in that these insets change transiently,
      * so complex relayout of the window should not happen based on them.
+     * @param outOutsets Rect in which is placed the dead area of the screen that we would like to
+     * treat as real display. Example of such area is a chin in some models of wearable devices.
      * @param outConfiguration New configuration of window, if it is now
      * becoming visible and the global configuration has changed since it
      * was last displayed.
      * @param outSurface Object in which is placed the new display surface.
-     * 
+     *
      * @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_SHOW_FOCUS},
      * {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
      */
@@ -91,7 +93,7 @@
             int requestedWidth, int requestedHeight, int viewVisibility,
             int flags, out Rect outFrame, out Rect outOverscanInsets,
             out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
-            out Configuration outConfig, out Surface outSurface);
+            out Rect outOutsets, out Configuration outConfig, out Surface outSurface);
 
     /**
      * If a call to relayout() asked to have the surface destroy deferred,
diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java
index b055efe..7b0f1fb 100644
--- a/core/java/android/view/ScaleGestureDetector.java
+++ b/core/java/android/view/ScaleGestureDetector.java
@@ -320,8 +320,8 @@
         }
 
         final int count = event.getPointerCount();
-        final boolean isStylusButtonDown = (event.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS)
-                && (event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0;
+        final boolean isStylusButtonDown =
+                (event.getButtonState() & MotionEvent.BUTTON_STYLUS_PRIMARY) != 0;
 
         final boolean anchoredScaleCancelled =
                 mAnchoredScaleMode == ANCHORED_SCALE_MODE_STYLUS && !isStylusButtonDown;
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 49be57d..160c662 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -106,6 +106,7 @@
     final Rect mOverscanInsets = new Rect();
     final Rect mContentInsets = new Rect();
     final Rect mStableInsets = new Rect();
+    final Rect mOutsets = new Rect();
     final Configuration mConfiguration = new Configuration();
 
     static final int KEEP_SCREEN_ON_MSG = 1;
@@ -519,7 +520,8 @@
                             visible ? VISIBLE : GONE,
                             WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY,
                             mWinFrame, mOverscanInsets, mContentInsets,
-                            mVisibleInsets, mStableInsets, mConfiguration, mNewSurface);
+                            mVisibleInsets, mStableInsets, mOutsets, mConfiguration,
+                            mNewSurface);
                     if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
                         mReportDrawNeeded = true;
                     }
@@ -654,7 +656,7 @@
 
         @Override
         public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
-                Rect visibleInsets, Rect stableInsets, boolean reportDraw,
+                Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
                 Configuration newConfig) {
             SurfaceView surfaceView = mSurfaceView.get();
             if (surfaceView != null) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 3e50695..3e621b1 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -3521,7 +3521,14 @@
      * the stylus is touching the screen and the button has been pressed, this
      * is false once the stylus has been lifted.
      */
-    private boolean mInStylusButtonPress = false;
+    private boolean mInStylusButtonPress;
+
+    /**
+     * Whether the next up event should be ignored for the purposes of gesture recognition. This is
+     * true after a stylus button press has occured, when the next up event should not be recognized
+     * as a tap.
+     */
+    private boolean mIgnoreNextUpEvent;
 
     /**
      * The minimum height of the view. We'll try our best to have the height
@@ -5231,26 +5238,6 @@
     }
 
     /**
-     * Checks for a stylus button press and calls the listener.
-     *
-     * @param event The event.
-     * @return True if the event was consumed.
-     */
-    private boolean performStylusActionOnButtonPress(MotionEvent event) {
-        if (isStylusButtonPressable() && !mInStylusButtonPress && !mHasPerformedLongPress
-                && event.isButtonPressed(MotionEvent.BUTTON_STYLUS_SECONDARY)) {
-            if (performStylusButtonPress()) {
-                mInStylusButtonPress = true;
-                setPressed(true, event.getX(), event.getY());
-                removeTapCallback();
-                removeLongPressCallback();
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
      * Performs button-related actions during a touch down event.
      *
      * @param event The event.
@@ -7376,6 +7363,15 @@
     }
 
     /**
+     * Returns the outsets, which areas of the device that aren't a surface, but we would like to
+     * treat them as such.
+     * @hide
+     */
+    public void getOutsets(Rect outOutsetRect) {
+        outOutsetRect.set(mAttachInfo.mOutsets);
+    }
+
+    /**
      * Returns the visibility status for this view.
      *
      * @return One of {@link #VISIBLE}, {@link #INVISIBLE}, or {@link #GONE}.
@@ -9371,6 +9367,29 @@
             return true;
         }
 
+        switch (event.getActionMasked()) {
+            case MotionEvent.ACTION_BUTTON_PRESS:
+                if (isStylusButtonPressable() && !mInStylusButtonPress && !mHasPerformedLongPress
+                        && event.getActionButton() == MotionEvent.BUTTON_STYLUS_PRIMARY) {
+                    if (performStylusButtonPress()) {
+                        mInStylusButtonPress = true;
+                        setPressed(true, event.getX(), event.getY());
+                        removeTapCallback();
+                        removeLongPressCallback();
+                        return true;
+                    }
+                }
+                break;
+
+            case MotionEvent.ACTION_BUTTON_RELEASE:
+                if (mInStylusButtonPress
+                        && event.getActionButton() == MotionEvent.BUTTON_STYLUS_PRIMARY) {
+                    mInStylusButtonPress = false;
+                    mIgnoreNextUpEvent = true;
+                }
+                break;
+        }
+
         if (mInputEventConsistencyVerifier != null) {
             mInputEventConsistencyVerifier.onUnhandledEvent(event, 0);
         }
@@ -10231,10 +10250,6 @@
                 (viewFlags & STYLUS_BUTTON_PRESSABLE) == STYLUS_BUTTON_PRESSABLE) {
             switch (action) {
                 case MotionEvent.ACTION_UP:
-                    if (mInStylusButtonPress) {
-                        mInStylusButtonPress = false;
-                        mHasPerformedLongPress = false;
-                    }
                     boolean prepressed = (mPrivateFlags & PFLAG_PREPRESSED) != 0;
                     if ((mPrivateFlags & PFLAG_PRESSED) != 0 || prepressed) {
                         // take focus if we don't have it already and we should in
@@ -10252,7 +10267,7 @@
                             setPressed(true, x, y);
                        }
 
-                        if (!mHasPerformedLongPress) {
+                        if (!mHasPerformedLongPress && !mIgnoreNextUpEvent) {
                             // This is a tap, so remove the longpress check
                             removeLongPressCallback();
 
@@ -10284,15 +10299,11 @@
 
                         removeTapCallback();
                     }
+                    mIgnoreNextUpEvent = false;
                     break;
 
                 case MotionEvent.ACTION_DOWN:
                     mHasPerformedLongPress = false;
-                    mInStylusButtonPress = false;
-
-                    if (performStylusActionOnButtonPress(event)) {
-                        break;
-                    }
 
                     if (performButtonActionOnTouchDown(event)) {
                         break;
@@ -10322,10 +10333,9 @@
                     setPressed(false);
                     removeTapCallback();
                     removeLongPressCallback();
-                    if (mInStylusButtonPress) {
-                        mInStylusButtonPress = false;
-                        mHasPerformedLongPress = false;
-                    }
+                    mInStylusButtonPress = false;
+                    mHasPerformedLongPress = false;
+                    mIgnoreNextUpEvent = false;
                     break;
 
                 case MotionEvent.ACTION_MOVE:
@@ -10341,9 +10351,6 @@
 
                             setPressed(false);
                         }
-                    } else if (performStylusActionOnButtonPress(event)) {
-                        // Check for stylus button press if we're within the view.
-                        break;
                     }
                     break;
             }
@@ -21566,6 +21573,12 @@
         final Rect mStableInsets = new Rect();
 
         /**
+         * For windows that include areas that are not covered by real surface these are the outsets
+         * for real surface.
+         */
+        final Rect mOutsets = new Rect();
+
+        /**
          * The internal insets given by this window.  This value is
          * supplied by the client (through
          * {@link ViewTreeObserver.OnComputeInternalInsetsListener}) and will
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 8d94de3..e1e0154 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -268,6 +268,7 @@
     final Rect mPendingVisibleInsets = new Rect();
     final Rect mPendingStableInsets = new Rect();
     final Rect mPendingContentInsets = new Rect();
+    final Rect mPendingOutsets = new Rect();
     final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
             = new ViewTreeObserver.InternalInsetsInfo();
 
@@ -1267,6 +1268,12 @@
                 contentInsets = mPendingContentInsets;
                 stableInsets = mPendingStableInsets;
             }
+            Rect outsets = mAttachInfo.mOutsets;
+            if (outsets.left > 0 || outsets.top > 0 || outsets.right > 0 || outsets.bottom > 0) {
+                contentInsets = new Rect(contentInsets.left + outsets.left,
+                        contentInsets.top + outsets.top, contentInsets.right + outsets.right,
+                        contentInsets.bottom + outsets.bottom);
+            }
             mLastWindowInsets = new WindowInsets(contentInsets,
                     null /* windowDecorInsets */, stableInsets,
                     mContext.getResources().getConfiguration().isScreenRound());
@@ -1425,6 +1432,9 @@
                     if (DEBUG_LAYOUT) Log.v(TAG, "Visible insets changing to: "
                             + mAttachInfo.mVisibleInsets);
                 }
+                if (!mPendingOutsets.equals(mAttachInfo.mOutsets)) {
+                    insetsChanged = true;
+                }
                 if (lp.width == ViewGroup.LayoutParams.WRAP_CONTENT
                         || lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
                     windowSizeMayChange = true;
@@ -1598,6 +1608,7 @@
                         mAttachInfo.mVisibleInsets);
                 final boolean stableInsetsChanged = !mPendingStableInsets.equals(
                         mAttachInfo.mStableInsets);
+                final boolean outsetsChanged = !mPendingOutsets.equals(mAttachInfo.mOutsets);
                 if (contentInsetsChanged) {
                     if (mWidth > 0 && mHeight > 0 && lp != null &&
                             ((lp.systemUiVisibility|lp.subtreeSystemUiVisibility)
@@ -1681,9 +1692,11 @@
                 }
                 if (contentInsetsChanged || mLastSystemUiVisibility !=
                         mAttachInfo.mSystemUiVisibility || mApplyInsetsRequested
-                        || mLastOverscanRequested != mAttachInfo.mOverscanRequested) {
+                        || mLastOverscanRequested != mAttachInfo.mOverscanRequested
+                        || outsetsChanged) {
                     mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility;
                     mLastOverscanRequested = mAttachInfo.mOverscanRequested;
+                    mAttachInfo.mOutsets.set(mPendingOutsets);
                     mApplyInsetsRequested = false;
                     dispatchApplyInsets(host);
                 }
@@ -3263,6 +3276,7 @@
                         && mPendingContentInsets.equals(args.arg2)
                         && mPendingStableInsets.equals(args.arg6)
                         && mPendingVisibleInsets.equals(args.arg3)
+                        && mPendingOutsets.equals(args.arg7)
                         && args.arg4 == null) {
                     break;
                 }
@@ -3281,6 +3295,7 @@
                     mPendingContentInsets.set((Rect) args.arg2);
                     mPendingStableInsets.set((Rect) args.arg6);
                     mPendingVisibleInsets.set((Rect) args.arg3);
+                    mPendingOutsets.set((Rect) args.arg7);
 
                     args.recycle();
 
@@ -5391,7 +5406,7 @@
                 (int) (mView.getMeasuredHeight() * appScale + 0.5f),
                 viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
                 mWinFrame, mPendingOverscanInsets, mPendingContentInsets, mPendingVisibleInsets,
-                mPendingStableInsets, mPendingConfiguration, mSurface);
+                mPendingStableInsets, mPendingOutsets, mPendingConfiguration, mSurface);
         //Log.d(TAG, "<<<<<< BACK FROM relayout");
         if (restore) {
             params.restore();
@@ -5660,7 +5675,8 @@
     }
 
     public void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets,
-            Rect visibleInsets, Rect stableInsets, boolean reportDraw, Configuration newConfig) {
+            Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
+            Configuration newConfig) {
         if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": frame=" + frame.toShortString()
                 + " contentInsets=" + contentInsets.toShortString()
                 + " visibleInsets=" + visibleInsets.toShortString()
@@ -5680,6 +5696,7 @@
         args.arg4 = sameProcessCall && newConfig != null ? new Configuration(newConfig) : newConfig;
         args.arg5 = sameProcessCall ? new Rect(overscanInsets) : overscanInsets;
         args.arg6 = sameProcessCall ? new Rect(stableInsets) : stableInsets;
+        args.arg7 = sameProcessCall ? new Rect(outsets) : outsets;
         msg.obj = args;
         mHandler.sendMessage(msg);
     }
@@ -6654,12 +6671,12 @@
 
         @Override
         public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
-                Rect visibleInsets, Rect stableInsets, boolean reportDraw,
+                Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
                 Configuration newConfig) {
             final ViewRootImpl viewAncestor = mViewAncestor.get();
             if (viewAncestor != null) {
                 viewAncestor.dispatchResized(frame, overscanInsets, contentInsets,
-                        visibleInsets, stableInsets, reportDraw, newConfig);
+                        visibleInsets, stableInsets, outsets, reportDraw, newConfig);
             }
         }
 
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 57121ddd..f7b6405 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -158,10 +158,12 @@
          * @param decorFrame The decor frame specified by policy specific to this window,
          * to use for proper cropping during animation.
          * @param stableFrame The frame around which stable system decoration is positioned.
+         * @param outsetFrame The frame that includes areas that aren't part of the surface but we
+         * want to treat them as such.
          */
         public void computeFrameLw(Rect parentFrame, Rect displayFrame,
                 Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame,
-                Rect stableFrame);
+                Rect stableFrame, Rect outsetFrame);
 
         /**
          * Retrieve the current frame of the window that has been assigned by
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 901a32d..b454d1c 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -2737,10 +2737,10 @@
 
         if (mCollectionItemInfo != null) {
             parcel.writeInt(1);
-            parcel.writeInt(mCollectionItemInfo.getColumnIndex());
-            parcel.writeInt(mCollectionItemInfo.getColumnSpan());
             parcel.writeInt(mCollectionItemInfo.getRowIndex());
             parcel.writeInt(mCollectionItemInfo.getRowSpan());
+            parcel.writeInt(mCollectionItemInfo.getColumnIndex());
+            parcel.writeInt(mCollectionItemInfo.getColumnSpan());
             parcel.writeInt(mCollectionItemInfo.isHeading() ? 1 : 0);
             parcel.writeInt(mCollectionItemInfo.isSelected() ? 1 : 0);
         } else {
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 7dcaa1f..f8b965f 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -16,6 +16,7 @@
 
 package android.widget;
 
+import android.annotation.Nullable;
 import android.os.Bundle;
 import android.os.Trace;
 import com.android.internal.R;
@@ -144,7 +145,7 @@
     }
 
     public ListView(Context context, AttributeSet attrs) {
-        this(context, attrs, com.android.internal.R.attr.listViewStyle);
+        this(context, attrs, R.attr.listViewStyle);
     }
 
     public ListView(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -155,38 +156,37 @@
         super(context, attrs, defStyleAttr, defStyleRes);
 
         final TypedArray a = context.obtainStyledAttributes(
-                attrs, com.android.internal.R.styleable.ListView, defStyleAttr, defStyleRes);
+                attrs, R.styleable.ListView, defStyleAttr, defStyleRes);
 
-        CharSequence[] entries = a.getTextArray(
-                com.android.internal.R.styleable.ListView_entries);
+        final CharSequence[] entries = a.getTextArray(R.styleable.ListView_entries);
         if (entries != null) {
-            setAdapter(new ArrayAdapter<CharSequence>(context,
-                    com.android.internal.R.layout.simple_list_item_1, entries));
+            setAdapter(new ArrayAdapter<>(context, R.layout.simple_list_item_1, entries));
         }
 
-        final Drawable d = a.getDrawable(com.android.internal.R.styleable.ListView_divider);
+        final Drawable d = a.getDrawable(R.styleable.ListView_divider);
         if (d != null) {
-            // If a divider is specified use its intrinsic height for divider height
+            // Use an implicit divider height which may be explicitly
+            // overridden by android:dividerHeight further down.
             setDivider(d);
         }
-        
-        final Drawable osHeader = a.getDrawable(
-                com.android.internal.R.styleable.ListView_overScrollHeader);
+
+        final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
         if (osHeader != null) {
             setOverscrollHeader(osHeader);
         }
 
-        final Drawable osFooter = a.getDrawable(
-                com.android.internal.R.styleable.ListView_overScrollFooter);
+        final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
         if (osFooter != null) {
             setOverscrollFooter(osFooter);
         }
 
-        // Use the height specified, zero being the default
-        final int dividerHeight = a.getDimensionPixelSize(
-                com.android.internal.R.styleable.ListView_dividerHeight, 0);
-        if (dividerHeight != 0) {
-            setDividerHeight(dividerHeight);
+        // Use an explicit divider height, if specified.
+        if (a.hasValueOrEmpty(R.styleable.ListView_dividerHeight)) {
+            final int dividerHeight = a.getDimensionPixelSize(
+                    R.styleable.ListView_dividerHeight, 0);
+            if (dividerHeight != 0) {
+                setDividerHeight(dividerHeight);
+            }
         }
 
         mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
@@ -3434,18 +3434,23 @@
      * Returns the drawable that will be drawn between each item in the list.
      *
      * @return the current drawable drawn between list elements
+     * @attr ref R.styleable#ListView_divider
      */
+    @Nullable
     public Drawable getDivider() {
         return mDivider;
     }
 
     /**
-     * Sets the drawable that will be drawn between each item in the list. If the drawable does
-     * not have an intrinsic height, you should also call {@link #setDividerHeight(int)}
+     * Sets the drawable that will be drawn between each item in the list.
+     * <p>
+     * <strong>Note:</strong> If the drawable does not have an intrinsic
+     * height, you should also call {@link #setDividerHeight(int)}.
      *
-     * @param divider The drawable to use.
+     * @param divider the drawable to use
+     * @attr ref R.styleable#ListView_divider
      */
-    public void setDivider(Drawable divider) {
+    public void setDivider(@Nullable Drawable divider) {
         if (divider != null) {
             mDividerHeight = divider.getIntrinsicHeight();
         } else {
diff --git a/core/java/com/android/internal/os/SomeArgs.java b/core/java/com/android/internal/os/SomeArgs.java
index c977997..b0d24fd 100644
--- a/core/java/com/android/internal/os/SomeArgs.java
+++ b/core/java/com/android/internal/os/SomeArgs.java
@@ -46,6 +46,7 @@
     public Object arg4;
     public Object arg5;
     public Object arg6;
+    public Object arg7;
     public int argi1;
     public int argi2;
     public int argi3;
@@ -97,6 +98,7 @@
         arg4 = null;
         arg5 = null;
         arg6 = null;
+        arg7 = null;
         argi1 = 0;
         argi2 = 0;
         argi3 = 0;
diff --git a/core/java/com/android/internal/policy/IKeyguardService.aidl b/core/java/com/android/internal/policy/IKeyguardService.aidl
index f93b1a1..7ab4651 100644
--- a/core/java/com/android/internal/policy/IKeyguardService.aidl
+++ b/core/java/com/android/internal/policy/IKeyguardService.aidl
@@ -22,6 +22,7 @@
 import android.os.Bundle;
 
 oneway interface IKeyguardService {
+
     /**
      * Sets the Keyguard as occluded when a window dismisses the Keyguard with flag
      * FLAG_SHOW_ON_LOCK_SCREEN.
@@ -36,8 +37,27 @@
     void dismiss();
     void onDreamingStarted();
     void onDreamingStopped();
-    void onScreenTurnedOff(int reason);
-    void onScreenTurnedOn(IKeyguardShowCallback callback);
+
+    /**
+     * Called when the device has started going to sleep.
+     *
+     * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
+     * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
+     */
+    void onStartedGoingToSleep(int reason);
+
+    /**
+     * Called when the device has finished going to sleep.
+     *
+     * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
+     * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
+     */
+    void onFinishedGoingToSleep(int reason);
+
+    /**
+     * Called when the device has started waking up.
+     */
+    void onStartedWakingUp(IKeyguardShowCallback callback);
     void setKeyguardEnabled(boolean enabled);
     void onSystemReady();
     void doKeyguardTimeout(in Bundle options);
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index bc64373..a04218a 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -56,7 +56,6 @@
 import android.view.WindowInsets;
 import android.view.WindowManager;
 import com.android.internal.R;
-import com.android.internal.util.ScreenShapeHelper;
 import com.android.internal.view.FloatingActionMode;
 import com.android.internal.view.RootViewSurfaceTaker;
 import com.android.internal.view.StandaloneActionMode;
@@ -156,7 +155,6 @@
     TypedValue mFixedWidthMinor;
     TypedValue mFixedHeightMajor;
     TypedValue mFixedHeightMinor;
-    int mOutsetBottomPx;
 
     // This is the top-level view of the window, containing the window decor.
     private DecorView mDecor;
@@ -289,6 +287,7 @@
     private Boolean mSharedElementsUseOverlay;
 
     private Rect mTempRect;
+    private Rect mOutsets = new Rect();
 
     static class WindowManagerHolder {
         static final IWindowManager sWindowManager = IWindowManager.Stub.asInterface(
@@ -2401,19 +2400,6 @@
         }
 
         @Override
-        public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
-            if (mOutsetBottomPx != 0) {
-                WindowInsets newInsets = insets.replaceSystemWindowInsets(
-                        insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
-                        insets.getSystemWindowInsetRight(), mOutsetBottomPx);
-                return super.dispatchApplyWindowInsets(newInsets);
-            } else {
-                return super.dispatchApplyWindowInsets(insets);
-            }
-        }
-
-
-        @Override
         public boolean onTouchEvent(MotionEvent event) {
             return onInterceptTouchEvent(event);
         }
@@ -2624,11 +2610,21 @@
                 }
             }
 
-            if (mOutsetBottomPx != 0) {
+            getOutsets(mOutsets);
+            if (mOutsets.top > 0 || mOutsets.bottom > 0) {
                 int mode = MeasureSpec.getMode(heightMeasureSpec);
                 if (mode != MeasureSpec.UNSPECIFIED) {
                     int height = MeasureSpec.getSize(heightMeasureSpec);
-                    heightMeasureSpec = MeasureSpec.makeMeasureSpec(height + mOutsetBottomPx, mode);
+                    heightMeasureSpec = MeasureSpec.makeMeasureSpec(
+                            height + mOutsets.top + mOutsets.bottom, mode);
+                }
+            }
+            if (mOutsets.left > 0 || mOutsets.right > 0) {
+                int mode = MeasureSpec.getMode(widthMeasureSpec);
+                if (mode != MeasureSpec.UNSPECIFIED) {
+                    int width = MeasureSpec.getSize(widthMeasureSpec);
+                    widthMeasureSpec = MeasureSpec.makeMeasureSpec(
+                            width + mOutsets.left + mOutsets.right, mode);
                 }
             }
 
@@ -2666,6 +2662,18 @@
         }
 
         @Override
+        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+            super.onLayout(changed, left, top, right, bottom);
+            getOutsets(mOutsets);
+            if (mOutsets.left > 0) {
+                offsetLeftAndRight(-mOutsets.left);
+            }
+            if (mOutsets.top > 0) {
+                offsetTopAndBottom(-mOutsets.top);
+            }
+        }
+
+        @Override
         public void draw(Canvas canvas) {
             super.draw(canvas);
 
@@ -2674,7 +2682,6 @@
             }
         }
 
-
         @Override
         public boolean showContextMenuForChild(View originalView) {
             // Reuse the context menu builder
@@ -3583,19 +3590,6 @@
             requestFeature(FEATURE_ACTIVITY_TRANSITIONS);
         }
 
-        final WindowManager windowService = (WindowManager) getContext().getSystemService(
-                Context.WINDOW_SERVICE);
-        if (windowService != null) {
-            final Display display = windowService.getDefaultDisplay();
-            final boolean shouldUseBottomOutset =
-                    display.getDisplayId() == Display.DEFAULT_DISPLAY
-                            || (getForcedWindowFlags() & FLAG_FULLSCREEN) != 0;
-            if (shouldUseBottomOutset) {
-                mOutsetBottomPx = ScreenShapeHelper.getWindowOutsetBottomPx(
-                        getContext().getResources().getDisplayMetrics(), a);
-            }
-        }
-
         final Context context = getContext();
         final int targetSdk = context.getApplicationInfo().targetSdkVersion;
         final boolean targetPreHoneycomb = targetSdk < android.os.Build.VERSION_CODES.HONEYCOMB;
diff --git a/core/java/com/android/internal/util/ScreenShapeHelper.java b/core/java/com/android/internal/util/ScreenShapeHelper.java
index 58ae853..4a196f8 100644
--- a/core/java/com/android/internal/util/ScreenShapeHelper.java
+++ b/core/java/com/android/internal/util/ScreenShapeHelper.java
@@ -18,19 +18,13 @@
 
     /**
      * Return the bottom pixel window outset of a window given its style attributes.
-     * @param displayMetrics Display metrics of the current device
-     * @param windowStyle Window style attributes for the window.
      * @return An outset dimension in pixels or 0 if no outset should be applied.
      */
-    public static int getWindowOutsetBottomPx(DisplayMetrics displayMetrics,
-            TypedArray windowStyle) {
+    public static int getWindowOutsetBottomPx(Resources resources) {
         if (IS_EMULATOR) {
             return SystemProperties.getInt(ViewRootImpl.PROPERTY_EMULATOR_WIN_OUTSET_BOTTOM_PX, 0);
-        } else if (windowStyle.hasValue(R.styleable.Window_windowOutsetBottom)) {
-            TypedValue outsetBottom = new TypedValue();
-            windowStyle.getValue(R.styleable.Window_windowOutsetBottom, outsetBottom);
-            return (int) outsetBottom.getDimension(displayMetrics);
+        } else {
+            return resources.getInteger(com.android.internal.R.integer.config_windowOutsetBottom);
         }
-        return 0;
     }
 }
diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java
index e27ba13..3eeabcd 100644
--- a/core/java/com/android/internal/view/BaseIWindow.java
+++ b/core/java/com/android/internal/view/BaseIWindow.java
@@ -34,8 +34,8 @@
     }
 
     @Override
-    public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
-            Rect visibleInsets, Rect stableInsets, boolean reportDraw, Configuration newConfig) {
+    public void resized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets,
+            Rect stableInsets, Rect outsets, boolean reportDraw, Configuration newConfig) {
         if (reportDraw) {
             try {
                 mSession.finishDrawing(this);
diff --git a/core/java/com/android/internal/widget/SwipeDismissLayout.java b/core/java/com/android/internal/widget/SwipeDismissLayout.java
index 6d4e058..35ed63b 100644
--- a/core/java/com/android/internal/widget/SwipeDismissLayout.java
+++ b/core/java/com/android/internal/widget/SwipeDismissLayout.java
@@ -16,9 +16,11 @@
 
 package com.android.internal.widget;
 
-import android.animation.TimeInterpolator;
 import android.app.Activity;
+import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.res.TypedArray;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -28,8 +30,6 @@
 import android.view.ViewConfiguration;
 import android.view.ViewGroup;
 import android.view.ViewTreeObserver;
-import android.view.animation.AccelerateInterpolator;
-import android.view.animation.DecelerateInterpolator;
 import android.widget.FrameLayout;
 
 /**
@@ -62,10 +62,6 @@
     // Cached ViewConfiguration and system-wide constant values
     private int mSlop;
     private int mMinFlingVelocity;
-    private int mMaxFlingVelocity;
-    private long mAnimationTime;
-    private TimeInterpolator mCancelInterpolator;
-    private TimeInterpolator mDismissInterpolator;
 
     // Transient properties
     private int mActiveTouchId;
@@ -92,6 +88,18 @@
                     }
                 }
             };
+    private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (mDismissed) {
+                dismiss();
+            } else {
+                cancel();
+            }
+            resetMembers();
+        }
+    };
+    private IntentFilter mScreenOffFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
 
     private float mLastX;
 
@@ -114,11 +122,6 @@
         ViewConfiguration vc = ViewConfiguration.get(context);
         mSlop = vc.getScaledTouchSlop();
         mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
-        mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
-        mAnimationTime = getContext().getResources().getInteger(
-                android.R.integer.config_shortAnimTime);
-        mCancelInterpolator = new DecelerateInterpolator(1.5f);
-        mDismissInterpolator = new AccelerateInterpolator(1.5f);
         TypedArray a = context.getTheme().obtainStyledAttributes(
                 com.android.internal.R.styleable.Theme);
         mUseDynamicTranslucency = !a.hasValue(
@@ -141,15 +144,17 @@
             getViewTreeObserver().addOnEnterAnimationCompleteListener(
                     mOnEnterAnimationCompleteListener);
         }
+        getContext().registerReceiver(mScreenOffReceiver, mScreenOffFilter);
     }
 
     @Override
     protected void onDetachedFromWindow() {
-        super.onDetachedFromWindow();
+        getContext().unregisterReceiver(mScreenOffReceiver);
         if (getContext() instanceof Activity) {
             getViewTreeObserver().removeOnEnterAnimationCompleteListener(
                     mOnEnterAnimationCompleteListener);
         }
+        super.onDetachedFromWindow();
     }
 
     @Override
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index c715652..8066d9f 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1861,6 +1861,11 @@
     <!-- default window inset isRound property -->
     <bool name="config_windowIsRound">false</bool>
 
+    <!-- Override this value if the device has a chin, i.e. area that is not actual part of the
+         screen but you would like to be treated as a real display. The value is the height of the
+         chin. -->
+    <integer name="config_windowOutsetBottom">0</integer>
+
     <!-- Package name for default network scorer app; overridden by product overlays. -->
     <string name="config_defaultNetworkScorerPackageName"></string>
 
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index ff3801f..93fcb2f 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -383,6 +383,7 @@
   <java-symbol type="integer" name="config_wifi_supplicant_scan_interval" />
   <java-symbol type="integer" name="config_wifi_scan_interval_p2p_connected" />
   <java-symbol type="bool" name="config_wifi_hal_pno_enable" />
+  <java-symbol type="integer" name="config_windowOutsetBottom" />
   <java-symbol type="integer" name="db_connection_pool_size" />
   <java-symbol type="integer" name="db_journal_size_limit" />
   <java-symbol type="integer" name="db_wal_autocheckpoint" />
diff --git a/docs/html/about/dashboards/index.jd b/docs/html/about/dashboards/index.jd
index ab3069e..2397dfe 100644
--- a/docs/html/about/dashboards/index.jd
+++ b/docs/html/about/dashboards/index.jd
@@ -57,12 +57,12 @@
 </div>
 
 
-<p style="clear:both"><em>Data collected during a 7-day period ending on May 4, 2015.
+<p style="clear:both"><em>Data collected during a 7-day period ending on June 1, 2015.
 <br/>Any versions with less than 0.1% distribution are not shown.</em>
 </p>
 
-<p class="note"><strong>Note:</strong> Because this data is gathered from the new Google Play
-Store app, which supports Android 2.2 and above, devices running older versions are not included.
+<p class="note"><strong>Note:</strong> This data is gathered from the new Google Play
+Store app, which supports Android 2.2 and above, so devices running older versions are not included.
 However, in August, 2013, versions older than Android 2.2 accounted for about 1% of devices that
 <em>checked in</em> to Google servers (not those that actually visited Google Play Store).
 </p>
@@ -88,7 +88,7 @@
 </div>
 
 
-<p style="clear:both"><em>Data collected during a 7-day period ending on May 4, 2015.
+<p style="clear:both"><em>Data collected during a 7-day period ending on June 1, 2015.
 
 <br/>Any screen configurations with less than 0.1% distribution are not shown.</em></p>
 
@@ -108,7 +108,7 @@
 
 
 <img alt="" style="float:right"
-src="//chart.googleapis.com/chart?chl=GL%202.0%7CGL%203.0%7CGL%203.1&chf=bg%2Cs%2C00000000&chd=t%3A64.1%2C34.5%2C1.4&chco=c4df9b%2C6fad0c&cht=p&chs=400x250">
+src="//chart.googleapis.com/chart?chl=GL%202.0%7CGL%203.0%7CGL%203.1&chf=bg%2Cs%2C00000000&chd=t%3A63.0%2C35.0%2C2.0&chco=c4df9b%2C6fad0c&cht=p&chs=400x250">
 
 <p>To declare which version of OpenGL ES your application requires, you should use the {@code
 android:glEsVersion} attribute of the <a
@@ -126,21 +126,21 @@
 </tr>
 <tr>
 <td>2.0</td>
-<td>64.1%</td>
+<td>63.0%</td>
 </tr>
 <tr>
 <td>3.0</td>
-<td>34.5%</td>
+<td>35.0%</td>
 </tr>
 <tr>
 <td>3.1</td>
-<td>1.4%</td>
+<td>2.0%</td>
 </tr>
 </table>
 
 
 
-<p style="clear:both"><em>Data collected during a 7-day period ending on May 4, 2015</em></p>
+<p style="clear:both"><em>Data collected during a 7-day period ending on June 1, 2015</em></p>
 
 
 
@@ -158,7 +158,7 @@
 var VERSION_DATA =
 [
   {
-    "chart": "//chart.googleapis.com/chart?chf=bg%2Cs%2C00000000&chd=t%3A0.3%2C5.7%2C5.3%2C39.2%2C39.8%2C9.7&chl=Froyo%7CGingerbread%7CIce%20Cream%20Sandwich%7CJelly%20Bean%7CKitKat%7CLollipop&chs=500x250&cht=p&chco=c4df9b%2C6fad0c",
+    "chart": "//chart.googleapis.com/chart?chco=c4df9b%2C6fad0c&cht=p&chs=500x250&chl=Froyo%7CGingerbread%7CIce%20Cream%20Sandwich%7CJelly%20Bean%7CKitKat%7CLollipop&chd=t%3A0.3%2C5.6%2C5.1%2C37.4%2C39.2%2C12.4&chf=bg%2Cs%2C00000000",
     "data": [
       {
         "api": 8,
@@ -168,42 +168,42 @@
       {
         "api": 10,
         "name": "Gingerbread",
-        "perc": "5.7"
+        "perc": "5.6"
       },
       {
         "api": 15,
         "name": "Ice Cream Sandwich",
-        "perc": "5.3"
+        "perc": "5.1"
       },
       {
         "api": 16,
         "name": "Jelly Bean",
-        "perc": "15.6"
+        "perc": "14.7"
       },
       {
         "api": 17,
         "name": "Jelly Bean",
-        "perc": "18.1"
+        "perc": "17.5"
       },
       {
         "api": 18,
         "name": "Jelly Bean",
-        "perc": "5.5"
+        "perc": "5.2"
       },
       {
         "api": 19,
         "name": "KitKat",
-        "perc": "39.8"
+        "perc": "39.2"
       },
       {
         "api": 21,
         "name": "Lollipop",
-        "perc": "9.0"
+        "perc": "11.6"
       },
       {
         "api": 22,
         "name": "Lollipop",
-        "perc": "0.7"
+        "perc": "0.8"
       }
     ]
   }
@@ -222,23 +222,23 @@
         "xhdpi": "0.6"
       },
       "Normal": {
-        "hdpi": "39.5",
+        "hdpi": "39.9",
         "mdpi": "7.6",
         "tvdpi": "0.1",
         "xhdpi": "19.8",
-        "xxhdpi": "16.2"
+        "xxhdpi": "15.9"
       },
       "Small": {
         "ldpi": "4.1"
       },
       "Xlarge": {
         "hdpi": "0.3",
-        "mdpi": "3.2",
+        "mdpi": "3.1",
         "xhdpi": "0.6"
       }
     },
-    "densitychart": "//chart.googleapis.com/chart?chf=bg%2Cs%2C00000000&chd=t%3A4.5%2C15.6%2C2.3%2C40.4%2C21.0%2C16.2&chl=ldpi%7Cmdpi%7Ctvdpi%7Chdpi%7Cxhdpi%7Cxxhdpi&chs=400x250&cht=p&chco=c4df9b%2C6fad0c",
-    "layoutchart": "//chart.googleapis.com/chart?chf=bg%2Cs%2C00000000&chd=t%3A4.1%2C8.6%2C83.2%2C4.1&chl=Xlarge%7CLarge%7CNormal%7CSmall&chs=400x250&cht=p&chco=c4df9b%2C6fad0c"
+    "densitychart": "//chart.googleapis.com/chart?chco=c4df9b%2C6fad0c&cht=p&chs=400x250&chl=ldpi%7Cmdpi%7Ctvdpi%7Chdpi%7Cxhdpi%7Cxxhdpi&chd=t%3A4.5%2C15.5%2C2.3%2C40.8%2C21.0%2C15.9&chf=bg%2Cs%2C00000000",
+    "layoutchart": "//chart.googleapis.com/chart?chco=c4df9b%2C6fad0c&cht=p&chs=400x250&chl=Xlarge%7CLarge%7CNormal%7CSmall&chd=t%3A4.0%2C8.6%2C83.3%2C4.1&chf=bg%2Cs%2C00000000"
   }
 ];
 
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
index f159c30..701bd67 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
@@ -621,9 +621,6 @@
                 (params.getKeyValidityForConsumptionEnd() != null)
                         ? params.getKeyValidityForConsumptionEnd() : new Date(Long.MAX_VALUE));
 
-        // TODO: Remove this once keymaster does not require us to specify the size of imported key.
-        args.addInt(KeymasterDefs.KM_TAG_KEY_SIZE, keyMaterial.length * 8);
-
         if (((purposes & KeyProperties.PURPOSE_ENCRYPT) != 0)
                 && (!params.isRandomizedEncryptionRequired())) {
             // Permit caller-provided IV when encrypting with this key
diff --git a/packages/DocumentsUI/res/values-kk-rKZ/strings.xml b/packages/DocumentsUI/res/values-kk-rKZ/strings.xml
index dd21bb8..9400ddc1 100644
--- a/packages/DocumentsUI/res/values-kk-rKZ/strings.xml
+++ b/packages/DocumentsUI/res/values-kk-rKZ/strings.xml
@@ -57,7 +57,7 @@
     <string name="empty" msgid="7858882803708117596">"Бос"</string>
     <string name="toast_no_application" msgid="1339885974067891667">"Файлды аша алмады"</string>
     <string name="toast_failed_delete" msgid="2180678019407244069">"Кейбір құжаттарды жою мүмкін болмады"</string>
-    <string name="share_via" msgid="8966594246261344259">"арқылы бөлісу"</string>
+    <string name="share_via" msgid="8966594246261344259">"Бөлісу"</string>
     <string name="copy_notification_title" msgid="6374299806748219777">"Файлдарды көшіру"</string>
     <string name="copy_remaining" msgid="6283790937387975095">"<xliff:g id="DURATION">%s</xliff:g> қалды"</string>
     <plurals name="copy_begin" formatted="false" msgid="9071199452634086365">
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
index 68803b3..f324933 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
@@ -205,7 +205,9 @@
      * Gets the current list of access points.
      */
     public List<AccessPoint> getAccessPoints() {
-        return mAccessPoints;
+        synchronized (mAccessPoints) {
+            return new ArrayList<>(mAccessPoints);
+        }
     }
 
     public WifiManager getManager() {
@@ -230,14 +232,14 @@
 
     public void dump(PrintWriter pw) {
         pw.println("  - wifi tracker ------");
-        for (AccessPoint accessPoint : mAccessPoints) {
+        for (AccessPoint accessPoint : getAccessPoints()) {
             pw.println("  " + accessPoint);
         }
     }
 
     private void updateAccessPoints() {
         // Swap the current access points into a cached list.
-        ArrayList<AccessPoint> cachedAccessPoints = new ArrayList<>(mAccessPoints);
+        List<AccessPoint> cachedAccessPoints = getAccessPoints();
         ArrayList<AccessPoint> accessPoints = new ArrayList<>();
 
         // Clear out the configs so we don't think something is saved when it isn't.
@@ -330,7 +332,7 @@
         mMainHandler.sendEmptyMessage(MainHandler.MSG_ACCESS_POINT_CHANGED);
     }
 
-    private AccessPoint getCachedOrCreate(ScanResult result, ArrayList<AccessPoint> cache) {
+    private AccessPoint getCachedOrCreate(ScanResult result, List<AccessPoint> cache) {
         final int N = cache.size();
         for (int i = 0; i < N; i++) {
             if (cache.get(i).matches(result)) {
@@ -342,7 +344,7 @@
         return new AccessPoint(mContext, result);
     }
 
-    private AccessPoint getCachedOrCreate(WifiConfiguration config, ArrayList<AccessPoint> cache) {
+    private AccessPoint getCachedOrCreate(WifiConfiguration config, List<AccessPoint> cache) {
         final int N = cache.size();
         for (int i = 0; i < N; i++) {
             if (cache.get(i).matches(config)) {
@@ -380,7 +382,9 @@
             }
         }
         if (reorder) {
-            Collections.sort(mAccessPoints);
+            synchronized (mAccessPoints) {
+                Collections.sort(mAccessPoints);
+            }
             mMainHandler.sendEmptyMessage(MainHandler.MSG_ACCESS_POINT_CHANGED);
         }
     }
diff --git a/packages/SystemUI/res/anim/ic_signal_blink_1.xml b/packages/SystemUI/res/anim/ic_signal_blink_1.xml
index ab1905a..64580d1 100644
--- a/packages/SystemUI/res/anim/ic_signal_blink_1.xml
+++ b/packages/SystemUI/res/anim/ic_signal_blink_1.xml
@@ -23,16 +23,16 @@
         android:valueType="colorType">
         <keyframe
             android:fraction="0.0"
-            android:value="@color/light_mode_icon_color_dual_tone_fill"/>
+            android:value="?attr/fillColor"/>
         <keyframe
             android:fraction="0.32"
-            android:value="@color/light_mode_icon_color_dual_tone_fill"/>
+            android:value="?attr/fillColor"/>
         <keyframe
             android:fraction="0.33"
-            android:value="@color/light_mode_icon_color_dual_tone_background"/>
+            android:value="?attr/backgroundColor"/>
         <keyframe
             android:fraction="1.0"
-            android:value="@color/light_mode_icon_color_dual_tone_background"/>
+            android:value="?attr/backgroundColor"/>
     </propertyValuesHolder>
 
 </objectAnimator>
diff --git a/packages/SystemUI/res/anim/ic_signal_blink_2.xml b/packages/SystemUI/res/anim/ic_signal_blink_2.xml
index 1b7ace2..f055cd07 100644
--- a/packages/SystemUI/res/anim/ic_signal_blink_2.xml
+++ b/packages/SystemUI/res/anim/ic_signal_blink_2.xml
@@ -23,22 +23,22 @@
         android:valueType="colorType">
         <keyframe
             android:fraction="0.0"
-            android:value="@color/light_mode_icon_color_dual_tone_background"/>
+            android:value="?attr/backgroundColor"/>
         <keyframe
             android:fraction="0.32"
-            android:value="@color/light_mode_icon_color_dual_tone_background"/>
+            android:value="?attr/backgroundColor"/>
         <keyframe
             android:fraction="0.33"
-            android:value="@color/light_mode_icon_color_dual_tone_fill"/>
+            android:value="?attr/fillColor"/>
         <keyframe
             android:fraction="0.66"
-            android:value="@color/light_mode_icon_color_dual_tone_fill"/>
+            android:value="?attr/fillColor"/>
         <keyframe
             android:fraction="0.67"
-            android:value="@color/light_mode_icon_color_dual_tone_background"/>
+            android:value="?attr/backgroundColor"/>
         <keyframe
             android:fraction="1.0"
-            android:value="@color/light_mode_icon_color_dual_tone_background"/>
+            android:value="?attr/backgroundColor"/>
     </propertyValuesHolder>
 
 </objectAnimator>
diff --git a/packages/SystemUI/res/anim/ic_signal_blink_3.xml b/packages/SystemUI/res/anim/ic_signal_blink_3.xml
index cee831c..abcd774 100644
--- a/packages/SystemUI/res/anim/ic_signal_blink_3.xml
+++ b/packages/SystemUI/res/anim/ic_signal_blink_3.xml
@@ -23,16 +23,16 @@
         android:valueType="colorType">
         <keyframe
             android:fraction="0.0"
-            android:value="@color/light_mode_icon_color_dual_tone_background"/>
+            android:value="?attr/backgroundColor"/>
         <keyframe
             android:fraction="0.66"
-            android:value="@color/light_mode_icon_color_dual_tone_background"/>
+            android:value="?attr/backgroundColor"/>
         <keyframe
             android:fraction="0.67"
-            android:value="@color/light_mode_icon_color_dual_tone_fill"/>
+            android:value="?attr/fillColor"/>
         <keyframe
             android:fraction="1.0"
-            android:value="@color/light_mode_icon_color_dual_tone_fill"/>
+            android:value="?attr/fillColor"/>
     </propertyValuesHolder>
 
 </objectAnimator>
diff --git a/packages/SystemUI/res/anim/ic_signal_dark_blink_1.xml b/packages/SystemUI/res/anim/ic_signal_dark_blink_1.xml
deleted file mode 100644
index 9d398fa..0000000
--- a/packages/SystemUI/res/anim/ic_signal_dark_blink_1.xml
+++ /dev/null
@@ -1,38 +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.
--->
-<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@android:anim/linear_interpolator"
-    android:duration="@integer/carrier_network_change_anim_time"
-    android:repeatCount="-1">
-
-    <propertyValuesHolder
-        android:propertyName="fillColor"
-        android:valueType="colorType">
-        <keyframe
-            android:fraction="0.0"
-            android:value="@color/dark_mode_icon_color_dual_tone_fill"/>
-        <keyframe
-            android:fraction="0.32"
-            android:value="@color/dark_mode_icon_color_dual_tone_fill"/>
-        <keyframe
-            android:fraction="0.33"
-            android:value="@color/dark_mode_icon_color_dual_tone_background"/>
-        <keyframe
-            android:fraction="1.0"
-            android:value="@color/dark_mode_icon_color_dual_tone_background"/>
-    </propertyValuesHolder>
-
-</objectAnimator>
diff --git a/packages/SystemUI/res/anim/ic_signal_dark_blink_2.xml b/packages/SystemUI/res/anim/ic_signal_dark_blink_2.xml
deleted file mode 100644
index c6e213d..0000000
--- a/packages/SystemUI/res/anim/ic_signal_dark_blink_2.xml
+++ /dev/null
@@ -1,44 +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.
--->
-<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@android:anim/linear_interpolator"
-    android:duration="@integer/carrier_network_change_anim_time"
-    android:repeatCount="-1">
-
-    <propertyValuesHolder
-        android:propertyName="fillColor"
-        android:valueType="colorType">
-        <keyframe
-            android:fraction="0.0"
-            android:value="@color/dark_mode_icon_color_dual_tone_background"/>
-        <keyframe
-            android:fraction="0.32"
-            android:value="@color/dark_mode_icon_color_dual_tone_background"/>
-        <keyframe
-            android:fraction="0.33"
-            android:value="@color/dark_mode_icon_color_dual_tone_fill"/>
-        <keyframe
-            android:fraction="0.66"
-            android:value="@color/dark_mode_icon_color_dual_tone_fill"/>
-        <keyframe
-            android:fraction="0.67"
-            android:value="@color/dark_mode_icon_color_dual_tone_background"/>
-        <keyframe
-            android:fraction="1.0"
-            android:value="@color/dark_mode_icon_color_dual_tone_background"/>
-    </propertyValuesHolder>
-
-</objectAnimator>
diff --git a/packages/SystemUI/res/anim/ic_signal_dark_blink_3.xml b/packages/SystemUI/res/anim/ic_signal_dark_blink_3.xml
deleted file mode 100644
index dce148c..0000000
--- a/packages/SystemUI/res/anim/ic_signal_dark_blink_3.xml
+++ /dev/null
@@ -1,38 +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.
--->
-<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@android:anim/linear_interpolator"
-    android:duration="@integer/carrier_network_change_anim_time"
-    android:repeatCount="-1">
-
-    <propertyValuesHolder
-        android:propertyName="fillColor"
-        android:valueType="colorType">
-        <keyframe
-            android:fraction="0.0"
-            android:value="@color/dark_mode_icon_color_dual_tone_background"/>
-        <keyframe
-            android:fraction="0.66"
-            android:value="@color/dark_mode_icon_color_dual_tone_background"/>
-        <keyframe
-            android:fraction="0.67"
-            android:value="@color/dark_mode_icon_color_dual_tone_fill"/>
-        <keyframe
-            android:fraction="1.0"
-            android:value="@color/dark_mode_icon_color_dual_tone_fill"/>
-    </propertyValuesHolder>
-
-</objectAnimator>
diff --git a/packages/SystemUI/res/drawable/stat_sys_signal_dark_carrier_network_change_animation.xml b/packages/SystemUI/res/drawable/stat_sys_signal_dark_carrier_network_change_animation.xml
deleted file mode 100644
index ff49d4c..0000000
--- a/packages/SystemUI/res/drawable/stat_sys_signal_dark_carrier_network_change_animation.xml
+++ /dev/null
@@ -1,27 +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.
--->
-<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:drawable="@drawable/stat_sys_signal_carrier_network_change" >
-    <target
-        android:name="dot1"
-        android:animation="@anim/ic_signal_dark_blink_1"/>
-    <target
-        android:name="dot2"
-        android:animation="@anim/ic_signal_dark_blink_2"/>
-    <target
-        android:name="dot3"
-        android:animation="@anim/ic_signal_dark_blink_3"/>
-</animated-vector>
diff --git a/packages/SystemUI/res/values-kk-rKZ/strings.xml b/packages/SystemUI/res/values-kk-rKZ/strings.xml
index 16b9d93..729cb6d 100644
--- a/packages/SystemUI/res/values-kk-rKZ/strings.xml
+++ b/packages/SystemUI/res/values-kk-rKZ/strings.xml
@@ -223,8 +223,8 @@
     <string name="status_bar_settings_signal_meter_disconnected" msgid="1940231521274147771">"Интернет байланысы жоқ"</string>
     <string name="status_bar_settings_signal_meter_wifi_nossid" msgid="6557486452774597820">"Wi-Fi қосулы"</string>
     <string name="gps_notification_searching_text" msgid="8574247005642736060">"GPS қызметін іздеуде"</string>
-    <string name="gps_notification_found_text" msgid="4619274244146446464">"Аймақ GPS арқылы орнатылған"</string>
-    <string name="accessibility_location_active" msgid="2427290146138169014">"Аймақ өтініштері қосылған"</string>
+    <string name="gps_notification_found_text" msgid="4619274244146446464">"Орын GPS арқылы орнатылған"</string>
+    <string name="accessibility_location_active" msgid="2427290146138169014">"Орын өтініштері қосылған"</string>
     <string name="accessibility_clear_all" msgid="5235938559247164925">"Барлық хабарларды жойыңыз."</string>
     <string name="status_bar_notification_inspect_item_title" msgid="5668348142410115323">"Хабарландыру параметрлері"</string>
     <string name="status_bar_notification_app_settings_title" msgid="5525260160341558869">"<xliff:g id="APP_NAME">%s</xliff:g> параметрлері"</string>
@@ -238,7 +238,7 @@
     <string name="start_dreams" msgid="7219575858348719790">"Қалғу"</string>
     <string name="ethernet_label" msgid="7967563676324087464">"Этернет"</string>
     <string name="quick_settings_dnd_label" msgid="8735855737575028208">"Мазаламау"</string>
-    <string name="quick_settings_dnd_priority_label" msgid="483232950670692036">"Тек басымдық"</string>
+    <string name="quick_settings_dnd_priority_label" msgid="483232950670692036">"Маңыздылары ғана"</string>
     <string name="quick_settings_dnd_alarms_label" msgid="2559229444312445858">"Тек дабылдар"</string>
     <string name="quick_settings_dnd_none_label" msgid="5025477807123029478">"Толық тыныштық"</string>
     <string name="quick_settings_bluetooth_label" msgid="6304190285170721401">"Bluetooth"</string>
@@ -251,8 +251,8 @@
     <string name="quick_settings_rotation_locked_portrait_label" msgid="5102691921442135053">"Портрет"</string>
     <string name="quick_settings_rotation_locked_landscape_label" msgid="8553157770061178719">"Пейзаж"</string>
     <string name="quick_settings_ime_label" msgid="7073463064369468429">"Енгізу әдісі"</string>
-    <string name="quick_settings_location_label" msgid="5011327048748762257">"Аймақ"</string>
-    <string name="quick_settings_location_off_label" msgid="7464544086507331459">"Аймақ өшірулі"</string>
+    <string name="quick_settings_location_label" msgid="5011327048748762257">"Орын"</string>
+    <string name="quick_settings_location_off_label" msgid="7464544086507331459">"Орын өшірулі"</string>
     <string name="quick_settings_media_device_label" msgid="1302906836372603762">"Meдиа құрылғысы"</string>
     <string name="quick_settings_rssi_label" msgid="7725671335550695589">"RSSI (алынған сигнал қуатының көрсеткіші)"</string>
     <string name="quick_settings_rssi_emergency_only" msgid="2713774041672886750">"Тек қана төтенше қоңыраулар"</string>
@@ -318,7 +318,7 @@
     <string name="voice_hint" msgid="8939888732119726665">"Дауыс көмекшісін ашу үшін белгішеден әрі қарай сырғытыңыз"</string>
     <string name="camera_hint" msgid="7939688436797157483">"Камераны ашу үшін белгішеден әрі қарай сырғытыңыз"</string>
     <string name="interruption_level_none" msgid="6000083681244492992">"Толық тыныштық"</string>
-    <string name="interruption_level_priority" msgid="6426766465363855505">"Тек басымдық"</string>
+    <string name="interruption_level_priority" msgid="6426766465363855505">"Маңыздылары ғана"</string>
     <string name="interruption_level_alarms" msgid="5226306993448328896">"Тек дабылдар"</string>
     <string name="interruption_level_none_twoline" msgid="3957581548190765889">"Толық\nтыныштық"</string>
     <string name="interruption_level_priority_twoline" msgid="1564715335217164124">"Тек\nбасымдық"</string>
diff --git a/packages/SystemUI/res/values-zh-rTW/strings.xml b/packages/SystemUI/res/values-zh-rTW/strings.xml
index fcc6fac..5e7a95d 100644
--- a/packages/SystemUI/res/values-zh-rTW/strings.xml
+++ b/packages/SystemUI/res/values-zh-rTW/strings.xml
@@ -240,7 +240,7 @@
     <string name="start_dreams" msgid="7219575858348719790">"休眠模式"</string>
     <string name="ethernet_label" msgid="7967563676324087464">"乙太網路"</string>
     <string name="quick_settings_dnd_label" msgid="8735855737575028208">"零打擾"</string>
-    <string name="quick_settings_dnd_priority_label" msgid="483232950670692036">"僅顯示優先通知"</string>
+    <string name="quick_settings_dnd_priority_label" msgid="483232950670692036">"僅限優先通知"</string>
     <string name="quick_settings_dnd_alarms_label" msgid="2559229444312445858">"僅允許鬧鐘"</string>
     <string name="quick_settings_dnd_none_label" msgid="5025477807123029478">"完全靜音"</string>
     <string name="quick_settings_bluetooth_label" msgid="6304190285170721401">"藍牙"</string>
@@ -320,7 +320,7 @@
     <string name="voice_hint" msgid="8939888732119726665">"滑動語音小幫手圖示即可啟用"</string>
     <string name="camera_hint" msgid="7939688436797157483">"滑動相機圖示即可啟用"</string>
     <string name="interruption_level_none" msgid="6000083681244492992">"完全靜音"</string>
-    <string name="interruption_level_priority" msgid="6426766465363855505">"僅顯示優先通知"</string>
+    <string name="interruption_level_priority" msgid="6426766465363855505">"僅限優先通知"</string>
     <string name="interruption_level_alarms" msgid="5226306993448328896">"僅允許鬧鐘"</string>
     <string name="interruption_level_none_twoline" msgid="3957581548190765889">"完全\n靜音"</string>
     <string name="interruption_level_priority_twoline" msgid="1564715335217164124">"僅允許\n優先通知"</string>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 139462d..de5639b 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -141,7 +141,7 @@
     <bool name="config_show4GForLTE">true</bool>
 
     <!-- milliseconds before the heads up notification auto-dismisses. -->
-    <integer name="heads_up_notification_decay">10000</integer>
+    <integer name="heads_up_notification_decay">5000</integer>
 
     <!-- milliseconds after a heads up notification is pushed back
      before the app can interrupt again. -->
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index 73fa2ed..98558b4 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -108,15 +108,21 @@
         }
 
         @Override // Binder interface
-        public void onScreenTurnedOff(int reason) {
+        public void onStartedGoingToSleep(int reason) {
             checkPermission();
-            mKeyguardViewMediator.onScreenTurnedOff(reason);
+            mKeyguardViewMediator.onStartedGoingToSleep(reason);
         }
 
         @Override // Binder interface
-        public void onScreenTurnedOn(IKeyguardShowCallback callback) {
+        public void onFinishedGoingToSleep(int reason) {
             checkPermission();
-            mKeyguardViewMediator.onScreenTurnedOn(callback);
+            mKeyguardViewMediator.onFinishedGoingToSleep(reason);
+        }
+
+        @Override // Binder interface
+        public void onStartedWakingUp(IKeyguardShowCallback callback) {
+            checkPermission();
+            mKeyguardViewMediator.onStartedWakingUp(callback);
         }
 
         @Override // Binder interface
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 74962ec..bc42105 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -188,11 +188,6 @@
     private boolean mBootCompleted;
     private boolean mBootSendUserPresent;
 
-    // Whether the next call to playSounds() should be skipped.  Defaults to
-    // true because the first lock (on boot) should be silent.
-    private boolean mSuppressNextLockSound = true;
-
-
     /** High level access to the power manager for WakeLocks */
     private PowerManager mPM;
 
@@ -255,7 +250,7 @@
 
     private KeyguardUpdateMonitor mUpdateMonitor;
 
-    private boolean mScreenOn;
+    private boolean mDeviceInteractive;
 
     // last known state of the cellular connection
     private String mPhoneState = TelephonyManager.EXTRA_STATE_IDLE;
@@ -306,6 +301,18 @@
 
     private final ArrayList<IKeyguardStateCallback> mKeyguardStateCallbacks = new ArrayList<>();
 
+    /**
+     * When starting going to sleep, we figured out that we need to reset Keyguard state and this
+     * should be committed when finished going to sleep.
+     */
+    private boolean mPendingReset;
+
+    /**
+     * When starting goign to sleep, we figured out that we need to lock Keyguard and this should be
+     * committed when finished going to sleep.
+     */
+    private boolean mPendingLock;
+
     KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
 
         @Override
@@ -341,7 +348,7 @@
         public void onPhoneStateChanged(int phoneState) {
             synchronized (KeyguardViewMediator.this) {
                 if (TelephonyManager.CALL_STATE_IDLE == phoneState  // call ending
-                        && !mScreenOn                           // screen off
+                        && !mDeviceInteractive                           // screen off
                         && mExternallyEnabled) {                // not disabled by any app
 
                     // note: this is a way to gracefully reenable the keyguard when the call
@@ -514,7 +521,7 @@
 
         @Override
         public boolean isScreenOn() {
-            return mScreenOn;
+            return mDeviceInteractive;
         }
     };
 
@@ -550,7 +557,7 @@
                 mViewMediatorCallback, mLockPatternUtils);
         final ContentResolver cr = mContext.getContentResolver();
 
-        mScreenOn = mPM.isScreenOn();
+        mDeviceInteractive = mPM.isInteractive();
 
         mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
         String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND);
@@ -613,23 +620,18 @@
      * @param why either {@link android.view.WindowManagerPolicy#OFF_BECAUSE_OF_USER} or
      *   {@link android.view.WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}.
      */
-    public void onScreenTurnedOff(int why) {
+    public void onStartedGoingToSleep(int why) {
+        if (DEBUG) Log.d(TAG, "onStartedGoingToSleep(" + why + ")");
         synchronized (this) {
-            mScreenOn = false;
-            if (DEBUG) Log.d(TAG, "onScreenTurnedOff(" + why + ")");
-
-            resetKeyguardDonePendingLocked();
-            mHideAnimationRun = false;
+            mDeviceInteractive = false;
 
             // Lock immediately based on setting if secure (user has a pin/pattern/password).
             // This also "locks" the device when not secure to provide easy access to the
             // camera while preventing unwanted input.
             int currentUser = KeyguardUpdateMonitor.getCurrentUser();
             final boolean lockImmediately =
-                mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser)
-                        || !mLockPatternUtils.isSecure(currentUser);
-
-            notifyScreenOffLocked();
+                    mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser)
+                            || !mLockPatternUtils.isSecure(currentUser);
 
             if (mExitSecureCallback != null) {
                 if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled");
@@ -643,12 +645,37 @@
                     hideLocked();
                 }
             } else if (mShowing) {
-                resetStateLocked();
+                mPendingReset = true;
             } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT
-                   || (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) {
+                    || (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) {
                 doKeyguardLaterLocked();
-            } else {
+            } else if (!mLockPatternUtils.isLockScreenDisabled(currentUser)) {
+                mPendingLock = true;
+            }
+
+            if (mPendingLock || mPendingReset) {
+                playSounds(true);
+            }
+        }
+    }
+
+    public void onFinishedGoingToSleep(int why) {
+        if (DEBUG) Log.d(TAG, "onFinishedGoingToSleep(" + why + ")");
+        synchronized (this) {
+            mDeviceInteractive = false;
+
+            resetKeyguardDonePendingLocked();
+            mHideAnimationRun = false;
+
+            notifyScreenOffLocked();
+
+            if (mPendingReset) {
+                resetStateLocked();
+                mPendingReset = false;
+            }
+            if (mPendingLock) {
                 doKeyguardLocked(null);
+                mPendingLock = false;
             }
         }
         KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurnedOff(why);
@@ -686,7 +713,6 @@
 
         if (timeout <= 0) {
             // Lock now
-            mSuppressNextLockSound = true;
             doKeyguardLocked(null);
         } else {
             // Lock in the future
@@ -706,13 +732,15 @@
     }
 
     /**
-     * Let's us know the screen was turned on.
+     * Let's us know when the device is waking up.
      */
-    public void onScreenTurnedOn(IKeyguardShowCallback callback) {
+    public void onStartedWakingUp(IKeyguardShowCallback callback) {
+
+        // TODO: Rename all screen off/on references to interactive/sleeping
         synchronized (this) {
-            mScreenOn = true;
+            mDeviceInteractive = true;
             cancelDoKeyguardLaterLocked();
-            if (DEBUG) Log.d(TAG, "onScreenTurnedOn, seq = " + mDelayedShowingSequence);
+            if (DEBUG) Log.d(TAG, "onStartedWakingUp, seq = " + mDelayedShowingSequence);
             if (callback != null) {
                 notifyScreenOnLocked(callback);
             }
@@ -737,7 +765,8 @@
      */
     public void onDreamingStarted() {
         synchronized (this) {
-            if (mScreenOn && mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) {
+            if (mDeviceInteractive
+                    && mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) {
                 doKeyguardLaterLocked();
             }
         }
@@ -748,7 +777,7 @@
      */
     public void onDreamingStopped() {
         synchronized (this) {
-            if (mScreenOn) {
+            if (mDeviceInteractive) {
                 cancelDoKeyguardLaterLocked();
             }
         }
@@ -1100,8 +1129,6 @@
                         + sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence);
                 synchronized (KeyguardViewMediator.this) {
                     if (mDelayedShowingSequence == sequence) {
-                        // Don't play lockscreen SFX if the screen went off due to timeout.
-                        mSuppressNextLockSound = true;
                         doKeyguardLocked(null);
                     }
                 }
@@ -1252,13 +1279,6 @@
     }
 
     private void playSounds(boolean locked) {
-        // User feedback for keyguard.
-
-        if (mSuppressNextLockSound) {
-            mSuppressNextLockSound = false;
-            return;
-        }
-
         playSound(locked ? mLockSoundId : mUnlockSoundId);
     }
 
@@ -1283,9 +1303,6 @@
     }
 
     private void playTrustedSound() {
-        if (mSuppressNextLockSound) {
-            return;
-        }
         playSound(mTrustedSoundId);
     }
 
@@ -1318,9 +1335,6 @@
             adjustStatusBarLocked();
             userActivity();
 
-            // Do this at the end to not slow down display of the keyguard.
-            playSounds(true);
-
             mShowKeyguardWakeLock.release();
         }
         mKeyguardDisplayManager.show();
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index af1f795..a12a3f1 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -376,7 +376,8 @@
             filter.addAction(ACTION_START_SAVER);
             filter.addAction(ACTION_STOP_SAVER);
             filter.addAction(ACTION_DISMISSED_WARNING);
-            mContext.registerReceiverAsUser(this, UserHandle.ALL, filter, null, mHandler);
+            mContext.registerReceiverAsUser(this, UserHandle.ALL, filter,
+                    android.Manifest.permission.STATUS_BAR_SERVICE, mHandler);
         }
 
         @Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
index dcf0438..a9e8b38 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
@@ -162,10 +162,9 @@
         }
 
         @Override
-        public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon,
-                int darkStatusIcon, int statusType, int qsType, boolean activityIn,
-                boolean activityOut, String typeContentDescription, String description,
-                boolean isWide, int subId) {
+        public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
+                int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
+                String description, boolean isWide, int subId) {
             if (qsIcon == null) {
                 // Not data sim, don't display.
                 return;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Constants.java b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
index c7f8919..18c213d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Constants.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
@@ -29,8 +29,6 @@
             public static final boolean EnableTransitionThumbnailDebugMode = false;
             // Enables the filtering of tasks according to their grouping
             public static final boolean EnableTaskFiltering = false;
-            // Enables app-info pane on long-pressing the icon
-            public static final boolean EnableDevAppInfoOnLongPress = true;
             // Enables dismiss-all
             public static final boolean EnableDismissAll = false;
             // Enables debug mode
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 682775b..01ed08a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -678,11 +678,7 @@
                 mHeaderView.mMoveTaskButton.setOnClickListener(this);
             }
             mActionButtonView.setOnClickListener(this);
-            if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
-                if (mConfig.developerOptionsEnabled) {
-                    mHeaderView.mApplicationIcon.setOnLongClickListener(this);
-                }
-            }
+            mHeaderView.mApplicationIcon.setOnLongClickListener(this);
         }
         mTaskDataLoaded = true;
     }
@@ -701,9 +697,7 @@
                 mHeaderView.mMoveTaskButton.setOnClickListener(null);
             }
             mActionButtonView.setOnClickListener(null);
-            if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
-                mHeaderView.mApplicationIcon.setOnLongClickListener(null);
-            }
+            mHeaderView.mApplicationIcon.setOnLongClickListener(null);
         }
         mTaskDataLoaded = false;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index 7e32c3a..6d02365 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -60,6 +60,7 @@
 import com.android.systemui.R;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.OutputStream;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
@@ -232,6 +233,12 @@
             // for DATE_TAKEN
             long dateSeconds = mImageTime / 1000;
 
+            // Save
+            OutputStream out = new FileOutputStream(mImageFilePath);
+            image.compress(Bitmap.CompressFormat.PNG, 100, out);
+            out.flush();
+            out.close();
+
             // Save the screenshot to the MediaStore
             ContentValues values = new ContentValues();
             ContentResolver resolver = context.getContentResolver();
@@ -244,8 +251,10 @@
             values.put(MediaStore.Images.ImageColumns.MIME_TYPE, "image/png");
             values.put(MediaStore.Images.ImageColumns.WIDTH, mImageWidth);
             values.put(MediaStore.Images.ImageColumns.HEIGHT, mImageHeight);
+            values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length());
             Uri uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
 
+            // Create a share intent
             String subjectDate = DateFormat.getDateTimeInstance().format(new Date(mImageTime));
             String subject = String.format(SCREENSHOT_SHARE_SUBJECT_TEMPLATE, subjectDate);
             Intent sharingIntent = new Intent(Intent.ACTION_SEND);
@@ -253,16 +262,6 @@
             sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
             sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
 
-            OutputStream out = resolver.openOutputStream(uri);
-            image.compress(Bitmap.CompressFormat.PNG, 100, out);
-            out.flush();
-            out.close();
-
-            // Update file size in the database
-            values.clear();
-            values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length());
-            resolver.update(uri, values, null, null);
-
             // Create a share action for the notification
             final PendingIntent callback = PendingIntent.getBroadcast(context, 0,
                     new Intent(context, GlobalScreenshot.TargetChosenReceiver.class)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index 991bde5..a66f8ec 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -180,13 +180,12 @@
     }
 
     @Override
-    public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int darkStatusIcon,
-            int statusType, int qsType, boolean activityIn, boolean activityOut,
-            String typeContentDescription, String description, boolean isWide, int subId) {
+    public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
+            int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
+            String description, boolean isWide, int subId) {
         PhoneState state = getOrInflateState(subId);
         state.mMobileVisible = statusIcon.visible;
         state.mMobileStrengthId = statusIcon.icon;
-        state.mMobileDarkStrengthId = darkStatusIcon;
         state.mMobileTypeId = statusType;
         state.mMobileDescription = statusIcon.contentDescription;
         state.mMobileTypeDescription = typeContentDescription;
@@ -426,7 +425,7 @@
     private class PhoneState {
         private final int mSubId;
         private boolean mMobileVisible = false;
-        private int mMobileStrengthId = 0, mMobileDarkStrengthId = 0, mMobileTypeId = 0;
+        private int mMobileStrengthId = 0, mMobileTypeId = 0;
         private boolean mIsMobileTypeIconWide;
         private String mMobileDescription, mMobileTypeDescription;
 
@@ -483,9 +482,8 @@
             mMobileDark.setPaddingRelative(mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0,
                     0, 0, 0);
 
-            if (DEBUG) Log.d(TAG, String.format("mobile: %s sig=%d dark=%d typ=%d",
-                        (mMobileVisible ? "VISIBLE" : "GONE"), mMobileStrengthId,
-                        mMobileDarkStrengthId, mMobileTypeId));
+            if (DEBUG) Log.d(TAG, String.format("mobile: %s sig=%d typ=%d",
+                        (mMobileVisible ? "VISIBLE" : "GONE"), mMobileStrengthId, mMobileTypeId));
 
             mMobileType.setVisibility(mMobileTypeId != 0 ? View.VISIBLE : View.GONE);
 
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 1e4aa61..5ff4ddb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -349,6 +349,9 @@
                 if (!mUserSetup && mStatusBarView != null)
                     animateCollapseQuickSettings();
             }
+            if (mIconPolicy != null) {
+                mIconPolicy.setCurrentUserSetup(mUserSetup);
+            }
         }
     };
 
@@ -554,6 +557,7 @@
 
         // Lastly, call to the icon policy to install/update all the icons.
         mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController);
+        mIconPolicy.setCurrentUserSetup(mUserSetup);
         mSettingsObserver.onChange(false); // set up
 
         mHeadsUpObserver.onChange(true); // set up
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 7c10c66..0872e06 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -18,6 +18,7 @@
 
 import android.app.ActivityManagerNative;
 import android.app.AlarmManager;
+import android.app.AlarmManager.AlarmClockInfo;
 import android.app.IUserSwitchObserver;
 import android.app.StatusBarManager;
 import android.bluetooth.BluetoothAdapter;
@@ -75,6 +76,7 @@
 
     private boolean mZenVisible;
     private boolean mVolumeVisible;
+    private boolean mCurrentUserSetup;
 
     private int mZen;
 
@@ -175,11 +177,12 @@
     }
 
     private void updateAlarm() {
-        final boolean hasAlarm = mAlarmManager.getNextAlarmClock(UserHandle.USER_CURRENT) != null;
+        final AlarmClockInfo alarm = mAlarmManager.getNextAlarmClock(UserHandle.USER_CURRENT);
+        final boolean hasAlarm = alarm != null && alarm.getTriggerTime() > 0;
         final boolean zenNone = mZen == Global.ZEN_MODE_NO_INTERRUPTIONS;
-        mService.setIconVisibility(SLOT_ALARM_CLOCK, hasAlarm);
         mService.setIcon(SLOT_ALARM_CLOCK, zenNone ? R.drawable.stat_sys_alarm_dim
                 : R.drawable.stat_sys_alarm, 0, null);
+        mService.setIconVisibility(SLOT_ALARM_CLOCK, mCurrentUserSetup && hasAlarm);
     }
 
     private final void updateSimState(Intent intent) {
@@ -391,4 +394,10 @@
         mKeyguardVisible = visible;
         updateManagedProfile();
     }
+
+    public void setCurrentUserSetup(boolean userSetup) {
+        if (mCurrentUserSetup == userSetup) return;
+        mCurrentUserSetup = userSetup;
+        updateAlarm();
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
index 7f52191..e618cb8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
@@ -124,17 +124,16 @@
 
     @Override
     public void setMobileDataIndicators(final IconState statusIcon, final IconState qsIcon,
-            final int darkStatusIcon, final int statusType, final int qsType,
-            final boolean activityIn, final boolean activityOut,
-            final String typeContentDescription, final String description, final boolean isWide,
-            final int subId) {
+            final int statusType, final int qsType,final boolean activityIn,
+            final boolean activityOut, final String typeContentDescription,
+            final String description, final boolean isWide, final int subId) {
         post(new Runnable() {
             @Override
             public void run() {
                 for (SignalCallback signalCluster : mSignalCallbacks) {
-                    signalCluster.setMobileDataIndicators(statusIcon, qsIcon, darkStatusIcon,
-                            statusType, qsType, activityIn, activityOut, typeContentDescription,
-                            description, isWide, subId);
+                    signalCluster.setMobileDataIndicators(statusIcon, qsIcon, statusType, qsType,
+                            activityIn, activityOut, typeContentDescription, description, isWide,
+                            subId);
                 }
             }
         });
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index 0d59953..cfc95bf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -117,7 +117,7 @@
 
     public void setCarrierNetworkChangeMode(boolean carrierNetworkChangeMode) {
         mCurrentState.carrierNetworkChangeMode = carrierNetworkChangeMode;
-        notifyListenersIfNecessary();
+        updateTelephony();
     }
 
     /**
@@ -220,13 +220,9 @@
                         && mCurrentState.activityOut;
         showDataIcon &= mCurrentState.isDefault;
         int typeIcon = showDataIcon ? icons.mDataType : 0;
-        mCallbackHandler.setMobileDataIndicators(statusIcon, qsIcon, getCurrentDarkIconId(),
-                typeIcon, qsTypeIcon, activityIn, activityOut, dataContentDescription, description,
-                icons.mIsWide, mSubscriptionInfo.getSubscriptionId());
-    }
-
-    private int getCurrentDarkIconId() {
-        return getCurrentIconId(false /* light */);
+        mCallbackHandler.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, qsTypeIcon,
+                activityIn, activityOut, dataContentDescription, description, icons.mIsWide,
+                mSubscriptionInfo.getSubscriptionId());
     }
 
     @Override
@@ -478,17 +474,8 @@
                 int sbNullState, int qsNullState, int sbDiscState, int qsDiscState,
                 int discContentDesc, int dataContentDesc, int dataType, boolean isWide,
                 int qsDataType) {
-            this(name, sbIcons, sbIcons, qsIcons, contentDesc, sbNullState, qsNullState,
-                    sbDiscState, sbDiscState, qsDiscState, discContentDesc, dataContentDesc,
-                    dataType, isWide, qsDataType);
-        }
-
-        public MobileIconGroup(String name, int[][] sbIcons, int[][] sbDarkIcons, int[][] qsIcons,
-                int[] contentDesc, int sbNullState, int qsNullState, int sbDiscState,
-                int sbDarkDiscState, int qsDiscState, int discContentDesc, int dataContentDesc,
-                int dataType, boolean isWide, int qsDataType) {
-            super(name, sbIcons, sbDarkIcons, qsIcons, contentDesc, sbNullState, qsNullState,
-                    sbDiscState, sbDarkDiscState, qsDiscState, discContentDesc);
+            super(name, sbIcons, qsIcons, contentDesc, sbNullState, qsNullState, sbDiscState,
+                    qsDiscState, discContentDesc);
             mDataContentDescription = dataContentDesc;
             mDataType = dataType;
             mIsWide = isWide;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 070ca63..38656ee 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -38,9 +38,9 @@
         void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
                 boolean activityIn, boolean activityOut, String description);
 
-        void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int darkStatusIcon,
-                int statusType, int qsType, boolean activityIn, boolean activityOut,
-                String typeContentDescription, String description, boolean isWide, int subId);
+        void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
+                int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
+                String description, boolean isWide, int subId);
         void setSubs(List<SubscriptionInfo> subs);
         void setNoSims(boolean show);
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalCallbackAdapter.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalCallbackAdapter.java
index 83a7d3d..dce889f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalCallbackAdapter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalCallbackAdapter.java
@@ -35,10 +35,9 @@
     }
 
     @Override
-    public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon,
-            int darkStatusIcon, int statusType, int qsType, boolean activityIn,
-            boolean activityOut, String typeContentDescription, String description,
-            boolean isWide, int subId) {
+    public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
+            int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
+            String description, boolean isWide, int subId) {
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalController.java
index e6ca646..5e9447e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SignalController.java
@@ -133,22 +133,10 @@
      * Gets the signal icon for SB based on current state of connected, enabled, and level.
      */
     public int getCurrentIconId() {
-        return getCurrentIconId(true /* light */);
-    }
-
-    protected int getCurrentIconId(boolean light) {
         if (mCurrentState.connected) {
-            if (light) {
-                return getIcons().mSbIcons[mCurrentState.inetCondition][mCurrentState.level];
-            } else {
-                return getIcons().mSbDarkIcons[mCurrentState.inetCondition][mCurrentState.level];
-            }
+            return getIcons().mSbIcons[mCurrentState.inetCondition][mCurrentState.level];
         } else if (mCurrentState.enabled) {
-            if (light) {
-                return getIcons().mSbDiscState;
-            } else {
-                return getIcons().mSbDarkDiscState;
-            }
+            return getIcons().mSbDiscState;
         } else {
             return getIcons().mSbNullState;
         }
@@ -229,13 +217,11 @@
      */
     static class IconGroup {
         final int[][] mSbIcons;
-        final int[][] mSbDarkIcons;
         final int[][] mQsIcons;
         final int[] mContentDesc;
         final int mSbNullState;
         final int mQsNullState;
         final int mSbDiscState;
-        final int mSbDarkDiscState;
         final int mQsDiscState;
         final int mDiscContentDesc;
         // For logging.
@@ -244,22 +230,13 @@
         public IconGroup(String name, int[][] sbIcons, int[][] qsIcons, int[] contentDesc,
                 int sbNullState, int qsNullState, int sbDiscState, int qsDiscState,
                 int discContentDesc) {
-            this(name, sbIcons, sbIcons, qsIcons, contentDesc, sbNullState, qsNullState,
-                    sbDiscState, sbDiscState, qsDiscState, discContentDesc);
-        }
-
-        public IconGroup(String name, int[][] sbIcons, int[][] sbDarkIcons, int[][] qsIcons,
-                int[] contentDesc, int sbNullState, int qsNullState, int sbDiscState,
-                int sbDarkDiscState, int qsDiscState, int discContentDesc) {
             mName = name;
             mSbIcons = sbIcons;
-            mSbDarkIcons = sbDarkIcons;
             mQsIcons = qsIcons;
             mContentDesc = contentDesc;
             mSbNullState = sbNullState;
             mQsNullState = qsNullState;
             mSbDiscState = sbDiscState;
-            mSbDarkDiscState = sbDarkDiscState;
             mQsDiscState = qsDiscState;
             mDiscContentDesc = discContentDesc;
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/TelephonyIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/TelephonyIcons.java
index fa4d464..8a27653 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/TelephonyIcons.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/TelephonyIcons.java
@@ -73,24 +73,15 @@
             { R.drawable.stat_sys_signal_carrier_network_change_animation,
               R.drawable.stat_sys_signal_carrier_network_change_animation,
               R.drawable.stat_sys_signal_carrier_network_change_animation,
+              R.drawable.stat_sys_signal_carrier_network_change_animation,
               R.drawable.stat_sys_signal_carrier_network_change_animation },
             { R.drawable.stat_sys_signal_carrier_network_change_animation,
               R.drawable.stat_sys_signal_carrier_network_change_animation,
               R.drawable.stat_sys_signal_carrier_network_change_animation,
+              R.drawable.stat_sys_signal_carrier_network_change_animation,
               R.drawable.stat_sys_signal_carrier_network_change_animation }
         };
 
-    static final int[][] TELEPHONY_CARRIER_NETWORK_CHANGE_DARK = {
-            { R.drawable.stat_sys_signal_dark_carrier_network_change_animation,
-              R.drawable.stat_sys_signal_dark_carrier_network_change_animation,
-              R.drawable.stat_sys_signal_dark_carrier_network_change_animation,
-              R.drawable.stat_sys_signal_dark_carrier_network_change_animation },
-            { R.drawable.stat_sys_signal_dark_carrier_network_change_animation,
-              R.drawable.stat_sys_signal_dark_carrier_network_change_animation,
-              R.drawable.stat_sys_signal_dark_carrier_network_change_animation,
-              R.drawable.stat_sys_signal_dark_carrier_network_change_animation }
-        };
-
     static final int[][] QS_TELEPHONY_CARRIER_NETWORK_CHANGE = {
         { R.drawable.ic_qs_signal_carrier_network_change_animation,
           R.drawable.ic_qs_signal_carrier_network_change_animation,
@@ -216,8 +207,6 @@
     static final int ICON_1X = R.drawable.stat_sys_data_fully_connected_1x;
     static final int ICON_CARRIER_NETWORK_CHANGE =
             R.drawable.stat_sys_signal_carrier_network_change_animation;
-    static final int ICON_CARRIER_NETWORK_CHANGE_DARK =
-            R.drawable.stat_sys_signal_dark_carrier_network_change_animation;
 
     static final int QS_ICON_LTE = R.drawable.ic_qs_signal_lte;
     static final int QS_ICON_3G = R.drawable.ic_qs_signal_3g;
@@ -229,12 +218,10 @@
     static final MobileIconGroup CARRIER_NETWORK_CHANGE = new MobileIconGroup(
             "CARRIER_NETWORK_CHANGE",
             TelephonyIcons.TELEPHONY_CARRIER_NETWORK_CHANGE,
-            TelephonyIcons.TELEPHONY_CARRIER_NETWORK_CHANGE_DARK,
             TelephonyIcons.QS_TELEPHONY_CARRIER_NETWORK_CHANGE,
             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
             0, 0,
             TelephonyIcons.ICON_CARRIER_NETWORK_CHANGE,
-            TelephonyIcons.ICON_CARRIER_NETWORK_CHANGE_DARK,
             TelephonyIcons.QS_ICON_CARRIER_NETWORK_CHANGE,
             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
             R.string.accessibility_carrier_network_change_mode,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
index c14d06f..5055bfe 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
@@ -94,7 +94,6 @@
     public void testSignalCallback_setMobileDataIndicators() {
         IconState status = new IconState(true, 0, "");
         IconState qs = new IconState(true, 1, "");
-        int dark = 2;
         boolean in = true;
         boolean out = true;
         String typeDescription = "Test 1";
@@ -103,13 +102,12 @@
         int qsType = R.drawable.ic_qs_signal_1x;
         boolean wide = true;
         int subId = 5;
-        mHandler.setMobileDataIndicators(status, qs, dark, type, qsType, in, out, typeDescription,
+        mHandler.setMobileDataIndicators(status, qs, type, qsType, in, out, typeDescription,
                 description, wide, subId);
         waitForCallbacks();
 
         ArgumentCaptor<IconState> statusArg = ArgumentCaptor.forClass(IconState.class);
         ArgumentCaptor<IconState> qsArg = ArgumentCaptor.forClass(IconState.class);
-        ArgumentCaptor<Integer> darkStrengthArg = ArgumentCaptor.forClass(Integer.class);
         ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class);
         ArgumentCaptor<Integer> qsTypeIconArg = ArgumentCaptor.forClass(Integer.class);
         ArgumentCaptor<Boolean> inArg = ArgumentCaptor.forClass(Boolean.class);
@@ -118,13 +116,12 @@
         ArgumentCaptor<String> descArg = ArgumentCaptor.forClass(String.class);
         ArgumentCaptor<Boolean> wideArg = ArgumentCaptor.forClass(Boolean.class);
         ArgumentCaptor<Integer> subIdArg = ArgumentCaptor.forClass(Integer.class);
-        Mockito.verify(mSignalCallback).setMobileDataIndicators(statusArg.capture(), qsArg.capture(),
-                darkStrengthArg.capture(), typeIconArg.capture(), qsTypeIconArg.capture(),
-                inArg.capture(), outArg.capture(), typeContentArg.capture(), descArg.capture(),
-                wideArg.capture(), subIdArg.capture());
+        Mockito.verify(mSignalCallback).setMobileDataIndicators(statusArg.capture(),
+                qsArg.capture(), typeIconArg.capture(), qsTypeIconArg.capture(), inArg.capture(),
+                outArg.capture(), typeContentArg.capture(), descArg.capture(), wideArg.capture(),
+                subIdArg.capture());
         assertEquals(status, statusArg.getValue());
         assertEquals(qs, qsArg.getValue());
-        assertEquals(dark, (int) darkStrengthArg.getValue());
         assertEquals(type, (int) typeIconArg.getValue());
         assertEquals(qsType, (int) qsTypeIconArg.getValue());
         assertEquals(in, (boolean) inArg.getValue());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
index 2d6bb68..441bb16 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
@@ -258,7 +258,6 @@
                     ArgumentCaptor.forClass(IconState.class).capture(),
                     iconArg.capture(),
                     ArgumentCaptor.forClass(Integer.class).capture(),
-                    ArgumentCaptor.forClass(Integer.class).capture(),
                     typeIconArg.capture(), dataInArg.capture(), dataOutArg.capture(),
                     ArgumentCaptor.forClass(String.class).capture(),
                     ArgumentCaptor.forClass(String.class).capture(),
@@ -275,20 +274,14 @@
     }
 
     protected void verifyLastMobileDataIndicators(boolean visible, int icon, int typeIcon) {
-        verifyLastMobileDataIndicators(visible, icon, icon, typeIcon);
-    }
-
-    protected void verifyLastMobileDataIndicators(boolean visible, int strengthIcon,
-            int darkStrengthIcon, int typeIcon) {
         ArgumentCaptor<IconState> iconArg = ArgumentCaptor.forClass(IconState.class);
-        ArgumentCaptor<Integer> darkStrengthIconArg = ArgumentCaptor.forClass(Integer.class);
         ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class);
 
         // TODO: Verify all fields.
         Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators(
                 iconArg.capture(),
                 ArgumentCaptor.forClass(IconState.class).capture(),
-                darkStrengthIconArg.capture(), typeIconArg.capture(),
+                typeIconArg.capture(),
                 ArgumentCaptor.forClass(Integer.class).capture(),
                 ArgumentCaptor.forClass(Boolean.class).capture(),
                 ArgumentCaptor.forClass(Boolean.class).capture(),
@@ -298,9 +291,6 @@
                 ArgumentCaptor.forClass(Integer.class).capture());
         IconState iconState = iconArg.getValue();
 
-        assertEquals("Signal strength icon in status bar", strengthIcon, iconState.icon);
-        assertEquals("Signal strength icon (dark mode) in status bar", darkStrengthIcon,
-                (int) darkStrengthIconArg.getValue());
         assertEquals("Data icon in status bar", typeIcon, (int) typeIconArg.getValue());
         assertEquals("Visibility in status bar", visible, iconState.visible);
     }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
index 874fdf9..dd6f272 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
@@ -438,7 +438,6 @@
       // Out of service and carrier network change is true, show special indicator
       verifyLastMobileDataIndicators(true /* visible */,
               TelephonyIcons.TELEPHONY_CARRIER_NETWORK_CHANGE[0][0] /* strengthIcon */,
-              TelephonyIcons.TELEPHONY_CARRIER_NETWORK_CHANGE_DARK[0][0] /* darkStrengthIcon */,
               0 /* typeIcon */);
 
       // Revert back
diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java
index 70a5821..bea138e 100644
--- a/rs/java/android/renderscript/Allocation.java
+++ b/rs/java/android/renderscript/Allocation.java
@@ -1052,6 +1052,7 @@
                               mSelectedLOD, mSelectedFace.mID,
                               count, 1, data.getID(mRS), dataOff, 0,
                               data.mSelectedLOD, data.mSelectedFace.mID);
+        Trace.traceEnd(RenderScript.TRACE_TAG);
     }
 
     private void validate2DRange(int xoff, int yoff, int w, int h) {
@@ -1213,19 +1214,22 @@
      * @param data the Bitmap to be copied
      */
     public void copy2DRangeFrom(int xoff, int yoff, Bitmap data) {
-        Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
-        mRS.validate();
-        if (data.getConfig() == null) {
-            Bitmap newBitmap = Bitmap.createBitmap(data.getWidth(), data.getHeight(), Bitmap.Config.ARGB_8888);
-            Canvas c = new Canvas(newBitmap);
-            c.drawBitmap(data, 0, 0, null);
-            copy2DRangeFrom(xoff, yoff, newBitmap);
-            return;
+        try {
+            Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
+            mRS.validate();
+            if (data.getConfig() == null) {
+                Bitmap newBitmap = Bitmap.createBitmap(data.getWidth(), data.getHeight(), Bitmap.Config.ARGB_8888);
+                Canvas c = new Canvas(newBitmap);
+                c.drawBitmap(data, 0, 0, null);
+                copy2DRangeFrom(xoff, yoff, newBitmap);
+                return;
+            }
+            validateBitmapFormat(data);
+            validate2DRange(xoff, yoff, data.getWidth(), data.getHeight());
+            mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, data);
+        } finally {
+            Trace.traceEnd(RenderScript.TRACE_TAG);
         }
-        validateBitmapFormat(data);
-        validate2DRange(xoff, yoff, data.getWidth(), data.getHeight());
-        mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, data);
-        Trace.traceEnd(RenderScript.TRACE_TAG);
     }
 
     private void validate3DRange(int xoff, int yoff, int zoff, int w, int h, int d) {
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index ad671c6..742f570 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -64,6 +64,7 @@
 import java.util.Locale;
 import java.util.Random;
 import java.util.TimeZone;
+import java.util.TreeSet;
 
 import static android.app.AlarmManager.RTC_WAKEUP;
 import static android.app.AlarmManager.RTC;
@@ -1055,6 +1056,28 @@
                     pw.print(" = "); pw.println(sdf.format(new Date(nextWakeupRTC)));
             pw.print("Num time change events: "); pw.println(mNumTimeChanged);
 
+            pw.println();
+            pw.println("Next alarm clock information: ");
+            final TreeSet<Integer> users = new TreeSet<>();
+            for (int i = 0; i < mNextAlarmClockForUser.size(); i++) {
+                users.add(mNextAlarmClockForUser.keyAt(i));
+            }
+            for (int i = 0; i < mPendingSendNextAlarmClockChangedForUser.size(); i++) {
+                users.add(mPendingSendNextAlarmClockChangedForUser.keyAt(i));
+            }
+            for (int user : users) {
+                final AlarmManager.AlarmClockInfo next = mNextAlarmClockForUser.get(user);
+                final long time = next != null ? next.getTriggerTime() : 0;
+                final boolean pendingSend = mPendingSendNextAlarmClockChangedForUser.get(user);
+                pw.print("  user:"); pw.print(user);
+                pw.print(" pendingSend:"); pw.print(pendingSend);
+                pw.print(" time:"); pw.print(time);
+                if (time > 0) {
+                    pw.print(" = "); pw.print(sdf.format(new Date(time)));
+                    pw.print(" = "); TimeUtils.formatDuration(time, nowRTC, pw);
+                }
+                pw.println();
+            }
             if (mAlarmBatches.size() > 0) {
                 pw.println();
                 pw.print("Pending alarm batches: ");
@@ -1706,8 +1729,8 @@
      */
     public static class IncreasingTimeOrder implements Comparator<Alarm> {
         public int compare(Alarm a1, Alarm a2) {
-            long when1 = a1.when;
-            long when2 = a2.when;
+            long when1 = a1.whenElapsed;
+            long when2 = a2.whenElapsed;
             if (when1 - when2 > 0) {
                 return 1;
             }
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index edca4b8..e544112 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -4603,27 +4603,36 @@
     @Override
     public void factoryReset() {
         enforceConnectivityInternalPermission();
+
+        if (mUserManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) {
+            return;
+        }
+
         final int userId = UserHandle.getCallingUserId();
 
         // Turn airplane mode off
         setAirplaneMode(false);
 
-        // Untether
-        for (String tether : getTetheredIfaces()) {
-            untether(tether);
+        if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) {
+            // Untether
+            for (String tether : getTetheredIfaces()) {
+                untether(tether);
+            }
         }
 
-        // Turn VPN off
-        VpnConfig vpnConfig = getVpnConfig(userId);
-        if (vpnConfig != null) {
-            if (vpnConfig.legacy) {
-                prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN, userId);
-            } else {
-                // Prevent this app (packagename = vpnConfig.user) from initiating VPN connections
-                // in the future without user intervention.
-                setVpnPackageAuthorization(vpnConfig.user, userId, false);
+        if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) {
+            // Turn VPN off
+            VpnConfig vpnConfig = getVpnConfig(userId);
+            if (vpnConfig != null) {
+                if (vpnConfig.legacy) {
+                    prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN, userId);
+                } else {
+                    // Prevent this app (packagename = vpnConfig.user) from initiating VPN connections
+                    // in the future without user intervention.
+                    setVpnPackageAuthorization(vpnConfig.user, userId, false);
 
-                prepareVpn(vpnConfig.user, VpnConfig.LEGACY_VPN, userId);
+                    prepareVpn(vpnConfig.user, VpnConfig.LEGACY_VPN, userId);
+                }
             }
         }
     }
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 706e965..81b8457 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -9028,11 +9028,22 @@
             // Our work here is done.
             return;
         }
+
+        final int callingUid = Binder.getCallingUid();
+        final int lockTaskUid = lockTask.mLockTaskUid;
         // Ensure the same caller for startLockTaskMode and stopLockTaskMode.
+        // It is possible lockTaskMode was started by the system process because
+        // android:lockTaskMode is set to a locking value in the application manifest instead of
+        // the app calling startLockTaskMode. In this case {@link TaskRecord.mLockTaskUid} will
+        // be 0, so we compare the callingUid to the {@link TaskRecord.effectiveUid} instead.
         if (getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_LOCKED &&
-                Binder.getCallingUid() != lockTask.mLockTaskUid) {
-            throw new SecurityException("Invalid uid, expected " + lockTask.mLockTaskUid);
+                callingUid != lockTaskUid
+                && (lockTaskUid != 0
+                    || (lockTaskUid == 0 && callingUid != lockTask.effectiveUid))) {
+            throw new SecurityException("Invalid uid, expected " + lockTaskUid
+                    + " callingUid=" + callingUid + " effectiveUid=" + lockTask.effectiveUid);
         }
+
         long ident = Binder.clearCallingIdentity();
         try {
             Log.d(TAG, "stopLockTaskMode");
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 1a79568..792d4ba 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -253,6 +253,7 @@
     private final INetworkManagementService mNetworkManager;
     private UsageStatsManagerInternal mUsageStats;
     private final TrustedTime mTime;
+    private final UserManager mUserManager;
 
     private IConnectivityManager mConnManager;
     private INotificationManager mNotifManager;
@@ -336,6 +337,7 @@
         mDeviceIdleController = IDeviceIdleController.Stub.asInterface(ServiceManager.getService(
                 DeviceIdleController.SERVICE_NAME));
         mTime = checkNotNull(time, "missing TrustedTime");
+        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
 
         HandlerThread thread = new HandlerThread(TAG);
         thread.start();
@@ -1986,7 +1988,6 @@
      */
     void updateRulesForGlobalChangeLocked(boolean restrictedNetworksChanged) {
         final PackageManager pm = mContext.getPackageManager();
-        final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
 
         // If we are in restrict power mode, we allow all important apps
         // to have data access.  Otherwise, we restrict data access to only
@@ -1996,7 +1997,7 @@
                 : ActivityManager.PROCESS_STATE_TOP;
 
         // update rules for all installed applications
-        final List<UserInfo> users = um.getUsers();
+        final List<UserInfo> users = mUserManager.getUsers();
         final List<ApplicationInfo> apps = pm.getInstalledApplications(
                 PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
 
@@ -2353,6 +2354,10 @@
     public void factoryReset(String subscriber) {
         mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
 
+        if (mUserManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) {
+            return;
+        }
+
         // Turn mobile data limit off
         NetworkPolicy[] policies = getNetworkPolicies(mContext.getOpPackageName());
         NetworkTemplate template = NetworkTemplate.buildTemplateMobileAll(subscriber);
@@ -2368,9 +2373,11 @@
         // Turn restrict background data off
         setRestrictBackground(false);
 
-        // Remove app's "restrict background data" flag
-        for (int uid : getUidsWithPolicy(POLICY_REJECT_METERED_BACKGROUND)) {
-            setUidPolicy(uid, POLICY_NONE);
+        if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_APPS_CONTROL)) {
+            // Remove app's "restrict background data" flag
+            for (int uid : getUidsWithPolicy(POLICY_REJECT_METERED_BACKGROUND)) {
+                setUidPolicy(uid, POLICY_NONE);
+            }
         }
     }
 }
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 15d1535a..08d386b 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -950,6 +950,7 @@
         writeBoolean(serializer, restrictions, UserManager.DISALLOW_DEBUGGING_FEATURES);
         writeBoolean(serializer, restrictions, UserManager.DISALLOW_CONFIG_VPN);
         writeBoolean(serializer, restrictions, UserManager.DISALLOW_CONFIG_TETHERING);
+        writeBoolean(serializer, restrictions, UserManager.DISALLOW_NETWORK_RESET);
         writeBoolean(serializer, restrictions, UserManager.DISALLOW_FACTORY_RESET);
         writeBoolean(serializer, restrictions, UserManager.DISALLOW_ADD_USER);
         writeBoolean(serializer, restrictions, UserManager.ENSURE_VERIFY_APPS);
@@ -1078,6 +1079,7 @@
         readBoolean(parser, restrictions, UserManager.DISALLOW_DEBUGGING_FEATURES);
         readBoolean(parser, restrictions, UserManager.DISALLOW_CONFIG_VPN);
         readBoolean(parser, restrictions, UserManager.DISALLOW_CONFIG_TETHERING);
+        readBoolean(parser, restrictions, UserManager.DISALLOW_NETWORK_RESET);
         readBoolean(parser, restrictions, UserManager.DISALLOW_FACTORY_RESET);
         readBoolean(parser, restrictions, UserManager.DISALLOW_ADD_USER);
         readBoolean(parser, restrictions, UserManager.ENSURE_VERIFY_APPS);
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index a1e1aef..7bd5b78 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -108,6 +108,7 @@
 import android.view.animation.AnimationUtils;
 import com.android.internal.R;
 import com.android.internal.statusbar.IStatusBarService;
+import com.android.internal.util.ScreenShapeHelper;
 import com.android.internal.widget.PointerLocationView;
 import com.android.server.LocalServices;
 import com.android.server.policy.keyguard.KeyguardServiceDelegate;
@@ -472,6 +473,7 @@
     static final Rect mTmpDecorFrame = new Rect();
     static final Rect mTmpStableFrame = new Rect();
     static final Rect mTmpNavigationFrame = new Rect();
+    static final Rect mTmpOutsetFrame = new Rect();
 
     WindowState mTopFullscreenOpaqueWindowState;
     WindowState mTopFullscreenOpaqueOrDimmingWindowState;
@@ -3363,6 +3365,7 @@
         final Rect of = mTmpOverscanFrame;
         final Rect vf = mTmpVisibleFrame;
         final Rect dcf = mTmpDecorFrame;
+        final Rect osf = mTmpOutsetFrame;
         pf.left = df.left = of.left = vf.left = mDockLeft;
         pf.top = df.top = of.top = vf.top = mDockTop;
         pf.right = df.right = of.right = vf.right = mDockRight;
@@ -3472,7 +3475,7 @@
                 // And compute the final frame.
                 mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
                         mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf,
-                        mTmpNavigationFrame);
+                        mTmpNavigationFrame, mTmpNavigationFrame);
                 if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
                 if (mNavigationBarController.checkHiddenLw()) {
                     updateSysUiVisibility = true;
@@ -3497,7 +3500,9 @@
                 mStatusBarLayer = mStatusBar.getSurfaceLayer();
 
                 // Let the status bar determine its size.
-                mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf, vf);
+                mStatusBar.computeFrameLw(pf /* parentFrame */, df /* displayFrame */,
+                        vf /* overlayFrame */, vf /* contentFrame */, vf /* visibleFrame */,
+                        dcf /* decorFrame */, vf /* stableFrame */, vf /* outsetFrame */);
 
                 // For layout, the status bar is always at the top with our fixed height.
                 mStableTop = mUnrestrictedScreenTop + mStatusBarHeight;
@@ -3680,6 +3685,7 @@
         final Rect vf = mTmpVisibleFrame;
         final Rect dcf = mTmpDecorFrame;
         final Rect sf = mTmpStableFrame;
+        Rect osf = null;
         dcf.setEmpty();
 
         final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar
@@ -4073,6 +4079,32 @@
             }
         }
 
+        // If the device has a chin (e.g. some watches), a dead area at the bottom of the screen we
+        // need to provide information to the clients that want to pretend that you can draw there.
+        if (isDefaultDisplay && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0) {
+            osf = mTmpOutsetFrame;
+            osf.set(cf.left, cf.top, cf.right, cf.bottom);
+            int outset = ScreenShapeHelper.getWindowOutsetBottomPx(mContext.getResources());
+            if (outset > 0) {
+                int rotation = Surface.ROTATION_0;
+                try {
+                    rotation = mWindowManager.getRotation();
+                } catch (RemoteException e) {
+                }
+                if (rotation == Surface.ROTATION_0) {
+                    osf.bottom += outset;
+                } else if (rotation == Surface.ROTATION_90) {
+                    osf.right += outset;
+                } else if (rotation == Surface.ROTATION_180) {
+                    osf.top -= outset;
+                } else if (rotation == Surface.ROTATION_270) {
+                    osf.left -= outset;
+                }
+                if (DEBUG_LAYOUT) Slog.v(TAG, "applying bottom outset of " + outset
+                        + " with rotation " + rotation + ", result: " + osf);
+            }
+        }
+
         if (DEBUG_LAYOUT) Slog.v(TAG, "Compute frame " + attrs.getTitle()
                 + ": sim=#" + Integer.toHexString(sim)
                 + " attach=" + attached + " type=" + attrs.type
@@ -4081,9 +4113,10 @@
                 + " of=" + of.toShortString()
                 + " cf=" + cf.toShortString() + " vf=" + vf.toShortString()
                 + " dcf=" + dcf.toShortString()
-                + " sf=" + sf.toShortString());
+                + " sf=" + sf.toShortString()
+                + " osf=" + (osf == null ? "null" : osf.toShortString()));
 
-        win.computeFrameLw(pf, df, of, cf, vf, dcf, sf);
+        win.computeFrameLw(pf, df, of, cf, vf, dcf, sf, osf);
 
         // Dock windows carve out the bottom of the screen, so normal windows
         // can't appear underneath them.
@@ -5236,6 +5269,9 @@
     @Override
     public void startedGoingToSleep(int why) {
         if (DEBUG_WAKEUP) Slog.i(TAG, "Started going to sleep... (why=" + why + ")");
+        if (mKeyguardDelegate != null) {
+            mKeyguardDelegate.onStartedGoingToSleep(why);
+        }
     }
 
     // Called on the PowerManager's Notifier thread.
@@ -5253,9 +5289,8 @@
             updateOrientationListenerLp();
             updateLockScreenTimeout();
         }
-
         if (mKeyguardDelegate != null) {
-            mKeyguardDelegate.onScreenTurnedOff(why);
+            mKeyguardDelegate.onFinishedGoingToSleep(why);
         }
     }
 
@@ -5283,7 +5318,7 @@
         }
 
         if (mKeyguardDelegate != null) {
-            mKeyguardDelegate.onScreenTurnedOn(mKeyguardDelegateCallback);
+            mKeyguardDelegate.onStartedWakingUp(mKeyguardDelegateCallback);
             // ... eventually calls finishKeyguardDrawn
         } else {
             if (DEBUG_WAKEUP) Slog.d(TAG, "null mKeyguardDelegate: setting mKeyguardDrawComplete.");
diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
index 1a52933..b9f132b 100644
--- a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
+++ b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
@@ -56,10 +56,8 @@
         boolean systemIsReady;
         boolean deviceHasKeyguard;
         public boolean enabled;
-        public boolean dismissable;
         public int offReason;
         public int currentUser;
-        public boolean screenIsOn;
         public boolean bootCompleted;
     };
 
@@ -138,7 +136,7 @@
                 // If the system is ready, it means keyguard crashed and restarted.
                 mKeyguardService.onSystemReady();
                 // This is used to hide the scrim once keyguard displays.
-                mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(
+                mKeyguardService.onStartedWakingUp(new KeyguardShowDelegate(
                         mShowListenerWhenConnect));
                 mShowListenerWhenConnect = null;
             }
@@ -218,10 +216,10 @@
         mKeyguardState.dreaming = false;
     }
 
-    public void onScreenTurnedOn(final ShowListener showListener) {
+    public void onStartedWakingUp(final ShowListener showListener) {
         if (mKeyguardService != null) {
             if (DEBUG) Log.v(TAG, "onScreenTurnedOn(showListener = " + showListener + ")");
-            mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(showListener));
+            mKeyguardService.onStartedWakingUp(new KeyguardShowDelegate(showListener));
         } else {
             // try again when we establish a connection
             Slog.w(TAG, "onScreenTurnedOn(): no keyguard service!");
@@ -230,15 +228,19 @@
             mShowListenerWhenConnect = showListener;
             showScrim();
         }
-        mKeyguardState.screenIsOn = true;
     }
 
-    public void onScreenTurnedOff(int why) {
+    public void onStartedGoingToSleep(int why) {
         if (mKeyguardService != null) {
-            mKeyguardService.onScreenTurnedOff(why);
+            mKeyguardService.onStartedGoingToSleep(why);
         }
         mKeyguardState.offReason = why;
-        mKeyguardState.screenIsOn = false;
+    }
+
+    public void onFinishedGoingToSleep(int why) {
+        if (mKeyguardService != null) {
+            mKeyguardService.onFinishedGoingToSleep(why);
+        }
     }
 
     public void setKeyguardEnabled(boolean enabled) {
diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java
index 2dc685b..51d59fa 100644
--- a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java
+++ b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java
@@ -105,19 +105,28 @@
         }
     }
 
-    @Override // Binder interface
-    public void onScreenTurnedOff(int reason) {
+    @Override
+    public void onStartedGoingToSleep(int reason) {
         try {
-            mService.onScreenTurnedOff(reason);
+            mService.onStartedGoingToSleep(reason);
         } catch (RemoteException e) {
             Slog.w(TAG , "Remote Exception", e);
         }
     }
 
-    @Override // Binder interface
-    public void onScreenTurnedOn(IKeyguardShowCallback result) {
+    @Override
+    public void onFinishedGoingToSleep(int reason) {
         try {
-            mService.onScreenTurnedOn(result);
+            mService.onFinishedGoingToSleep(reason);
+        } catch (RemoteException e) {
+            Slog.w(TAG , "Remote Exception", e);
+        }
+    }
+
+    @Override
+    public void onStartedWakingUp(IKeyguardShowCallback callback) {
+        try {
+            mService.onStartedWakingUp(callback);
         } catch (RemoteException e) {
             Slog.w(TAG , "Remote Exception", e);
         }
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 487483e9..e9c5ac7 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -190,14 +190,15 @@
     public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
             int requestedWidth, int requestedHeight, int viewFlags,
             int flags, Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
-            Rect outVisibleInsets, Rect outStableInsets, Configuration outConfig,
+            Rect outVisibleInsets, Rect outStableInsets, Rect outsets, Configuration
+                    outConfig,
             Surface outSurface) {
         if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED relayout from "
                 + Binder.getCallingPid());
         int res = mService.relayoutWindow(this, window, seq, attrs,
                 requestedWidth, requestedHeight, viewFlags, flags,
                 outFrame, outOverscanInsets, outContentInsets, outVisibleInsets,
-                outStableInsets, outConfig, outSurface);
+                outStableInsets, outsets, outConfig, outSurface);
         if (false) Slog.d(WindowManagerService.TAG, "<<<<<< EXITING relayout to "
                 + Binder.getCallingPid());
         return res;
@@ -522,4 +523,4 @@
     public String toString() {
         return mStringName;
     }
-}
\ No newline at end of file
+}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 6042c27..5c9f87e 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -741,8 +741,7 @@
                     final float newX = motionEvent.getRawX();
                     final float newY = motionEvent.getRawY();
                     final boolean isStylusButtonDown =
-                            (motionEvent.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS)
-                            && (motionEvent.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0;
+                            (motionEvent.getButtonState() & MotionEvent.BUTTON_STYLUS_PRIMARY) != 0;
 
                     if (mIsStartEvent) {
                         if (isStylusButtonDown) {
@@ -3052,7 +3051,7 @@
             WindowManager.LayoutParams attrs, int requestedWidth,
             int requestedHeight, int viewVisibility, int flags,
             Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
-            Rect outVisibleInsets, Rect outStableInsets, Configuration outConfig,
+            Rect outVisibleInsets, Rect outStableInsets, Rect outOutsets, Configuration outConfig,
             Surface outSurface) {
         boolean toBeDisplayed = false;
         boolean inTouchMode;
@@ -3340,6 +3339,7 @@
             outContentInsets.set(win.mContentInsets);
             outVisibleInsets.set(win.mVisibleInsets);
             outStableInsets.set(win.mStableInsets);
+            outOutsets.set(win.mOutsets);
             if (localLOGV) Slog.v(
                 TAG, "Relayout given client " + client.asBinder()
                 + ", requestedWidth=" + requestedWidth
@@ -9613,6 +9613,7 @@
                 w.mLastContentInsets.set(w.mContentInsets);
                 w.mLastVisibleInsets.set(w.mVisibleInsets);
                 w.mLastStableInsets.set(w.mStableInsets);
+                w.mLastOutsets.set(w.mOutsets);
                 makeWindowFreezingScreenIfNeededLocked(w);
                 // If the orientation is changing, then we need to
                 // hold off on unfreezing the display until this
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 193d812..b8b243c 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -180,6 +180,14 @@
     boolean mStableInsetsChanged;
 
     /**
+     * Outsets determine the area outside of the surface where we want to pretend that it's possible
+     * to draw anyway.
+     */
+    final Rect mOutsets = new Rect();
+    final Rect mLastOutsets = new Rect();
+    boolean mOutsetsChanged = false;
+
+    /**
      * Set to true if we are waiting for this window to receive its
      * given internal insets before laying out other windows based on it.
      */
@@ -261,6 +269,10 @@
     // displays hint text.
     final Rect mVisibleFrame = new Rect();
 
+    // Frame that includes dead area outside of the surface but where we want to pretend that it's
+    // possible to draw.
+    final Rect mOutsetFrame = new Rect();
+
     boolean mContentChanged;
 
     // If a window showing a wallpaper: the requested offset for the
@@ -519,7 +531,8 @@
     }
 
     @Override
-    public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf, Rect dcf, Rect sf) {
+    public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf, Rect dcf, Rect sf,
+            Rect osf) {
         mHaveFrame = true;
 
         final TaskStack stack = mAppToken != null ? getStack() : null;
@@ -594,6 +607,10 @@
         mVisibleFrame.set(vf);
         mDecorFrame.set(dcf);
         mStableFrame.set(sf);
+        final boolean hasOutsets = osf != null;
+        if (hasOutsets) {
+            mOutsetFrame.set(osf);
+        }
 
         final int fw = mFrame.width();
         final int fh = mFrame.height();
@@ -658,6 +675,16 @@
                 Math.max(mFrame.right - mStableFrame.right, 0),
                 Math.max(mFrame.bottom - mStableFrame.bottom, 0));
 
+        if (hasOutsets) {
+            // We need to calculate outsets
+            mOutsets.set(Math.max(mContentFrame.left - mOutsetFrame.left, 0),
+                    Math.max(mContentFrame.top - mOutsetFrame.top, 0),
+                    Math.max(mOutsetFrame.right - mContentFrame.right, 0),
+                    Math.max(mOutsetFrame.bottom - mContentFrame.bottom, 0));
+        } else {
+            mOutsets.set(0, 0, 0, 0);
+        }
+
         mCompatFrame.set(mFrame);
         if (mEnforceSizeCompat) {
             // If there is a size compatibility scale being applied to the
@@ -667,6 +694,7 @@
             mContentInsets.scale(mInvGlobalScale);
             mVisibleInsets.scale(mInvGlobalScale);
             mStableInsets.scale(mInvGlobalScale);
+            mOutsets.scale(mInvGlobalScale);
 
             // Also the scaled frame that we report to the app needs to be
             // adjusted to be in its coordinate space.
@@ -689,7 +717,8 @@
                 + "): frame=" + mFrame.toShortString()
                 + " ci=" + mContentInsets.toShortString()
                 + " vi=" + mVisibleInsets.toShortString()
-                + " vi=" + mStableInsets.toShortString());
+                + " vi=" + mStableInsets.toShortString()
+                + " of=" + mOutsets.toShortString());
     }
 
     @Override
@@ -804,7 +833,9 @@
         mContentInsetsChanged |= !mLastContentInsets.equals(mContentInsets);
         mVisibleInsetsChanged |= !mLastVisibleInsets.equals(mVisibleInsets);
         mStableInsetsChanged |= !mLastStableInsets.equals(mStableInsets);
-        return mOverscanInsetsChanged || mContentInsetsChanged || mVisibleInsetsChanged;
+        mOutsetsChanged |= !mLastOutsets.equals(mOutsets);
+        return mOverscanInsetsChanged || mContentInsetsChanged || mVisibleInsetsChanged
+                || mOutsetsChanged;
     }
 
     public DisplayContent getDisplayContent() {
@@ -1472,6 +1503,7 @@
             final Rect contentInsets = mLastContentInsets;
             final Rect visibleInsets = mLastVisibleInsets;
             final Rect stableInsets = mLastStableInsets;
+            final Rect outsets = mLastOutsets;
             final boolean reportDraw = mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING;
             final Configuration newConfig = configChanged ? mConfiguration : null;
             if (mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
@@ -1482,7 +1514,7 @@
                     public void run() {
                         try {
                             mClient.resized(frame, overscanInsets, contentInsets,
-                                    visibleInsets, stableInsets,  reportDraw, newConfig);
+                                    visibleInsets, stableInsets, outsets, reportDraw, newConfig);
                         } catch (RemoteException e) {
                             // Not a remote call, RemoteException won't be raised.
                         }
@@ -1490,7 +1522,7 @@
                 });
             } else {
                 mClient.resized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets,
-                        reportDraw, newConfig);
+                        outsets, reportDraw, newConfig);
             }
 
             //TODO (multidisplay): Accessibility supported only for the default display.
@@ -1503,6 +1535,7 @@
             mContentInsetsChanged = false;
             mVisibleInsetsChanged = false;
             mStableInsetsChanged = false;
+            mOutsetsChanged = false;
             mWinAnimator.mSurfaceResized = false;
         } catch (RemoteException e) {
             mOrientationChanging = false;
@@ -1664,17 +1697,22 @@
                     pw.println();
             pw.print(prefix); pw.print("    decor="); mDecorFrame.printShortString(pw);
                     pw.println();
+            pw.print(prefix); pw.print("    outset="); mOutsetFrame.printShortString(pw);
+                    pw.println();
             pw.print(prefix); pw.print("Cur insets: overscan=");
                     mOverscanInsets.printShortString(pw);
                     pw.print(" content="); mContentInsets.printShortString(pw);
                     pw.print(" visible="); mVisibleInsets.printShortString(pw);
                     pw.print(" stable="); mStableInsets.printShortString(pw);
+                    pw.print(" outsets="); mOutsets.printShortString(pw);
                     pw.println();
             pw.print(prefix); pw.print("Lst insets: overscan=");
                     mLastOverscanInsets.printShortString(pw);
                     pw.print(" content="); mLastContentInsets.printShortString(pw);
                     pw.print(" visible="); mLastVisibleInsets.printShortString(pw);
                     pw.print(" stable="); mLastStableInsets.printShortString(pw);
+                    pw.print(" physical="); mLastOutsets.printShortString(pw);
+                    pw.print(" outset="); mLastOutsets.printShortString(pw);
                     pw.println();
         }
         pw.print(prefix); pw.print(mWinAnimator); pw.println(":");
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index d807b0b..ff748f2 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -202,6 +202,7 @@
         DEVICE_OWNER_USER_RESTRICTIONS = new HashSet();
         DEVICE_OWNER_USER_RESTRICTIONS.add(UserManager.DISALLOW_USB_FILE_TRANSFER);
         DEVICE_OWNER_USER_RESTRICTIONS.add(UserManager.DISALLOW_CONFIG_TETHERING);
+        DEVICE_OWNER_USER_RESTRICTIONS.add(UserManager.DISALLOW_NETWORK_RESET);
         DEVICE_OWNER_USER_RESTRICTIONS.add(UserManager.DISALLOW_FACTORY_RESET);
         DEVICE_OWNER_USER_RESTRICTIONS.add(UserManager.DISALLOW_ADD_USER);
         DEVICE_OWNER_USER_RESTRICTIONS.add(UserManager.DISALLOW_CONFIG_CELL_BROADCASTS);
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 4cf741d..07176b3 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -124,6 +124,16 @@
             "android.telecom.action.CHANGE_DEFAULT_DIALER";
 
     /**
+     * Privileged version of {@link #ACTION_CHANGE_DEFAULT_DIALER} that doesn't require
+     * confirmation from the user via the dialog.
+     *
+     * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE}
+     * @hide
+     */
+    public static final String ACTION_CHANGE_DEFAULT_DIALER_PRIVILEGED =
+            "android.telecom.action.CHANGE_DEFAULT_DIALER_PRIVILEGED";
+
+    /**
      * Activity action: Opens the settings screen where a user can enable and disable which
      * {@link PhoneAccount}s are allows to make and receive calls. Because a user must
      * explicitly enable an account before the system will use it, an app may want to send the
diff --git a/tests/VectorDrawableTest/res/anim/blink.xml b/tests/VectorDrawableTest/res/anim/blink.xml
index 2af0b48..714f491 100644
--- a/tests/VectorDrawableTest/res/anim/blink.xml
+++ b/tests/VectorDrawableTest/res/anim/blink.xml
@@ -22,7 +22,7 @@
     <propertyValuesHolder
         android:propertyName="fillColor"
         android:valueType="colorType"
-        android:valueFrom="#ff3838"
-        android:valueTo="?attr/color1" />
+        android:valueFrom="?attr/color1"
+        android:valueTo="@android:color/white" />
 
 </objectAnimator>
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
index 66092fc..771c3c8 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
@@ -47,8 +47,8 @@
     }
 
     @Override
-    public void resized(Rect rect, Rect rect2, Rect rect3, Rect rect4, Rect rect5, boolean b,
-            Configuration configuration) throws RemoteException {
+    public void resized(Rect rect, Rect rect2, Rect rect3, Rect rect4, Rect rect5, Rect rect6,
+            boolean b, Configuration configuration) throws RemoteException {
         // pass for now.
     }
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
index 4289689..c92df6d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
@@ -89,7 +89,7 @@
     @Override
     public int relayout(IWindow iWindow, int i, LayoutParams layoutParams, int i2,
             int i3, int i4, int i5, Rect rect, Rect rect2, Rect rect3, Rect rect4, Rect rect5,
-            Configuration configuration, Surface surface) throws RemoteException {
+            Rect rect6, Configuration configuration, Surface surface) throws RemoteException {
         // pass for now.
         return 0;
     }