Merge "Fix menu visibility while updating dismiss fraction." into oc-dev
diff --git a/api/current.txt b/api/current.txt
index 392b60d..d18d8813 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -104,7 +104,7 @@
     field public static final java.lang.String READ_FRAME_BUFFER = "android.permission.READ_FRAME_BUFFER";
     field public static final deprecated java.lang.String READ_INPUT_STATE = "android.permission.READ_INPUT_STATE";
     field public static final java.lang.String READ_LOGS = "android.permission.READ_LOGS";
-    field public static final java.lang.String READ_PHONE_NUMBER = "android.permission.READ_PHONE_NUMBER";
+    field public static final java.lang.String READ_PHONE_NUMBERS = "android.permission.READ_PHONE_NUMBERS";
     field public static final java.lang.String READ_PHONE_STATE = "android.permission.READ_PHONE_STATE";
     field public static final java.lang.String READ_SMS = "android.permission.READ_SMS";
     field public static final java.lang.String READ_SYNC_SETTINGS = "android.permission.READ_SYNC_SETTINGS";
@@ -3675,7 +3675,8 @@
     method public boolean onMenuItemSelected(int, android.view.MenuItem);
     method public boolean onMenuOpened(int, android.view.Menu);
     method public void onMovedToDisplay(int, android.content.res.Configuration);
-    method public void onMultiWindowModeChanged(boolean);
+    method public void onMultiWindowModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onMultiWindowModeChanged(boolean);
     method public boolean onNavigateUp();
     method public boolean onNavigateUpFromChild(android.app.Activity);
     method protected void onNewIntent(android.content.Intent);
@@ -3683,7 +3684,8 @@
     method public void onOptionsMenuClosed(android.view.Menu);
     method public void onPanelClosed(int, android.view.Menu);
     method protected void onPause();
-    method public void onPictureInPictureModeChanged(boolean);
+    method public void onPictureInPictureModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onPictureInPictureModeChanged(boolean);
     method protected void onPostCreate(android.os.Bundle);
     method public void onPostCreate(android.os.Bundle, android.os.PersistableBundle);
     method protected void onPostResume();
@@ -4180,7 +4182,7 @@
     field public static final java.lang.String OPSTR_READ_CELL_BROADCASTS = "android:read_cell_broadcasts";
     field public static final java.lang.String OPSTR_READ_CONTACTS = "android:read_contacts";
     field public static final java.lang.String OPSTR_READ_EXTERNAL_STORAGE = "android:read_external_storage";
-    field public static final java.lang.String OPSTR_READ_PHONE_NUMBER = "android:read_phone_number";
+    field public static final java.lang.String OPSTR_READ_PHONE_NUMBERS = "android:read_phone_numbers";
     field public static final java.lang.String OPSTR_READ_PHONE_STATE = "android:read_phone_state";
     field public static final java.lang.String OPSTR_READ_SMS = "android:read_sms";
     field public static final java.lang.String OPSTR_RECEIVE_MMS = "android:receive_mms";
@@ -4616,11 +4618,13 @@
     method public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle);
     method public deprecated void onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle);
     method public void onLowMemory();
-    method public void onMultiWindowModeChanged(boolean);
+    method public void onMultiWindowModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onMultiWindowModeChanged(boolean);
     method public boolean onOptionsItemSelected(android.view.MenuItem);
     method public void onOptionsMenuClosed(android.view.Menu);
     method public void onPause();
-    method public void onPictureInPictureModeChanged(boolean);
+    method public void onPictureInPictureModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onPictureInPictureModeChanged(boolean);
     method public void onPrepareOptionsMenu(android.view.Menu);
     method public void onRequestPermissionsResult(int, java.lang.String[], int[]);
     method public void onResume();
@@ -4705,11 +4709,13 @@
     method public void dispatchDestroy();
     method public void dispatchDestroyView();
     method public void dispatchLowMemory();
-    method public void dispatchMultiWindowModeChanged(boolean);
+    method public deprecated void dispatchMultiWindowModeChanged(boolean);
+    method public void dispatchMultiWindowModeChanged(boolean, android.content.res.Configuration);
     method public boolean dispatchOptionsItemSelected(android.view.MenuItem);
     method public void dispatchOptionsMenuClosed(android.view.Menu);
     method public void dispatchPause();
-    method public void dispatchPictureInPictureModeChanged(boolean);
+    method public deprecated void dispatchPictureInPictureModeChanged(boolean);
+    method public void dispatchPictureInPictureModeChanged(boolean, android.content.res.Configuration);
     method public boolean dispatchPrepareOptionsMenu(android.view.Menu);
     method public void dispatchResume();
     method public void dispatchStart();
@@ -45992,7 +45998,6 @@
     method public static deprecated int getEdgeSlop();
     method public static deprecated int getFadingEdgeLength();
     method public static deprecated long getGlobalActionKeyTimeout();
-    method public float getScaledHorizontalScrollFactor();
     method public static int getJumpTapTimeout();
     method public static int getKeyRepeatDelay();
     method public static int getKeyRepeatTimeout();
@@ -46004,6 +46009,7 @@
     method public int getScaledDoubleTapSlop();
     method public int getScaledEdgeSlop();
     method public int getScaledFadingEdgeLength();
+    method public float getScaledHorizontalScrollFactor();
     method public int getScaledMaximumDrawingCacheSize();
     method public int getScaledMaximumFlingVelocity();
     method public int getScaledMinimumFlingVelocity();
@@ -46012,6 +46018,7 @@
     method public int getScaledPagingTouchSlop();
     method public int getScaledScrollBarSize();
     method public int getScaledTouchSlop();
+    method public float getScaledVerticalScrollFactor();
     method public int getScaledWindowTouchSlop();
     method public static int getScrollBarFadeDuration();
     method public static deprecated int getScrollBarSize();
@@ -46019,7 +46026,6 @@
     method public static float getScrollFriction();
     method public static int getTapTimeout();
     method public static deprecated int getTouchSlop();
-    method public float getScaledVerticalScrollFactor();
     method public static deprecated int getWindowTouchSlop();
     method public static long getZoomControlsTimeout();
     method public boolean hasPermanentMenuKey();
diff --git a/api/system-current.txt b/api/system-current.txt
index ac1597f..13e843f 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -182,7 +182,7 @@
     field public static final java.lang.String READ_LOGS = "android.permission.READ_LOGS";
     field public static final java.lang.String READ_NETWORK_USAGE_HISTORY = "android.permission.READ_NETWORK_USAGE_HISTORY";
     field public static final java.lang.String READ_OEM_UNLOCK_STATE = "android.permission.READ_OEM_UNLOCK_STATE";
-    field public static final java.lang.String READ_PHONE_NUMBER = "android.permission.READ_PHONE_NUMBER";
+    field public static final java.lang.String READ_PHONE_NUMBERS = "android.permission.READ_PHONE_NUMBERS";
     field public static final java.lang.String READ_PHONE_STATE = "android.permission.READ_PHONE_STATE";
     field public static final java.lang.String READ_PRIVILEGED_PHONE_STATE = "android.permission.READ_PRIVILEGED_PHONE_STATE";
     field public static final java.lang.String READ_SEARCH_INDEXABLES = "android.permission.READ_SEARCH_INDEXABLES";
@@ -3801,7 +3801,8 @@
     method public boolean onMenuItemSelected(int, android.view.MenuItem);
     method public boolean onMenuOpened(int, android.view.Menu);
     method public void onMovedToDisplay(int, android.content.res.Configuration);
-    method public void onMultiWindowModeChanged(boolean);
+    method public void onMultiWindowModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onMultiWindowModeChanged(boolean);
     method public boolean onNavigateUp();
     method public boolean onNavigateUpFromChild(android.app.Activity);
     method protected void onNewIntent(android.content.Intent);
@@ -3809,7 +3810,8 @@
     method public void onOptionsMenuClosed(android.view.Menu);
     method public void onPanelClosed(int, android.view.Menu);
     method protected void onPause();
-    method public void onPictureInPictureModeChanged(boolean);
+    method public void onPictureInPictureModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onPictureInPictureModeChanged(boolean);
     method protected void onPostCreate(android.os.Bundle);
     method public void onPostCreate(android.os.Bundle, android.os.PersistableBundle);
     method protected void onPostResume();
@@ -4325,7 +4327,7 @@
     field public static final java.lang.String OPSTR_READ_CELL_BROADCASTS = "android:read_cell_broadcasts";
     field public static final java.lang.String OPSTR_READ_CONTACTS = "android:read_contacts";
     field public static final java.lang.String OPSTR_READ_EXTERNAL_STORAGE = "android:read_external_storage";
-    field public static final java.lang.String OPSTR_READ_PHONE_NUMBER = "android:read_phone_number";
+    field public static final java.lang.String OPSTR_READ_PHONE_NUMBERS = "android:read_phone_numbers";
     field public static final java.lang.String OPSTR_READ_PHONE_STATE = "android:read_phone_state";
     field public static final java.lang.String OPSTR_READ_SMS = "android:read_sms";
     field public static final java.lang.String OPSTR_RECEIVE_MMS = "android:receive_mms";
@@ -4775,11 +4777,13 @@
     method public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle);
     method public deprecated void onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle);
     method public void onLowMemory();
-    method public void onMultiWindowModeChanged(boolean);
+    method public void onMultiWindowModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onMultiWindowModeChanged(boolean);
     method public boolean onOptionsItemSelected(android.view.MenuItem);
     method public void onOptionsMenuClosed(android.view.Menu);
     method public void onPause();
-    method public void onPictureInPictureModeChanged(boolean);
+    method public void onPictureInPictureModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onPictureInPictureModeChanged(boolean);
     method public void onPrepareOptionsMenu(android.view.Menu);
     method public void onRequestPermissionsResult(int, java.lang.String[], int[]);
     method public void onResume();
@@ -4864,11 +4868,13 @@
     method public void dispatchDestroy();
     method public void dispatchDestroyView();
     method public void dispatchLowMemory();
-    method public void dispatchMultiWindowModeChanged(boolean);
+    method public deprecated void dispatchMultiWindowModeChanged(boolean);
+    method public void dispatchMultiWindowModeChanged(boolean, android.content.res.Configuration);
     method public boolean dispatchOptionsItemSelected(android.view.MenuItem);
     method public void dispatchOptionsMenuClosed(android.view.Menu);
     method public void dispatchPause();
-    method public void dispatchPictureInPictureModeChanged(boolean);
+    method public deprecated void dispatchPictureInPictureModeChanged(boolean);
+    method public void dispatchPictureInPictureModeChanged(boolean, android.content.res.Configuration);
     method public boolean dispatchPrepareOptionsMenu(android.view.Menu);
     method public void dispatchResume();
     method public void dispatchStart();
@@ -9763,6 +9769,8 @@
     field public static final java.lang.String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
     field public static final java.lang.String ACTION_CALL = "android.intent.action.CALL";
     field public static final java.lang.String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
+    field public static final java.lang.String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
+    field public static final java.lang.String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
     field public static final java.lang.String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
     field public static final java.lang.String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
     field public static final java.lang.String ACTION_CHOOSER = "android.intent.action.CHOOSER";
@@ -49449,7 +49457,6 @@
     method public static deprecated int getEdgeSlop();
     method public static deprecated int getFadingEdgeLength();
     method public static deprecated long getGlobalActionKeyTimeout();
-    method public float getScaledHorizontalScrollFactor();
     method public static int getJumpTapTimeout();
     method public static int getKeyRepeatDelay();
     method public static int getKeyRepeatTimeout();
@@ -49461,6 +49468,7 @@
     method public int getScaledDoubleTapSlop();
     method public int getScaledEdgeSlop();
     method public int getScaledFadingEdgeLength();
+    method public float getScaledHorizontalScrollFactor();
     method public int getScaledMaximumDrawingCacheSize();
     method public int getScaledMaximumFlingVelocity();
     method public int getScaledMinimumFlingVelocity();
@@ -49469,6 +49477,7 @@
     method public int getScaledPagingTouchSlop();
     method public int getScaledScrollBarSize();
     method public int getScaledTouchSlop();
+    method public float getScaledVerticalScrollFactor();
     method public int getScaledWindowTouchSlop();
     method public static int getScrollBarFadeDuration();
     method public static deprecated int getScrollBarSize();
@@ -49476,7 +49485,6 @@
     method public static float getScrollFriction();
     method public static int getTapTimeout();
     method public static deprecated int getTouchSlop();
-    method public float getScaledVerticalScrollFactor();
     method public static deprecated int getWindowTouchSlop();
     method public static long getZoomControlsTimeout();
     method public boolean hasPermanentMenuKey();
diff --git a/api/test-current.txt b/api/test-current.txt
index fc3c9e7..7b56071 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -104,7 +104,7 @@
     field public static final java.lang.String READ_FRAME_BUFFER = "android.permission.READ_FRAME_BUFFER";
     field public static final deprecated java.lang.String READ_INPUT_STATE = "android.permission.READ_INPUT_STATE";
     field public static final java.lang.String READ_LOGS = "android.permission.READ_LOGS";
-    field public static final java.lang.String READ_PHONE_NUMBER = "android.permission.READ_PHONE_NUMBER";
+    field public static final java.lang.String READ_PHONE_NUMBERS = "android.permission.READ_PHONE_NUMBERS";
     field public static final java.lang.String READ_PHONE_STATE = "android.permission.READ_PHONE_STATE";
     field public static final java.lang.String READ_SMS = "android.permission.READ_SMS";
     field public static final java.lang.String READ_SYNC_SETTINGS = "android.permission.READ_SYNC_SETTINGS";
@@ -3677,7 +3677,8 @@
     method public boolean onMenuItemSelected(int, android.view.MenuItem);
     method public boolean onMenuOpened(int, android.view.Menu);
     method public void onMovedToDisplay(int, android.content.res.Configuration);
-    method public void onMultiWindowModeChanged(boolean);
+    method public void onMultiWindowModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onMultiWindowModeChanged(boolean);
     method public boolean onNavigateUp();
     method public boolean onNavigateUpFromChild(android.app.Activity);
     method protected void onNewIntent(android.content.Intent);
@@ -3685,7 +3686,8 @@
     method public void onOptionsMenuClosed(android.view.Menu);
     method public void onPanelClosed(int, android.view.Menu);
     method protected void onPause();
-    method public void onPictureInPictureModeChanged(boolean);
+    method public void onPictureInPictureModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onPictureInPictureModeChanged(boolean);
     method protected void onPostCreate(android.os.Bundle);
     method public void onPostCreate(android.os.Bundle, android.os.PersistableBundle);
     method protected void onPostResume();
@@ -4192,7 +4194,7 @@
     field public static final java.lang.String OPSTR_READ_CELL_BROADCASTS = "android:read_cell_broadcasts";
     field public static final java.lang.String OPSTR_READ_CONTACTS = "android:read_contacts";
     field public static final java.lang.String OPSTR_READ_EXTERNAL_STORAGE = "android:read_external_storage";
-    field public static final java.lang.String OPSTR_READ_PHONE_NUMBER = "android:read_phone_number";
+    field public static final java.lang.String OPSTR_READ_PHONE_NUMBERS = "android:read_phone_numbers";
     field public static final java.lang.String OPSTR_READ_PHONE_STATE = "android:read_phone_state";
     field public static final java.lang.String OPSTR_READ_SMS = "android:read_sms";
     field public static final java.lang.String OPSTR_RECEIVE_MMS = "android:receive_mms";
@@ -4628,11 +4630,13 @@
     method public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle);
     method public deprecated void onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle);
     method public void onLowMemory();
-    method public void onMultiWindowModeChanged(boolean);
+    method public void onMultiWindowModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onMultiWindowModeChanged(boolean);
     method public boolean onOptionsItemSelected(android.view.MenuItem);
     method public void onOptionsMenuClosed(android.view.Menu);
     method public void onPause();
-    method public void onPictureInPictureModeChanged(boolean);
+    method public void onPictureInPictureModeChanged(boolean, android.content.res.Configuration);
+    method public deprecated void onPictureInPictureModeChanged(boolean);
     method public void onPrepareOptionsMenu(android.view.Menu);
     method public void onRequestPermissionsResult(int, java.lang.String[], int[]);
     method public void onResume();
@@ -4717,11 +4721,13 @@
     method public void dispatchDestroy();
     method public void dispatchDestroyView();
     method public void dispatchLowMemory();
-    method public void dispatchMultiWindowModeChanged(boolean);
+    method public deprecated void dispatchMultiWindowModeChanged(boolean);
+    method public void dispatchMultiWindowModeChanged(boolean, android.content.res.Configuration);
     method public boolean dispatchOptionsItemSelected(android.view.MenuItem);
     method public void dispatchOptionsMenuClosed(android.view.Menu);
     method public void dispatchPause();
-    method public void dispatchPictureInPictureModeChanged(boolean);
+    method public deprecated void dispatchPictureInPictureModeChanged(boolean);
+    method public void dispatchPictureInPictureModeChanged(boolean, android.content.res.Configuration);
     method public boolean dispatchPrepareOptionsMenu(android.view.Menu);
     method public void dispatchResume();
     method public void dispatchStart();
@@ -37522,6 +37528,7 @@
     ctor public TileService();
     method public final android.service.quicksettings.Tile getQsTile();
     method public final boolean isLocked();
+    method public static boolean isQuickSettingsSupported();
     method public final boolean isSecure();
     method public android.os.IBinder onBind(android.content.Intent);
     method public void onClick();
@@ -46369,7 +46376,6 @@
     method public static deprecated int getEdgeSlop();
     method public static deprecated int getFadingEdgeLength();
     method public static deprecated long getGlobalActionKeyTimeout();
-    method public float getScaledHorizontalScrollFactor();
     method public static int getHoverTooltipHideShortTimeout();
     method public static int getHoverTooltipHideTimeout();
     method public static int getHoverTooltipShowTimeout();
@@ -46385,6 +46391,7 @@
     method public int getScaledDoubleTapSlop();
     method public int getScaledEdgeSlop();
     method public int getScaledFadingEdgeLength();
+    method public float getScaledHorizontalScrollFactor();
     method public int getScaledMaximumDrawingCacheSize();
     method public int getScaledMaximumFlingVelocity();
     method public int getScaledMinimumFlingVelocity();
@@ -46393,6 +46400,7 @@
     method public int getScaledPagingTouchSlop();
     method public int getScaledScrollBarSize();
     method public int getScaledTouchSlop();
+    method public float getScaledVerticalScrollFactor();
     method public int getScaledWindowTouchSlop();
     method public static int getScrollBarFadeDuration();
     method public static deprecated int getScrollBarSize();
@@ -46400,7 +46408,6 @@
     method public static float getScrollFriction();
     method public static int getTapTimeout();
     method public static deprecated int getTouchSlop();
-    method public float getScaledVerticalScrollFactor();
     method public static deprecated int getWindowTouchSlop();
     method public static long getZoomControlsTimeout();
     method public boolean hasPermanentMenuKey();
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 147b5d0..dbf81f9 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1889,11 +1889,32 @@
 
     /**
      * Called by the system when the activity changes from fullscreen mode to multi-window mode and
-     * visa-versa.
+     * visa-versa. This method provides the same configuration that will be sent in the following
+     * {@link #onConfigurationChanged(Configuration)} call after the activity enters this mode.
+     *
      * @see android.R.attr#resizeableActivity
      *
      * @param isInMultiWindowMode True if the activity is in multi-window mode.
+     * @param newConfig The new configuration of the activity with the state
+     *                  {@param isInMultiWindowMode}.
      */
+    public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) {
+        // Left deliberately empty. There should be no side effects if a direct
+        // subclass of Activity does not call super.
+        onMultiWindowModeChanged(isInMultiWindowMode);
+    }
+
+    /**
+     * Called by the system when the activity changes from fullscreen mode to multi-window mode and
+     * visa-versa.
+     *
+     * @see android.R.attr#resizeableActivity
+     *
+     * @param isInMultiWindowMode True if the activity is in multi-window mode.
+     *
+     * @deprecated Use {@link #onMultiWindowModeChanged(boolean, Configuration)} instead.
+     */
+    @Deprecated
     public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
         // Left deliberately empty. There should be no side effects if a direct
         // subclass of Activity does not call super.
@@ -1914,11 +1935,33 @@
     }
 
     /**
-     * Called by the system when the activity changes to and from picture-in-picture mode.
+     * Called by the system when the activity changes to and from picture-in-picture mode. This
+     * method provides the same configuration that will be sent in the following
+     * {@link #onConfigurationChanged(Configuration)} call after the activity enters this mode.
+     *
      * @see android.R.attr#supportsPictureInPicture
      *
      * @param isInPictureInPictureMode True if the activity is in picture-in-picture mode.
+     * @param newConfig The new configuration of the activity with the state
+     *                  {@param isInPictureInPictureMode}.
      */
+    public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode,
+            Configuration newConfig) {
+        // Left deliberately empty. There should be no side effects if a direct
+        // subclass of Activity does not call super.
+        onPictureInPictureModeChanged(isInPictureInPictureMode);
+    }
+
+    /**
+     * Called by the system when the activity changes to and from picture-in-picture mode.
+     *
+     * @see android.R.attr#supportsPictureInPicture
+     *
+     * @param isInPictureInPictureMode True if the activity is in picture-in-picture mode.
+     *
+     * @deprecated Use {@link #onPictureInPictureModeChanged(boolean, Configuration)} instead.
+     */
+    @Deprecated
     public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
         // Left deliberately empty. There should be no side effects if a direct
         // subclass of Activity does not call super.
@@ -6993,21 +7036,25 @@
         }
     }
 
-    final void dispatchMultiWindowModeChanged(boolean isInMultiWindowMode) {
+    final void dispatchMultiWindowModeChanged(boolean isInMultiWindowMode,
+            Configuration newConfig) {
         if (DEBUG_LIFECYCLE) Slog.v(TAG,
-                "dispatchMultiWindowModeChanged " + this + ": " + isInMultiWindowMode);
-        mFragments.dispatchMultiWindowModeChanged(isInMultiWindowMode);
+                "dispatchMultiWindowModeChanged " + this + ": " + isInMultiWindowMode
+                        + " " + newConfig);
+        mFragments.dispatchMultiWindowModeChanged(isInMultiWindowMode, newConfig);
         if (mWindow != null) {
             mWindow.onMultiWindowModeChanged();
         }
-        onMultiWindowModeChanged(isInMultiWindowMode);
+        onMultiWindowModeChanged(isInMultiWindowMode, newConfig);
     }
 
-    final void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
+    final void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode,
+            Configuration newConfig) {
         if (DEBUG_LIFECYCLE) Slog.v(TAG,
-                "dispatchPictureInPictureModeChanged " + this + ": " + isInPictureInPictureMode);
-        mFragments.dispatchPictureInPictureModeChanged(isInPictureInPictureMode);
-        onPictureInPictureModeChanged(isInPictureInPictureMode);
+                "dispatchPictureInPictureModeChanged " + this + ": " + isInPictureInPictureMode
+                        + " " + newConfig);
+        mFragments.dispatchPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
+        onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
     }
 
     /**
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index b5d1fa8..e49aad2 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -1411,15 +1411,23 @@
         }
 
         @Override
-        public void scheduleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode)
-                throws RemoteException {
-            sendMessage(H.MULTI_WINDOW_MODE_CHANGED, token, isInMultiWindowMode ? 1 : 0);
+        public void scheduleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode,
+                Configuration overrideConfig) throws RemoteException {
+            SomeArgs args = SomeArgs.obtain();
+            args.arg1 = token;
+            args.arg2 = overrideConfig;
+            args.argi1 = isInMultiWindowMode ? 1 : 0;
+            sendMessage(H.MULTI_WINDOW_MODE_CHANGED, args);
         }
 
         @Override
-        public void schedulePictureInPictureModeChanged(IBinder token, boolean isInPipMode)
-                throws RemoteException {
-            sendMessage(H.PICTURE_IN_PICTURE_MODE_CHANGED, token, isInPipMode ? 1 : 0);
+        public void schedulePictureInPictureModeChanged(IBinder token, boolean isInPipMode,
+                Configuration overrideConfig) throws RemoteException {
+            SomeArgs args = SomeArgs.obtain();
+            args.arg1 = token;
+            args.arg2 = overrideConfig;
+            args.argi1 = isInPipMode ? 1 : 0;
+            sendMessage(H.PICTURE_IN_PICTURE_MODE_CHANGED, args);
         }
 
         @Override
@@ -1816,10 +1824,14 @@
                     handleStopBinderTrackingAndDump((ParcelFileDescriptor) msg.obj);
                     break;
                 case MULTI_WINDOW_MODE_CHANGED:
-                    handleMultiWindowModeChanged((IBinder) msg.obj, msg.arg1 == 1);
+                    handleMultiWindowModeChanged((IBinder) ((SomeArgs) msg.obj).arg1,
+                            ((SomeArgs) msg.obj).argi1 == 1,
+                            (Configuration) ((SomeArgs) msg.obj).arg2);
                     break;
                 case PICTURE_IN_PICTURE_MODE_CHANGED:
-                    handlePictureInPictureModeChanged((IBinder) msg.obj, msg.arg1 == 1);
+                    handlePictureInPictureModeChanged((IBinder) ((SomeArgs) msg.obj).arg1,
+                            ((SomeArgs) msg.obj).argi1 == 1,
+                            (Configuration) ((SomeArgs) msg.obj).arg2);
                     break;
                 case LOCAL_VOICE_INTERACTION_STARTED:
                     handleLocalVoiceInteractionStarted((IBinder) ((SomeArgs) msg.obj).arg1,
@@ -3119,17 +3131,27 @@
         }
     }
 
-    private void handleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode) {
+    private void handleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode,
+            Configuration overrideConfig) {
         final ActivityClientRecord r = mActivities.get(token);
         if (r != null) {
-            r.activity.dispatchMultiWindowModeChanged(isInMultiWindowMode);
+            final Configuration newConfig = new Configuration(mConfiguration);
+            if (overrideConfig != null) {
+                newConfig.updateFrom(overrideConfig);
+            }
+            r.activity.dispatchMultiWindowModeChanged(isInMultiWindowMode, newConfig);
         }
     }
 
-    private void handlePictureInPictureModeChanged(IBinder token, boolean isInPipMode) {
+    private void handlePictureInPictureModeChanged(IBinder token, boolean isInPipMode,
+            Configuration overrideConfig) {
         final ActivityClientRecord r = mActivities.get(token);
         if (r != null) {
-            r.activity.dispatchPictureInPictureModeChanged(isInPipMode);
+            final Configuration newConfig = new Configuration(mConfiguration);
+            if (overrideConfig != null) {
+                newConfig.updateFrom(overrideConfig);
+            }
+            r.activity.dispatchPictureInPictureModeChanged(isInPipMode, newConfig);
         }
     }
 
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index cbd7b9d..8292152 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -242,7 +242,7 @@
     /** @hide */
     public static final int OP_AUDIO_ACCESSIBILITY_VOLUME = 64;
     /** @hide Read the phone number. */
-    public static final int OP_READ_PHONE_NUMBER = 65;
+    public static final int OP_READ_PHONE_NUMBERS = 65;
     /** @hide Request package installs through package installer */
     public static final int OP_REQUEST_INSTALL_PACKAGES = 66;
     /** @hide Enter picture-in-picture. */
@@ -353,8 +353,8 @@
     /** @hide Get device accounts. */
     public static final String OPSTR_GET_ACCOUNTS
             = "android:get_accounts";
-    public static final String OPSTR_READ_PHONE_NUMBER
-            = "android:read_phone_number";
+    public static final String OPSTR_READ_PHONE_NUMBERS
+            = "android:read_phone_numbers";
     /** Access to picture-in-picture. */
     public static final String OPSTR_PICTURE_IN_PICTURE
             = "android:picture_in_picture";
@@ -391,7 +391,7 @@
             OP_FINE_LOCATION,
             // Phone
             OP_READ_PHONE_STATE,
-            OP_READ_PHONE_NUMBER,
+            OP_READ_PHONE_NUMBERS,
             OP_CALL_PHONE,
             OP_READ_CALL_LOG,
             OP_WRITE_CALL_LOG,
@@ -487,7 +487,7 @@
             OP_GET_ACCOUNTS,
             OP_RUN_IN_BACKGROUND,
             OP_AUDIO_ACCESSIBILITY_VOLUME,
-            OP_READ_PHONE_NUMBER,
+            OP_READ_PHONE_NUMBERS,
             OP_REQUEST_INSTALL_PACKAGES,
             OP_PICTURE_IN_PICTURE,
             OP_INSTANT_APP_START_FOREGROUND,
@@ -564,7 +564,7 @@
             OPSTR_GET_ACCOUNTS,
             null,
             null, // OP_AUDIO_ACCESSIBILITY_VOLUME
-            OPSTR_READ_PHONE_NUMBER,
+            OPSTR_READ_PHONE_NUMBERS,
             null, // OP_REQUEST_INSTALL_PACKAGES
             OPSTR_PICTURE_IN_PICTURE,
             OPSTR_INSTANT_APP_START_FOREGROUND,
@@ -641,7 +641,7 @@
             "GET_ACCOUNTS",
             "RUN_IN_BACKGROUND",
             "AUDIO_ACCESSIBILITY_VOLUME",
-            "READ_PHONE_NUMBER",
+            "READ_PHONE_NUMBERS",
             "REQUEST_INSTALL_PACKAGES",
             "PICTURE_IN_PICTURE",
             "INSTANT_APP_START_FOREGROUND",
@@ -718,7 +718,7 @@
             Manifest.permission.GET_ACCOUNTS,
             null, // no permission for running in background
             null, // no permission for changing accessibility volume
-            Manifest.permission.READ_PHONE_NUMBER,
+            Manifest.permission.READ_PHONE_NUMBERS,
             Manifest.permission.REQUEST_INSTALL_PACKAGES,
             null, // no permission for entering picture-in-picture on hide
             Manifest.permission.INSTANT_APP_FOREGROUND_SERVICE,
@@ -796,7 +796,7 @@
             null, // GET_ACCOUNTS
             null, // RUN_IN_BACKGROUND
             UserManager.DISALLOW_ADJUST_VOLUME, //AUDIO_ACCESSIBILITY_VOLUME
-            null, // READ_PHONE_NUMBER
+            null, // READ_PHONE_NUMBERS
             null, // REQUEST_INSTALL_PACKAGES
             null, // ENTER_PICTURE_IN_PICTURE_ON_HIDE
             null, // INSTANT_APP_START_FOREGROUND
@@ -873,7 +873,7 @@
             false, // GET_ACCOUNTS
             false, // RUN_IN_BACKGROUND
             false, // AUDIO_ACCESSIBILITY_VOLUME
-            false, // READ_PHONE_NUMBER
+            false, // READ_PHONE_NUMBERS
             false, // REQUEST_INSTALL_PACKAGES
             false, // ENTER_PICTURE_IN_PICTURE_ON_HIDE
             false, // INSTANT_APP_START_FOREGROUND
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index 02fe101..3102a93 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -1716,19 +1716,55 @@
     /**
      * Called when the Fragment's activity changes from fullscreen mode to multi-window mode and
      * visa-versa. This is generally tied to {@link Activity#onMultiWindowModeChanged} of the
+     * containing Activity. This method provides the same configuration that will be sent in the
+     * following {@link #onConfigurationChanged(Configuration)} call after the activity enters this
+     * mode.
+     *
+     * @param isInMultiWindowMode True if the activity is in multi-window mode.
+     * @param newConfig The new configuration of the activity with the state
+     *                  {@param isInMultiWindowMode}.
+     */
+    public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) {
+        onMultiWindowModeChanged(isInMultiWindowMode);
+    }
+
+    /**
+     * Called when the Fragment's activity changes from fullscreen mode to multi-window mode and
+     * visa-versa. This is generally tied to {@link Activity#onMultiWindowModeChanged} of the
      * containing Activity.
      *
      * @param isInMultiWindowMode True if the activity is in multi-window mode.
+     *
+     * @deprecated Use {@link #onMultiWindowModeChanged(boolean, Configuration)} instead.
      */
+    @Deprecated
     public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
     }
 
     /**
      * Called by the system when the activity changes to and from picture-in-picture mode. This is
      * generally tied to {@link Activity#onPictureInPictureModeChanged} of the containing Activity.
+     * This method provides the same configuration that will be sent in the following
+     * {@link #onConfigurationChanged(Configuration)} call after the activity enters this mode.
+     *
+     * @param isInPictureInPictureMode True if the activity is in picture-in-picture mode.
+     * @param newConfig The new configuration of the activity with the state
+     *                  {@param isInPictureInPictureMode}.
+     */
+    public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode,
+            Configuration newConfig) {
+        onPictureInPictureModeChanged(isInPictureInPictureMode);
+    }
+
+    /**
+     * Called by the system when the activity changes to and from picture-in-picture mode. This is
+     * generally tied to {@link Activity#onPictureInPictureModeChanged} of the containing Activity.
      *
      * @param isInPictureInPictureMode True if the activity is in picture-in-picture mode.
+     *
+     * @deprecated Use {@link #onPictureInPictureModeChanged(boolean, Configuration)} instead.
      */
+    @Deprecated
     public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
     }
 
@@ -2572,6 +2608,7 @@
         }
     }
 
+    @Deprecated
     void performMultiWindowModeChanged(boolean isInMultiWindowMode) {
         onMultiWindowModeChanged(isInMultiWindowMode);
         if (mChildFragmentManager != null) {
@@ -2579,6 +2616,14 @@
         }
     }
 
+    void performMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) {
+        onMultiWindowModeChanged(isInMultiWindowMode, newConfig);
+        if (mChildFragmentManager != null) {
+            mChildFragmentManager.dispatchMultiWindowModeChanged(isInMultiWindowMode, newConfig);
+        }
+    }
+
+    @Deprecated
     void performPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
         onPictureInPictureModeChanged(isInPictureInPictureMode);
         if (mChildFragmentManager != null) {
@@ -2586,6 +2631,15 @@
         }
     }
 
+    void performPictureInPictureModeChanged(boolean isInPictureInPictureMode,
+            Configuration newConfig) {
+        onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
+        if (mChildFragmentManager != null) {
+            mChildFragmentManager.dispatchPictureInPictureModeChanged(isInPictureInPictureMode,
+                    newConfig);
+        }
+    }
+
     void performConfigurationChanged(Configuration newConfig) {
         onConfigurationChanged(newConfig);
         if (mChildFragmentManager != null) {
diff --git a/core/java/android/app/FragmentController.java b/core/java/android/app/FragmentController.java
index 9ea15a0..cff94d8 100644
--- a/core/java/android/app/FragmentController.java
+++ b/core/java/android/app/FragmentController.java
@@ -250,20 +250,49 @@
      * <p>Call when the multi-window mode of the activity changed.
      *
      * @see Fragment#onMultiWindowModeChanged
+     * @deprecated use {@link #dispatchMultiWindowModeChanged(boolean, Configuration)}
      */
+    @Deprecated
     public void dispatchMultiWindowModeChanged(boolean isInMultiWindowMode) {
         mHost.mFragmentManager.dispatchMultiWindowModeChanged(isInMultiWindowMode);
     }
 
     /**
+     * Lets all Fragments managed by the controller's FragmentManager know the multi-window mode of
+     * the activity changed.
+     * <p>Call when the multi-window mode of the activity changed.
+     *
+     * @see Fragment#onMultiWindowModeChanged
+     */
+    public void dispatchMultiWindowModeChanged(boolean isInMultiWindowMode,
+            Configuration newConfig) {
+        mHost.mFragmentManager.dispatchMultiWindowModeChanged(isInMultiWindowMode, newConfig);
+    }
+
+    /**
+     * Lets all Fragments managed by the controller's FragmentManager know the picture-in-picture
+     * mode of the activity changed.
+     * <p>Call when the picture-in-picture mode of the activity changed.
+     *
+     * @see Fragment#onPictureInPictureModeChanged
+     * @deprecated use {@link #dispatchPictureInPictureModeChanged(boolean, Configuration)}
+     */
+    @Deprecated
+    public void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
+        mHost.mFragmentManager.dispatchPictureInPictureModeChanged(isInPictureInPictureMode);
+    }
+
+    /**
      * Lets all Fragments managed by the controller's FragmentManager know the picture-in-picture
      * mode of the activity changed.
      * <p>Call when the picture-in-picture mode of the activity changed.
      *
      * @see Fragment#onPictureInPictureModeChanged
      */
-    public void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
-        mHost.mFragmentManager.dispatchPictureInPictureModeChanged(isInPictureInPictureMode);
+    public void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode,
+            Configuration newConfig) {
+        mHost.mFragmentManager.dispatchPictureInPictureModeChanged(isInPictureInPictureMode,
+                newConfig);
     }
 
     /**
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 0c1be07..279b900 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -1844,6 +1844,10 @@
         }
         synchronized (this) {
             if (mDestroyed || mHost == null) {
+                if (allowStateLoss) {
+                    // This FragmentManager isn't attached, so drop the entire transaction.
+                    return;
+                }
                 throw new IllegalStateException("Activity has been destroyed");
             }
             if (mPendingActions == null) {
@@ -1960,6 +1964,10 @@
     }
 
     public void execSingleAction(OpGenerator action, boolean allowStateLoss) {
+        if (allowStateLoss && (mHost == null || mDestroyed)) {
+            // This FragmentManager isn't attached, so drop the entire transaction.
+            return;
+        }
         ensureExecReady(allowStateLoss);
         if (action.generateOps(mTmpRecords, mTmpIsPop)) {
             mExecutingActions = true;
@@ -2944,6 +2952,10 @@
         }
     }
 
+    /**
+     * @deprecated use {@link #dispatchMultiWindowModeChanged(boolean, Configuration)}
+     */
+    @Deprecated
     public void dispatchMultiWindowModeChanged(boolean isInMultiWindowMode) {
         if (mAdded == null) {
             return;
@@ -2956,6 +2968,23 @@
         }
     }
 
+    public void dispatchMultiWindowModeChanged(boolean isInMultiWindowMode,
+            Configuration newConfig) {
+        if (mAdded == null) {
+            return;
+        }
+        for (int i = mAdded.size() - 1; i >= 0; --i) {
+            final Fragment f = mAdded.get(i);
+            if (f != null) {
+                f.performMultiWindowModeChanged(isInMultiWindowMode, newConfig);
+            }
+        }
+    }
+
+    /**
+     * @deprecated use {@link #dispatchPictureInPictureModeChanged(boolean, Configuration)}
+     */
+    @Deprecated
     public void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
         if (mAdded == null) {
             return;
@@ -2968,6 +2997,19 @@
         }
     }
 
+    public void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode,
+            Configuration newConfig) {
+        if (mAdded == null) {
+            return;
+        }
+        for (int i = mAdded.size() - 1; i >= 0; --i) {
+            final Fragment f = mAdded.get(i);
+            if (f != null) {
+                f.performPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
+            }
+        }
+    }
+
     public void dispatchConfigurationChanged(Configuration newConfig) {
         if (mAdded != null) {
             for (int i=0; i<mAdded.size(); i++) {
diff --git a/core/java/android/app/IApplicationThread.aidl b/core/java/android/app/IApplicationThread.aidl
index e99691d..6c43fe3 100644
--- a/core/java/android/app/IApplicationThread.aidl
+++ b/core/java/android/app/IApplicationThread.aidl
@@ -146,9 +146,10 @@
     void notifyCleartextNetwork(in byte[] firstPacket);
     void startBinderTracking();
     void stopBinderTrackingAndDump(in ParcelFileDescriptor fd);
-    void scheduleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode);
-    void schedulePictureInPictureModeChanged(IBinder token,
-            boolean isInPictureInPictureMode);
+    void scheduleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode,
+            in Configuration newConfig);
+    void schedulePictureInPictureModeChanged(IBinder token, boolean isInPictureInPictureMode,
+            in Configuration newConfig);
     void scheduleLocalVoiceInteractionStarted(IBinder token,
             IVoiceInteractor voiceInteractor);
     void handleTrustStorageUpdate();
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 116224b..81aea8d 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1093,6 +1093,8 @@
      * <p>Output: nothing.
      * @hide
      */
+    @SystemApi
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
     public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
     /**
      * Activity action: Perform a call to any number (emergency or not)
@@ -1102,6 +1104,8 @@
      * <p>Output: nothing.
      * @hide
      */
+    @SystemApi
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
     public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
 
     /**
diff --git a/core/java/android/service/quicksettings/TileService.java b/core/java/android/service/quicksettings/TileService.java
index 8e01030..56b267f 100644
--- a/core/java/android/service/quicksettings/TileService.java
+++ b/core/java/android/service/quicksettings/TileService.java
@@ -19,11 +19,13 @@
 import android.annotation.SdkConstant;
 import android.annotation.SdkConstant.SdkConstantType;
 import android.annotation.SystemApi;
+import android.annotation.TestApi;
 import android.app.Dialog;
 import android.app.Service;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.res.Resources;
 import android.graphics.drawable.Icon;
 import android.os.Handler;
 import android.os.IBinder;
@@ -34,6 +36,8 @@
 import android.view.View.OnAttachStateChangeListener;
 import android.view.WindowManager;
 
+import com.android.internal.R;
+
 /**
  * A TileService provides the user a tile that can be added to Quick Settings.
  * Quick Settings is a space provided that allows the user to change settings and
@@ -425,6 +429,15 @@
     }
 
     /**
+     * @return True if the device supports quick settings and its assocated APIs.
+     * @hide
+     */
+    @TestApi
+    public static boolean isQuickSettingsSupported() {
+        return Resources.getSystem().getBoolean(R.bool.config_quickSettingsSupported);
+    }
+
+    /**
      * Requests that a tile be put in the listening state so it can send an update.
      *
      * This method is only applicable to tiles that have {@link #META_DATA_ACTIVE_TILE} defined
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 362794e..ffcb8476 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -798,13 +798,13 @@
         android:description="@string/permdesc_readPhoneState"
         android:protectionLevel="dangerous" />
 
-    <!-- Allows read access to the device's phone number. This is a subset of the capabilities
+    <!-- Allows read access to the device's phone number(s). This is a subset of the capabilities
          granted by {@link #READ_PHONE_STATE} but is exposed to ephemeral applications.
          <p>Protection level: dangerous-->
-    <permission android:name="android.permission.READ_PHONE_NUMBER"
+    <permission android:name="android.permission.READ_PHONE_NUMBERS"
         android:permissionGroup="android.permission-group.PHONE"
         android:label="@string/permlab_readPhoneNumber"
-        android:description="@string/permdesc_readPhoneNumber"
+        android:description="@string/permdesc_readPhoneNumbers"
         android:protectionLevel="dangerous|ephemeral" />
 
     <!-- Allows an application to initiate a phone call without going through
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index bcd8a8a..85ecaff 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2819,4 +2819,7 @@
          density will be scaled accordingly to maintain aspect ratio. A value of 0 indicates no
          constraint will be enforced. -->
     <integer name="config_maxUiWidth">0</integer>
+
+    <!-- Whether the device supports quick settings and its associated APIs -->
+    <bool name="config_quickSettingsSupported">true</bool>
 </resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 4afa8dc..831cf89 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -20,10 +20,8 @@
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <!-- Suffix added to a number to signify size in bytes. -->
     <string name="byteShort">B</string>
-    <!-- Suffix added to a number to signify size in kilobytes (1000 bytes).
-        If you retain the Latin script for the localization, please use the lowercase
-        'k', as it signifies 1000 bytes as opposed to 1024 bytes. -->
-    <string name="kilobyteShort">kB</string>
+    <!-- Suffix added to a number to signify size in kilobytes (1000 bytes). -->
+    <string name="kilobyteShort">KB</string>
     <!-- Suffix added to a number to signify size in megabytes. -->
     <string name="megabyteShort">MB</string>
     <!-- Suffix added to a number to signify size in gigabytes. -->
@@ -1094,9 +1092,9 @@
         order to improve the calling experience.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permlab_readPhoneNumber">read phone number</string>
+    <string name="permlab_readPhoneNumbers">read phone numbers</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_readPhoneNumber">Allows the app to access the phone number of the device.</string>
+    <string name="permdesc_readPhoneNumbers">Allows the app to access the phone numbers of the device.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_wakeLock" product="tablet">prevent tablet from sleeping</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index dfd18e7..ae05a69 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2955,4 +2955,5 @@
   <java-symbol type="string" name="etws_primary_default_message_test" />
 
   <java-symbol type="string" name="etws_primary_default_message_others" />
+  <java-symbol type="bool" name="config_quickSettingsSupported" />
 </resources>
diff --git a/packages/SettingsLib/res/values/attrs.xml b/packages/SettingsLib/res/values/attrs.xml
index 1f35d3e..ea538fb 100644
--- a/packages/SettingsLib/res/values/attrs.xml
+++ b/packages/SettingsLib/res/values/attrs.xml
@@ -36,6 +36,9 @@
     <declare-styleable name="WifiEncryptionState">
         <attr name="state_encrypted" format="boolean" />
     </declare-styleable>
+    <declare-styleable name="WifiMeteredState">
+        <attr name="state_metered" format="boolean" />
+    </declare-styleable>
     <declare-styleable name="WifiSavedState">
         <attr name="state_saved" format="boolean" />
     </declare-styleable>
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
index 0f443d6..61ca13d 100755
--- a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
+++ b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
@@ -63,7 +63,7 @@
             mPlusPaint;
     private float mTextHeight, mWarningTextHeight;
     private int mIconTint = Color.WHITE;
-    private float mOldDarkIntensity = 0f;
+    private float mOldDarkIntensity = -1f;
 
     private int mHeight;
     private int mWidth;
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java
index a9aaa05..8f8167e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java
@@ -44,6 +44,10 @@
             R.attr.state_encrypted
     };
 
+    private static final int[] STATE_METERED = {
+            R.attr.state_metered
+    };
+
     private static final int[] wifi_friction_attributes = { R.attr.wifi_friction };
 
     private final StateListDrawable mFrictionSld;
@@ -179,6 +183,8 @@
         }
         if (mAccessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
             mFrictionSld.setState(STATE_SECURED);
+        } else if (mAccessPoint.getConfig() != null && mAccessPoint.getConfig().meteredHint) {
+            mFrictionSld.setState(STATE_METERED);
         }
         Drawable drawable = mFrictionSld.getCurrent();
         frictionImageView.setImageDrawable(drawable);
diff --git a/packages/SystemUI/res/layout/menu_ime.xml b/packages/SystemUI/res/layout/menu_ime.xml
index 6bd79a4..8078c41 100644
--- a/packages/SystemUI/res/layout/menu_ime.xml
+++ b/packages/SystemUI/res/layout/menu_ime.xml
@@ -27,6 +27,7 @@
         android:layout_marginEnd="2dp"
         android:scaleType="centerInside"
         systemui:keyCode="82"
+        systemui:playSound="false"
         android:visibility="invisible"
         android:contentDescription="@string/accessibility_menu"
         />
diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml
index f405943..008fcf0 100644
--- a/packages/SystemUI/res/values/attrs.xml
+++ b/packages/SystemUI/res/values/attrs.xml
@@ -20,6 +20,8 @@
         <attr name="keyCode" format="integer" />
         <!-- does this button generate longpress / repeat events? -->
         <attr name="keyRepeat" format="boolean" />
+        <!-- Should this button play sound effects, default true -->
+        <attr name="playSound" format="boolean" />
         <attr name="android:contentDescription" />
     </declare-styleable>
     <declare-styleable name="ToggleSliderView">
diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
index 8c1062b..d57e88c 100644
--- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
+++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
@@ -98,6 +98,8 @@
         addView(mBatteryIconView, mlp);
 
         updateShowPercent();
+        // Init to not dark at all.
+        onDarkChanged(new Rect(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
     }
 
     public void setForceShowPercent(boolean show) {
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
index dd8cd2b..ad290c3 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
@@ -113,6 +113,7 @@
     private IWindowManager mWindowManager;
     private MediaSessionManager mMediaSessionManager;
     private int mState = STATE_NO_PIP;
+    private int mResumeResizePinnedStackRunnable = STATE_NO_PIP;
     private final Handler mHandler = new Handler();
     private List<Listener> mListeners = new ArrayList<>();
     private List<MediaListener> mMediaListeners = new ArrayList<>();
@@ -133,7 +134,7 @@
     private final Runnable mResizePinnedStackRunnable = new Runnable() {
         @Override
         public void run() {
-            resizePinnedStack(mState);
+            resizePinnedStack(mResumeResizePinnedStackRunnable);
         }
     };
     private final Runnable mClosePipRunnable = new Runnable() {
@@ -364,16 +365,17 @@
     void resizePinnedStack(int state) {
         if (DEBUG) Log.d(TAG, "resizePinnedStack() state=" + state);
         boolean wasStateNoPip = (mState == STATE_NO_PIP);
-        mState = state;
+        mResumeResizePinnedStackRunnable = state;
         for (int i = mListeners.size() - 1; i >= 0; --i) {
             mListeners.get(i).onPipResizeAboutToStart();
         }
         if (mSuspendPipResizingReason != 0) {
-            if (DEBUG) Log.d(TAG,
-                    "resizePinnedStack() deferring mSuspendPipResizingReason=" +
-                            mSuspendPipResizingReason);
+            if (DEBUG) Log.d(TAG, "resizePinnedStack() deferring"
+                    + " mSuspendPipResizingReason=" + mSuspendPipResizingReason
+                    + " mResumeResizePinnedStackRunnable=" + mResumeResizePinnedStackRunnable);
             return;
         }
+        mState = state;
         switch (mState) {
             case STATE_NO_PIP:
                 mCurrentPipBounds = null;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index 882902e..b5d22b1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -49,6 +49,7 @@
 
 public class KeyButtonView extends ImageView implements ButtonInterface {
 
+    private final boolean mPlaySounds;
     private int mContentDescriptionRes;
     private long mDownTime;
     private int mCode;
@@ -90,6 +91,7 @@
         mCode = a.getInteger(R.styleable.KeyButtonView_keyCode, 0);
 
         mSupportsLongpress = a.getBoolean(R.styleable.KeyButtonView_keyRepeat, true);
+        mPlaySounds = a.getBoolean(R.styleable.KeyButtonView_playSound, true);
 
         TypedValue value = new TypedValue();
         if (a.getValue(R.styleable.KeyButtonView_android_contentDescription, value)) {
@@ -241,8 +243,9 @@
     }
 
     public void playSoundEffect(int soundConstant) {
+        if (!mPlaySounds) return;
         mAudioManager.playSoundEffect(soundConstant, ActivityManager.getCurrentUser());
-    };
+    }
 
     public void sendEvent(int action, int flags) {
         sendEvent(action, flags, SystemClock.uptimeMillis());
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index da441f5..78bc01d 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -3188,21 +3188,21 @@
     // ACTION: Logged when a provisioning session has completed
     PROVISIONING_SESSION_COMPLETED = 735;
 
-    // ACTION: An app requested the permission READ_PHONE_NUMBER
+    // ACTION: An app requested the permission READ_PHONE_NUMBERS
     // PACKAGE: The package name of the app requesting the permission
-    ACTION_PERMISSION_REQUEST_READ_PHONE_NUMBER = 736;
+    ACTION_PERMISSION_REQUEST_READ_PHONE_NUMBERS = 736;
 
-    // ACTION: An app was granted the permission READ_PHONE_NUMBER
+    // ACTION: An app was granted the permission READ_PHONE_NUMBERS
     // PACKAGE: The package name of the app that was granted the permission
-    ACTION_PERMISSION_GRANT_READ_PHONE_NUMBER = 737;
+    ACTION_PERMISSION_GRANT_READ_PHONE_NUMBERS = 737;
 
-    // ACTION: An app requested the permission READ_PHONE_NUMBER and the request was denied
+    // ACTION: An app requested the permission READ_PHONE_NUMBERS and the request was denied
     // PACKAGE: The package name of the app requesting the permission
-    ACTION_PERMISSION_DENIED_READ_PHONE_NUMBER = 738;
+    ACTION_PERMISSION_DENIED_READ_PHONE_NUMBERS = 738;
 
-    // ACTION: The permission READ_PHONE_NUMBER was revoked for an app
+    // ACTION: The permission READ_PHONE_NUMBERS was revoked for an app
     // PACKAGE: The package name of the app the permission was revoked for
-    ACTION_PERMISSION_REVOKE_READ_PHONE_NUMBER = 739;
+    ACTION_PERMISSION_REVOKE_READ_PHONE_NUMBERS = 739;
 
     // ACTION: QS Brightness Slider (with auto brightness disabled, and VR enabled)
     //   SUBTYPE: slider value
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c27fa1b..7618144 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -11516,6 +11516,9 @@
                 }
             }
             checkTime(startTime, "getContentProviderImpl: done!");
+
+            grantEphemeralAccessLocked(userId, null /*intent*/,
+                    cpi.applicationInfo.uid, UserHandle.getAppId(Binder.getCallingUid()));
         }
 
         // Wait for the provider to be published...
@@ -12291,13 +12294,17 @@
         mRecentTasks.notifyTaskPersisterLocked(task, flush);
     }
 
-    /** Notifies all listeners when the pinned stack animation starts. */
+    /**
+     * Notifies all listeners when the pinned stack animation starts.
+     */
     @Override
     public void notifyPinnedStackAnimationStarted() {
         mTaskChangeNotificationController.notifyPinnedStackAnimationStarted();
     }
 
-    /** Notifies all listeners when the pinned stack animation ends. */
+    /**
+     * Notifies all listeners when the pinned stack animation ends.
+     */
     @Override
     public void notifyPinnedStackAnimationEnded() {
         mTaskChangeNotificationController.notifyPinnedStackAnimationEnded();
@@ -19784,6 +19791,10 @@
         }
     }
 
+    /**
+     * NOTE: For the pinned stack, this method is only called after the bounds animation has
+     *       animated the stack to the fullscreen.
+     */
     @Override
     public void moveTasksToFullscreenStack(int fromStackId, boolean onTop) {
         enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "moveTasksToFullscreenStack()");
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index 432988a..cbb51e1 100644
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -284,6 +284,10 @@
     boolean frozenBeforeDestroy;// has been frozen but not yet destroyed.
     boolean immersive;      // immersive mode (don't interrupt if possible)
     boolean forceNewConfig; // force re-create with new config next time
+    private boolean mInMultiWindowMode; // whether or not this activity is currently in multi-window
+                                        // mode (default false)
+    private boolean mInPictureInPictureMode; // whether or not this activity is currently in
+                                             // picture-in-picture mode (default false)
     boolean supportsPictureInPictureWhilePausing;  // This flag is set by the system to indicate
         // that the activity can enter picture in picture while pausing (ie. only when another
         // task is brought to front or started)
@@ -615,25 +619,51 @@
         }
     }
 
-    void scheduleMultiWindowModeChanged() {
+    void updateMultiWindowMode() {
         if (task == null || task.getStack() == null || app == null || app.thread == null) {
             return;
         }
+
+        // An activity is considered to be in multi-window mode if its task isn't fullscreen.
+        final boolean inMultiWindowMode = !task.mFullscreen;
+        if (inMultiWindowMode != mInMultiWindowMode) {
+            mInMultiWindowMode = inMultiWindowMode;
+            scheduleMultiWindowModeChanged(getConfiguration());
+        }
+    }
+
+    private void scheduleMultiWindowModeChanged(Configuration overrideConfig) {
         try {
-            // An activity is considered to be in multi-window mode if its task isn't fullscreen.
-            app.thread.scheduleMultiWindowModeChanged(appToken, !task.mFullscreen);
+            app.thread.scheduleMultiWindowModeChanged(appToken, mInMultiWindowMode,
+                    overrideConfig);
         } catch (Exception e) {
             // If process died, I don't care.
         }
     }
 
-    void schedulePictureInPictureModeChanged() {
+    void updatePictureInPictureMode(Rect targetStackBounds) {
         if (task == null || task.getStack() == null || app == null || app.thread == null) {
             return;
         }
+
+        final boolean inPictureInPictureMode = (task.getStackId() == PINNED_STACK_ID) &&
+                (targetStackBounds != null);
+        if (inPictureInPictureMode != mInPictureInPictureMode) {
+            // Picture-in-picture mode changes also trigger a multi-window mode change as well, so
+            // update that here in order
+            mInPictureInPictureMode = inPictureInPictureMode;
+            mInMultiWindowMode = inPictureInPictureMode;
+            final Configuration newConfig = task.computeNewOverrideConfigurationForBounds(
+                    targetStackBounds, null);
+            schedulePictureInPictureModeChanged(newConfig);
+            scheduleMultiWindowModeChanged(newConfig);
+        }
+    }
+
+    private void schedulePictureInPictureModeChanged(Configuration overrideConfig) {
         try {
-            app.thread.schedulePictureInPictureModeChanged(
-                    appToken, task.getStackId() == PINNED_STACK_ID);
+            app.thread.schedulePictureInPictureModeChanged(appToken, mInPictureInPictureMode,
+                    overrideConfig);
         } catch (Exception e) {
             // If process died, no one cares.
         }
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 498de63..ee37463 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -342,7 +342,7 @@
     private final Rect mTmpRect2 = new Rect();
 
     /** Run all ActivityStacks through this */
-    private final ActivityStackSupervisor mStackSupervisor;
+    protected final ActivityStackSupervisor mStackSupervisor;
 
     private final LaunchingTaskPositioner mTaskPositioner;
 
@@ -5074,7 +5074,7 @@
     }
 
     void addTask(final TaskRecord task, final boolean toTop, String reason) {
-        addTask(task, toTop ? MAX_VALUE : 0, reason);
+        addTask(task, toTop ? MAX_VALUE : 0, true /* schedulePictureInPictureModeChange */, reason);
         if (toTop) {
             // TODO: figure-out a way to remove this call.
             mWindowContainerController.positionChildAtTop(task.getWindowContainerController(),
@@ -5084,7 +5084,8 @@
 
     // TODO: This shouldn't allow automatic reparenting. Remove the call to preAddTask and deal
     // with the fall-out...
-    void addTask(final TaskRecord task, int position, String reason) {
+    void addTask(final TaskRecord task, int position, boolean schedulePictureInPictureModeChange,
+            String reason) {
         // TODO: Is this remove really needed? Need to look into the call path for the other addTask
         mTaskHistory.remove(task);
         position = getAdjustedPositionForTask(task, position, null /* starting */);
@@ -5100,7 +5101,7 @@
 
         updateTaskMovement(task, toTop);
 
-        postAddTask(task, prevStack);
+        postAddTask(task, prevStack, schedulePictureInPictureModeChange);
     }
 
     void positionChildAt(TaskRecord task, int index) {
@@ -5116,7 +5117,7 @@
         final boolean wasResumed = topRunningActivity == task.getStack().mResumedActivity;
         insertTaskAtPosition(task, index);
         task.setStack(this);
-        postAddTask(task, null /* prevStack */);
+        postAddTask(task, null /* prevStack */, true /* schedulePictureInPictureModeChange */);
 
         if (wasResumed) {
             if (mResumedActivity != null) {
@@ -5142,9 +5143,15 @@
         return prevStack;
     }
 
-    private void postAddTask(TaskRecord task, ActivityStack prevStack) {
-        if (prevStack != null) {
-            mStackSupervisor.scheduleReportPictureInPictureModeChangedIfNeeded(task, prevStack);
+    /**
+     * @param schedulePictureInPictureModeChange specifies whether or not to schedule the PiP mode
+     *            change. Callers may set this to false if they are explicitly scheduling PiP mode
+     *            changes themselves, like during the PiP animation
+     */
+    private void postAddTask(TaskRecord task, ActivityStack prevStack,
+            boolean schedulePictureInPictureModeChange) {
+        if (schedulePictureInPictureModeChange && prevStack != null) {
+            mStackSupervisor.scheduleUpdatePictureInPictureModeIfNeeded(task, prevStack);
         } else if (task.voiceSession != null) {
             try {
                 task.voiceSession.taskStarted(task.intent, task.taskId);
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index c65ca79..f16849d 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -371,6 +371,10 @@
      * application */
     final ArrayList<ActivityRecord> mPipModeChangedActivities = new ArrayList<>();
 
+    /** The target stack bounds for the picture-in-picture mode changed that we need to report to
+     * the application */
+    Rect mPipModeChangedTargetStackBounds;
+
     /** Used on user changes */
     final ArrayList<UserState> mStartingUsers = new ArrayList<>();
 
@@ -2334,6 +2338,9 @@
             ActivityStack fullscreenStack = getStack(FULLSCREEN_WORKSPACE_STACK_ID);
             final boolean isFullscreenStackVisible = fullscreenStack != null &&
                     fullscreenStack.getStackVisibilityLocked(null) == STACK_VISIBLE;
+            // If we are moving from the pinned stack, then the animation takes care of updating
+            // the picture-in-picture mode.
+            final boolean schedulePictureInPictureModeChange = (fromStackId != PINNED_STACK_ID);
             final ArrayList<TaskRecord> tasks = stack.getAllTasks();
             final int size = tasks.size();
             if (onTop) {
@@ -2352,6 +2359,7 @@
                     // Defer resume until all the tasks have been moved to the fullscreen stack
                     task.reparent(FULLSCREEN_WORKSPACE_STACK_ID, ON_TOP,
                             REPARENT_MOVE_STACK_TO_FRONT, isTopTask /* animate */, DEFER_RESUME,
+                            schedulePictureInPictureModeChange,
                             "moveTasksToFullscreenStack - onTop");
                 }
             } else {
@@ -2361,8 +2369,9 @@
                             ? Math.max(fullscreenStack.getAllTasks().size() - 1, 0) : 0;
                     // Defer resume until all the tasks have been moved to the fullscreen stack
                     task.reparent(FULLSCREEN_WORKSPACE_STACK_ID, position,
-                            REPARENT_LEAVE_STACK_IN_PLACE, !ANIMATE,
-                            DEFER_RESUME, "moveTasksToFullscreenStack - NOT_onTop");
+                            REPARENT_LEAVE_STACK_IN_PLACE, !ANIMATE, DEFER_RESUME,
+                            schedulePictureInPictureModeChange,
+                            "moveTasksToFullscreenStack - NOT_onTop");
                 }
             }
 
@@ -2506,9 +2515,8 @@
                         fullscreenStack.getStackVisibilityLocked(null) == STACK_VISIBLE;
                 for (int i = 0; i < tasks.size(); i++) {
                     // Insert the task either at the top of the fullscreen stack if it is hidden,
-                    // or just under the top task if it is currently visible
-                    final int insertPosition = isFullscreenStackVisible
-                            ? Math.max(0, fullscreenStack.getChildCount() - 1)
+                    // or to the bottom if it is currently visible
+                    final int insertPosition = isFullscreenStackVisible ? 0
                             : fullscreenStack.getChildCount();
                     final TaskRecord task = tasks.get(i);
                     // Defer resume until we remove all the tasks
@@ -2856,9 +2864,9 @@
                     // was launched from home so home should be visible behind it.
                     moveHomeStackToFront(reason);
                 }
-                // Defer resume until below
+                // Defer resume until below, and do not schedule PiP changes until we animate below
                 task.reparent(PINNED_STACK_ID, ON_TOP, REPARENT_MOVE_STACK_TO_FRONT, !ANIMATE,
-                        DEFER_RESUME, reason);
+                        DEFER_RESUME, false /* schedulePictureInPictureModeChange */, reason);
             } else {
                 // There are multiple activities in the task and moving the top activity should
                 // reveal/leave the other activities in their original task.
@@ -2873,9 +2881,9 @@
                         r.mActivityType);
                 r.reparent(newTask, MAX_VALUE, "moveActivityToStack");
 
-                // Defer resume until below
+                // Defer resume until below, and do not schedule PiP changes until we animate below
                 newTask.reparent(PINNED_STACK_ID, ON_TOP, REPARENT_MOVE_STACK_TO_FRONT, !ANIMATE,
-                        DEFER_RESUME, reason);
+                        DEFER_RESUME, false /* schedulePictureInPictureModeChange */, reason);
             }
 
             // Reset the state that indicates it can enter PiP while pausing after we've moved it
@@ -4109,7 +4117,7 @@
         mActivityMetricsLogger.logWindowState();
     }
 
-    void scheduleReportMultiWindowModeChanged(TaskRecord task) {
+    void scheduleUpdateMultiWindowMode(TaskRecord task) {
         for (int i = task.mActivities.size() - 1; i >= 0; i--) {
             final ActivityRecord r = task.mActivities.get(i);
             if (r.app != null && r.app.thread != null) {
@@ -4122,22 +4130,39 @@
         }
     }
 
-    void scheduleReportPictureInPictureModeChangedIfNeeded(TaskRecord task, ActivityStack prevStack) {
+    void scheduleUpdatePictureInPictureModeIfNeeded(TaskRecord task, ActivityStack prevStack) {
         final ActivityStack stack = task.getStack();
         if (prevStack == null || prevStack == stack
                 || (prevStack.mStackId != PINNED_STACK_ID && stack.mStackId != PINNED_STACK_ID)) {
             return;
         }
 
-        for (int i = task.mActivities.size() - 1; i >= 0; i--) {
-            final ActivityRecord r = task.mActivities.get(i);
-            if (r.app != null && r.app.thread != null) {
-                mPipModeChangedActivities.add(r);
-            }
-        }
+        scheduleUpdatePictureInPictureModeIfNeeded(task, stack.mBounds, false /* immediate */);
+    }
 
-        if (!mHandler.hasMessages(REPORT_PIP_MODE_CHANGED_MSG)) {
-            mHandler.sendEmptyMessage(REPORT_PIP_MODE_CHANGED_MSG);
+    void scheduleUpdatePictureInPictureModeIfNeeded(TaskRecord task, Rect targetStackBounds,
+            boolean immediate) {
+
+        if (immediate) {
+            mHandler.removeMessages(REPORT_PIP_MODE_CHANGED_MSG);
+            for (int i = task.mActivities.size() - 1; i >= 0; i--) {
+                final ActivityRecord r = task.mActivities.get(i);
+                if (r.app != null && r.app.thread != null) {
+                    r.updatePictureInPictureMode(targetStackBounds);
+                }
+            }
+        } else {
+            for (int i = task.mActivities.size() - 1; i >= 0; i--) {
+                final ActivityRecord r = task.mActivities.get(i);
+                if (r.app != null && r.app.thread != null) {
+                    mPipModeChangedActivities.add(r);
+                }
+            }
+            mPipModeChangedTargetStackBounds = targetStackBounds;
+
+            if (!mHandler.hasMessages(REPORT_PIP_MODE_CHANGED_MSG)) {
+                mHandler.sendEmptyMessage(REPORT_PIP_MODE_CHANGED_MSG);
+            }
         }
     }
 
@@ -4165,7 +4190,7 @@
                     synchronized (mService) {
                         for (int i = mMultiWindowModeChangedActivities.size() - 1; i >= 0; i--) {
                             final ActivityRecord r = mMultiWindowModeChangedActivities.remove(i);
-                            r.scheduleMultiWindowModeChanged();
+                            r.updateMultiWindowMode();
                         }
                     }
                 } break;
@@ -4173,7 +4198,7 @@
                     synchronized (mService) {
                         for (int i = mPipModeChangedActivities.size() - 1; i >= 0; i--) {
                             final ActivityRecord r = mPipModeChangedActivities.remove(i);
-                            r.schedulePictureInPictureModeChanged();
+                            r.updatePictureInPictureMode(mPipModeChangedTargetStackBounds);
                         }
                     }
                 } break;
diff --git a/services/core/java/com/android/server/am/PinnedActivityStack.java b/services/core/java/com/android/server/am/PinnedActivityStack.java
index 32d3082..394e902 100644
--- a/services/core/java/com/android/server/am/PinnedActivityStack.java
+++ b/services/core/java/com/android/server/am/PinnedActivityStack.java
@@ -23,6 +23,7 @@
 import com.android.server.wm.PinnedStackWindowController;
 import com.android.server.wm.StackWindowController;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -57,4 +58,18 @@
     boolean isBoundsAnimatingToFullscreen() {
         return getWindowContainerController().isBoundsAnimatingToFullscreen();
     }
+
+    @Override
+    public void updatePictureInPictureModeForPinnedStackAnimation(Rect targetStackBounds) {
+        // It is guaranteed that the activities requiring the update will be in the pinned stack at
+        // this point (either reparented before the animation into PiP, or before reparenting after
+        // the animation out of PiP)
+        synchronized(this) {
+            ArrayList<TaskRecord> tasks = getAllTasks();
+            for (int i = 0; i < tasks.size(); i++ ) {
+                mStackSupervisor.scheduleUpdatePictureInPictureModeIfNeeded(tasks.get(i),
+                        targetStackBounds, true /* immediate */);
+            }
+        }
+    }
 }
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index ee4a42d..27a2461 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -568,7 +568,27 @@
     boolean reparent(int preferredStackId, boolean toTop, @ReparentMoveStackMode int moveStackMode,
             boolean animate, boolean deferResume, String reason) {
         return reparent(preferredStackId, toTop ? MAX_VALUE : 0, moveStackMode, animate,
-                deferResume, reason);
+                deferResume, true /* schedulePictureInPictureModeChange */, reason);
+    }
+
+    /**
+     * Convenience method to reparent a task to the top or bottom position of the stack, with
+     * an option to skip scheduling the picture-in-picture mode change.
+     */
+    boolean reparent(int preferredStackId, boolean toTop, @ReparentMoveStackMode int moveStackMode,
+            boolean animate, boolean deferResume, boolean schedulePictureInPictureModeChange,
+            String reason) {
+        return reparent(preferredStackId, toTop ? MAX_VALUE : 0, moveStackMode, animate,
+                deferResume, schedulePictureInPictureModeChange, reason);
+    }
+
+    /**
+     * Convenience method to reparent a task to a specific position of the stack.
+     */
+    boolean reparent(int preferredStackId, int position, @ReparentMoveStackMode int moveStackMode,
+            boolean animate, boolean deferResume, String reason) {
+        return reparent(preferredStackId, position, moveStackMode, animate, deferResume,
+                true /* schedulePictureInPictureModeChange */, reason);
     }
 
     /**
@@ -577,16 +597,20 @@
      * @param preferredStackId the stack id of the target stack to move this task
      * @param position the position to place this task in the new stack
      * @param animate whether or not we should wait for the new window created as a part of the
-     *                reparenting to be drawn and animated in
+     *            reparenting to be drawn and animated in
      * @param moveStackMode whether or not to move the stack to the front always, only if it was
-     *                      previously focused & in front, or never
+     *            previously focused & in front, or never
      * @param deferResume whether or not to update the visibility of other tasks and stacks that may
-     *                    have changed as a result of this reparenting
+     *            have changed as a result of this reparenting
+     * @param schedulePictureInPictureModeChange specifies whether or not to schedule the PiP mode
+     *            change. Callers may set this to false if they are explicitly scheduling PiP mode
+     *            changes themselves, like during the PiP animation
      * @param reason the caller of this reparenting
-     * @return
+     * @return whether the task was reparented
      */
     boolean reparent(int preferredStackId, int position, @ReparentMoveStackMode int moveStackMode,
-            boolean animate, boolean deferResume, String reason) {
+            boolean animate, boolean deferResume, boolean schedulePictureInPictureModeChange,
+            String reason) {
         final ActivityStackSupervisor supervisor = mService.mStackSupervisor;
         final WindowManagerService windowManager = mService.mWindowManager;
         final ActivityStack sourceStack = getStack();
@@ -649,11 +673,12 @@
 
             // Move the task
             sourceStack.removeTask(this, reason, REMOVE_TASK_MODE_MOVING);
-            toStack.addTask(this, position, reason);
+            toStack.addTask(this, position, false /* schedulePictureInPictureModeChange */, reason);
 
-            // TODO: Ensure that this is actually necessary here
-            // Notify of picture-in-picture mode changes
-            supervisor.scheduleReportPictureInPictureModeChangedIfNeeded(this, sourceStack);
+            if (schedulePictureInPictureModeChange) {
+                // Notify of picture-in-picture mode changes
+                supervisor.scheduleUpdatePictureInPictureModeIfNeeded(this, sourceStack);
+            }
 
             // TODO: Ensure that this is actually necessary here
             // Notify the voice session if required
@@ -1979,6 +2004,25 @@
     }
 
     /**
+     * @return a new Configuration for this Task, given the provided {@param bounds} and
+     *         {@param insetBounds}.
+     */
+    Configuration computeNewOverrideConfigurationForBounds(Rect bounds, Rect insetBounds) {
+        // Compute a new override configuration for the given bounds, if fullscreen bounds
+        // (bounds == null), then leave the override config unset
+        final Configuration newOverrideConfig = new Configuration();
+        if (bounds != null) {
+            newOverrideConfig.setTo(getOverrideConfiguration());
+            mTmpRect.set(bounds);
+            adjustForMinimalTaskDimensions(mTmpRect);
+            computeOverrideConfiguration(newOverrideConfig, mTmpRect, insetBounds,
+                    mTmpRect.right != bounds.right, mTmpRect.bottom != bounds.bottom);
+        }
+
+        return newOverrideConfig;
+    }
+
+    /**
      * Update task's override configuration based on the bounds.
      * @param bounds The bounds of the task.
      * @return True if the override configuration was updated.
@@ -2027,7 +2071,7 @@
         onOverrideConfigurationChanged(newConfig);
 
         if (mFullscreen != oldFullscreen) {
-            mService.mStackSupervisor.scheduleReportMultiWindowModeChanged(this);
+            mService.mStackSupervisor.scheduleUpdateMultiWindowMode(this);
         }
 
         return !mTmpConfig.equals(newConfig);
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index 73afaa0..65aaee0 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -282,7 +282,7 @@
         for (int i = 0; i < size; i++) {
             final NotificationChannel notificationChannel = r.channels.valueAt(i);
             if (notificationChannel != null &&
-                    notificationChannel.getId() != NotificationChannel.DEFAULT_CHANNEL_ID) {
+                    !notificationChannel.getId().equals(NotificationChannel.DEFAULT_CHANNEL_ID)) {
                 hasCreatedAChannel = true;
                 break;
             }
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 6b6adc3..365a8e8 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -569,7 +569,7 @@
             Manifest.permission.RECEIVE_MMS,
             Manifest.permission.READ_EXTERNAL_STORAGE,
             Manifest.permission.WRITE_EXTERNAL_STORAGE,
-            Manifest.permission.READ_PHONE_NUMBER,
+            Manifest.permission.READ_PHONE_NUMBERS,
             Manifest.permission.ANSWER_PHONE_CALLS);
 
 
diff --git a/services/core/java/com/android/server/statusbar/StatusBarShellCommand.java b/services/core/java/com/android/server/statusbar/StatusBarShellCommand.java
index 963a572..40bb496 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarShellCommand.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarShellCommand.java
@@ -17,6 +17,8 @@
 import android.content.ComponentName;
 import android.os.RemoteException;
 import android.os.ShellCommand;
+import android.service.quicksettings.TileService;
+
 import com.android.internal.statusbar.IStatusBarService;
 
 import java.io.PrintWriter;
@@ -48,6 +50,10 @@
                     return runRemoveTile();
                 case "click-tile":
                     return runClickTile();
+                case "check-support":
+                    final PrintWriter pw = getOutPrintWriter();
+                    pw.println(String.valueOf(TileService.isQuickSettingsSupported()));
+                    return 0;
                 default:
                     return handleDefaultCommands(cmd);
             }
@@ -113,5 +119,8 @@
         pw.println("  click-tile COMPONENT");
         pw.println("    Click on a TileService of the specified component");
         pw.println("");
+        pw.println("  check-support");
+        pw.println("    Check if this device supports QS + APIs");
+        pw.println("");
     }
 }
diff --git a/services/core/java/com/android/server/wm/BoundsAnimationController.java b/services/core/java/com/android/server/wm/BoundsAnimationController.java
index 62414e5..9f0ed21 100644
--- a/services/core/java/com/android/server/wm/BoundsAnimationController.java
+++ b/services/core/java/com/android/server/wm/BoundsAnimationController.java
@@ -16,7 +16,6 @@
 
 package com.android.server.wm;
 
-import static com.android.server.wm.AppTransition.DEFAULT_APP_TRANSITION_DURATION;
 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
 import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
 import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -32,7 +31,6 @@
 import android.util.Slog;
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
-import android.view.animation.LinearInterpolator;
 import android.view.WindowManagerInternal;
 
 /**
@@ -111,10 +109,15 @@
         private final boolean mMoveToFullScreen;
         // True if this this animation was cancelled and will be replaced the another animation from
         // the same {@link #AnimateBoundsUser} target.
-        private boolean mWillReplace;
-        // True to true if this animation replaced a previous animation of the same
+        private boolean mSkipAnimationEnd;
+        // True if this animation replaced a previous animation of the same
         // {@link #AnimateBoundsUser} target.
-        private final boolean mReplacement;
+        private final boolean mSkipAnimationStart;
+        // True if this animation is not replacing a previous animation, or if the previous
+        // animation is animating to a different fullscreen state than the current animation.
+        // We use this to ensure that we always provide a consistent set/order of callbacks when we
+        // transition to/from PiP.
+        private final boolean mAnimatingToNewFullscreenState;
 
         // Depending on whether we are animating from
         // a smaller to a larger size
@@ -122,13 +125,14 @@
         private final int mFrozenTaskHeight;
 
         BoundsAnimator(AnimateBoundsUser target, Rect from, Rect to, boolean moveToFullScreen,
-                boolean replacement) {
+                boolean replacingExistingAnimation, boolean animatingToNewFullscreenState) {
             super();
             mTarget = target;
             mFrom.set(from);
             mTo.set(to);
             mMoveToFullScreen = moveToFullScreen;
-            mReplacement = replacement;
+            mSkipAnimationStart = replacingExistingAnimation;
+            mAnimatingToNewFullscreenState = animatingToNewFullscreenState;
             addUpdateListener(this);
             addListener(this);
 
@@ -145,11 +149,32 @@
             }
         }
 
-        boolean animatingToLargerSize() {
-            if (mFrom.width() * mFrom.height() > mTo.width() * mTo.height()) {
-                return false;
+        @Override
+        public void onAnimationStart(Animator animation) {
+            if (DEBUG) Slog.d(TAG, "onAnimationStart: mTarget=" + mTarget
+                    + " mSkipAnimationStart=" + mSkipAnimationStart);
+            mFinishAnimationAfterTransition = false;
+            mTmpRect.set(mFrom.left, mFrom.top, mFrom.left + mFrozenTaskWidth,
+                    mFrom.top + mFrozenTaskHeight);
+
+            // Ensure that we have prepared the target for animation before
+            // we trigger any size changes, so it can swap surfaces
+            // in to appropriate modes, or do as it wishes otherwise.
+            if (!mSkipAnimationStart) {
+                mTarget.onAnimationStart(mMoveToFullScreen);
             }
-            return true;
+
+            // If we are animating to a new fullscreen state (either to/from fullscreen), then
+            // notify the target of the change with the new frozen task bounds
+            if (mAnimatingToNewFullscreenState) {
+                mTarget.updatePictureInPictureMode(mMoveToFullScreen ? null : mTo);
+            }
+
+            // Immediately update the task bounds if they have to become larger, but preserve
+            // the starting position so we don't jump at the beginning of the animation.
+            if (animatingToLargerSize()) {
+                mTarget.setPinnedStackSize(mFrom, mTmpRect);
+            }
         }
 
         @Override
@@ -174,32 +199,11 @@
             }
         }
 
-
-        @Override
-        public void onAnimationStart(Animator animation) {
-            if (DEBUG) Slog.d(TAG, "onAnimationStart: mTarget=" + mTarget
-                    + " mReplacement=" + mReplacement);
-            mFinishAnimationAfterTransition = false;
-            // Ensure that we have prepared the target for animation before
-            // we trigger any size changes, so it can swap surfaces
-            // in to appropriate modes, or do as it wishes otherwise.
-            if (!mReplacement) {
-                mTarget.onAnimationStart(mMoveToFullScreen);
-            }
-
-            // Immediately update the task bounds if they have to become larger, but preserve
-            // the starting position so we don't jump at the beginning of the animation.
-            if (animatingToLargerSize()) {
-                mTmpRect.set(mFrom.left, mFrom.top,
-                        mFrom.left + mFrozenTaskWidth, mFrom.top + mFrozenTaskHeight);
-                mTarget.setPinnedStackSize(mFrom, mTmpRect);
-            }
-        }
-
         @Override
         public void onAnimationEnd(Animator animation) {
             if (DEBUG) Slog.d(TAG, "onAnimationEnd: mTarget=" + mTarget
-                    + " mMoveToFullScreen=" + mMoveToFullScreen + " mWillReplace=" + mWillReplace);
+                    + " mMoveToFullScreen=" + mMoveToFullScreen
+                    + " mSkipAnimationEnd=" + mSkipAnimationEnd);
 
             // There could be another animation running. For example in the
             // move to fullscreen case, recents will also be closing while the
@@ -214,7 +218,7 @@
             finishAnimation();
 
             mTarget.setPinnedStackSize(mTo, null);
-            if (mMoveToFullScreen && !mWillReplace) {
+            if (mMoveToFullScreen && !mSkipAnimationEnd) {
                 mTarget.moveToFullscreen();
             }
         }
@@ -226,20 +230,27 @@
 
         @Override
         public void cancel() {
-            mWillReplace = true;
+            mSkipAnimationEnd = true;
             if (DEBUG) Slog.d(TAG, "cancel: willReplace mTarget=" + mTarget);
             super.cancel();
         }
 
         /** Returns true if the animation target is the same as the input bounds. */
-        public boolean isAnimatingTo(Rect bounds) {
+        boolean isAnimatingTo(Rect bounds) {
             return mTo.equals(bounds);
         }
 
+        private boolean animatingToLargerSize() {
+            if (mFrom.width() * mFrom.height() > mTo.width() * mTo.height()) {
+                return false;
+            }
+            return true;
+        }
+
         private void finishAnimation() {
             if (DEBUG) Slog.d(TAG, "finishAnimation: mTarget=" + mTarget
                     + " callers" + Debug.getCallers(2));
-            if (!mWillReplace) {
+            if (!mSkipAnimationEnd) {
                 mTarget.onAnimationEnd();
             }
             removeListener(this);
@@ -249,7 +260,7 @@
 
         @Override
         public void onAnimationRepeat(Animator animation) {
-
+            // Do nothing
         }
     }
 
@@ -266,14 +277,27 @@
         boolean setSize(Rect bounds);
         /**
          * Behaves as setSize, but freezes the bounds of any tasks in the target at taskBounds,
-         * to allow for more flexibility during resizing. Only
-         * works for the pinned stack at the moment.
+         * to allow for more flexibility during resizing. Only works for the pinned stack at the
+         * moment.
          */
         boolean setPinnedStackSize(Rect bounds, Rect taskBounds);
 
+        /**
+         * Callback for the target to inform it that the animation has started, so it can do some
+         * necessary preparation.
+         */
         void onAnimationStart(boolean toFullscreen);
 
         /**
+         * Callback for the target to inform it that the animation is going to a new fullscreen
+         * state and should update the picture-in-picture mode accordingly.
+         *
+         * @param targetStackBounds the target stack bounds we are animating to, can be null if
+         *                          we are animating to fullscreen
+         */
+        void updatePictureInPictureMode(Rect targetStackBounds);
+
+        /**
          * Callback for the target to inform it that the animation has ended, so it can do some
          * necessary cleanup.
          */
@@ -286,9 +310,12 @@
             boolean moveToFullscreen) {
         final BoundsAnimator existing = mRunningAnimations.get(target);
         final boolean replacing = existing != null;
+        final boolean animatingToNewFullscreenState = (existing == null) ||
+                (existing.mMoveToFullScreen != moveToFullscreen);
 
         if (DEBUG) Slog.d(TAG, "animateBounds: target=" + target + " from=" + from + " to=" + to
-                + " moveToFullscreen=" + moveToFullscreen + " replacing=" + replacing);
+                + " moveToFullscreen=" + moveToFullscreen + " replacing=" + replacing
+                + " animatingToNewFullscreenState=" + animatingToNewFullscreenState);
 
         if (replacing) {
             if (existing.isAnimatingTo(to)) {
@@ -300,8 +327,8 @@
             }
             existing.cancel();
         }
-        final BoundsAnimator animator =
-                new BoundsAnimator(target, from, to, moveToFullscreen, replacing);
+        final BoundsAnimator animator = new BoundsAnimator(target, from, to, moveToFullscreen,
+                replacing, animatingToNewFullscreenState);
         mRunningAnimations.put(target, animator);
         animator.setFloatValues(0f, 1f);
         animator.setDuration((animationDuration != -1 ? animationDuration
diff --git a/services/core/java/com/android/server/wm/StackWindowController.java b/services/core/java/com/android/server/wm/StackWindowController.java
index b2029dd..635527e 100644
--- a/services/core/java/com/android/server/wm/StackWindowController.java
+++ b/services/core/java/com/android/server/wm/StackWindowController.java
@@ -362,6 +362,13 @@
         }
     }
 
+    /** Calls directly into activity manager so window manager lock shouldn't held. */
+    public void updatePictureInPictureModeForPinnedStackAnimation(Rect targetStackBounds) {
+        if (mListener != null) {
+            mListener.updatePictureInPictureModeForPinnedStackAnimation(targetStackBounds);
+        }
+    }
+
     void requestResize(Rect bounds) {
         mHandler.obtainMessage(H.REQUEST_RESIZE, bounds).sendToTarget();
     }
diff --git a/services/core/java/com/android/server/wm/StackWindowListener.java b/services/core/java/com/android/server/wm/StackWindowListener.java
index c763c17..a55f9df 100644
--- a/services/core/java/com/android/server/wm/StackWindowListener.java
+++ b/services/core/java/com/android/server/wm/StackWindowListener.java
@@ -26,4 +26,10 @@
 
     /** Called when the stack container would like its controller to resize. */
     void requestResize(Rect bounds);
+
+    /**
+     * Called when the stack container pinned stack animation will change the picture-in-picture
+     * mode. This is a direct call into ActivityManager.
+     */
+    default void updatePictureInPictureModeForPinnedStackAnimation(Rect targetStackBounds) {}
 }
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 8b5f5ac..1a67ac7 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -1483,6 +1483,14 @@
     }
 
     @Override  // AnimatesBounds
+    public void updatePictureInPictureMode(Rect targetStackBounds) {
+        final StackWindowController controller = getController();
+        if (controller != null) {
+            controller.updatePictureInPictureModeForPinnedStackAnimation(targetStackBounds);
+        }
+    }
+
+    @Override  // AnimatesBounds
     public void onAnimationEnd() {
         synchronized (mService.mWindowMap) {
             mBoundsAnimating = false;
diff --git a/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
index 1729cee..e3ccd6e 100644
--- a/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java
@@ -213,10 +213,10 @@
      */
     @Test
     public void testDefaultDisplayOverrideConfigUpdate() throws Exception {
-        final Configuration currentOverrideConfig = sDisplayContent.getOverrideConfiguration();
+        final Configuration currentConfig = sDisplayContent.getConfiguration();
 
         // Create new, slightly changed override configuration and apply it to the display.
-        final Configuration newOverrideConfig = new Configuration(currentOverrideConfig);
+        final Configuration newOverrideConfig = new Configuration(currentConfig);
         newOverrideConfig.densityDpi += 120;
         newOverrideConfig.fontScale += 0.3;
 
@@ -228,10 +228,10 @@
         assertEquals(newOverrideConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */);
 
         // Return back to original values.
-        sWm.setNewDisplayOverrideConfiguration(currentOverrideConfig, DEFAULT_DISPLAY);
+        sWm.setNewDisplayOverrideConfiguration(currentConfig, DEFAULT_DISPLAY);
         globalConfig = sWm.mRoot.getConfiguration();
-        assertEquals(currentOverrideConfig.densityDpi, globalConfig.densityDpi);
-        assertEquals(currentOverrideConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */);
+        assertEquals(currentConfig.densityDpi, globalConfig.densityDpi);
+        assertEquals(currentConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */);
     }
 
     @Test
diff --git a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
index 0b72a21..fbeda0a 100644
--- a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
+++ b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
@@ -23,6 +23,7 @@
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.doAnswer;
 
+import android.content.pm.ActivityInfo;
 import android.os.PowerSaveState;
 import org.mockito.invocation.InvocationOnMock;
 
@@ -449,9 +450,8 @@
     }
 
     @Override
-    public boolean rotationHasCompatibleMetricsLw(int orientation,
-            int rotation) {
-        return false;
+    public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) {
+        return true;
     }
 
     @Override
diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java
index 1b1984d..2e6eac0 100644
--- a/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java
@@ -250,37 +250,57 @@
 
     @Test
     public void testLayoutNonfullscreenTask() {
-        final Rect taskBounds = new Rect(300, 300, 700, 700);
+        final DisplayInfo displayInfo = sWm.getDefaultDisplayContentLocked().getDisplayInfo();
+        final int logicalWidth = displayInfo.logicalWidth;
+        final int logicalHeight = displayInfo.logicalHeight;
+
+        final int taskLeft = logicalWidth / 4;
+        final int taskTop = logicalHeight / 4;
+        final int taskRight = logicalWidth / 4 * 3;
+        final int taskBottom = logicalHeight / 4 * 3;
+        final Rect taskBounds = new Rect(taskLeft, taskTop, taskRight, taskBottom);
         TaskWithBounds task = new TaskWithBounds(taskBounds);
         task.mFullscreenForTest = false;
         WindowState w = createWindow(task, FILL_PARENT, FILL_PARENT);
         w.mAttrs.gravity = Gravity.LEFT | Gravity.TOP;
 
-        final Rect pf = new Rect(0, 0, 1000, 1000);
+        final Rect pf = new Rect(0, 0, logicalWidth, logicalHeight);
         w.computeFrameLw(pf, pf, pf, pf, pf, pf, pf, null);
         // For non fullscreen tasks the containing frame is based off the
         // task bounds not the parent frame.
-        assertRect(w.mFrame, 300, 300, 700, 700);
-        assertRect(w.getContentFrameLw(), 300, 300, 700, 700);
+        assertRect(w.mFrame, taskLeft, taskTop, taskRight, taskBottom);
+        assertRect(w.getContentFrameLw(), taskLeft, taskTop, taskRight, taskBottom);
         assertRect(w.mContentInsets, 0, 0, 0, 0);
 
-        pf.set(0, 0, 1000, 1000);
+        pf.set(0, 0, logicalWidth, logicalHeight);
         // We still produce insets against the containing frame the same way.
-        final Rect cf = new Rect(0, 0, 500, 500);
+        final int cfRight = logicalWidth / 2;
+        final int cfBottom = logicalHeight / 2;
+        final Rect cf = new Rect(0, 0, cfRight, cfBottom);
         w.computeFrameLw(pf, pf, pf, cf, cf, pf, cf, null);
-        assertRect(w.mFrame, 300, 300, 700, 700);
-        assertRect(w.getContentFrameLw(), 300, 300, 500, 500);
-        assertRect(w.mContentInsets, 0, 0, 200, 200);
+        assertRect(w.mFrame, taskLeft, taskTop, taskRight, taskBottom);
+        int contentInsetRight = taskRight - cfRight;
+        int contentInsetBottom = taskBottom - cfBottom;
+        assertRect(w.mContentInsets, 0, 0, contentInsetRight, contentInsetBottom);
+        assertRect(w.getContentFrameLw(), taskLeft, taskTop, taskRight - contentInsetRight,
+                taskBottom - contentInsetBottom);
 
-        pf.set(0, 0, 1000, 1000);
+        pf.set(0, 0, logicalWidth, logicalHeight);
         // However if we set temp inset bounds, the insets will be computed
         // as if our window was laid out there,  but it will be laid out according to
         // the task bounds.
-        task.mInsetBounds.set(200, 200, 600, 600);
+        final int insetLeft = logicalWidth / 5;
+        final int insetTop = logicalHeight / 5;
+        final int insetRight = insetLeft + (taskRight - taskLeft);
+        final int insetBottom = insetTop + (taskBottom - taskTop);
+        task.mInsetBounds.set(insetLeft, insetTop, insetRight, insetBottom);
         w.computeFrameLw(pf, pf, pf, cf, cf, pf, cf, null);
-        assertRect(w.mFrame, 300, 300, 700, 700);
-        assertRect(w.getContentFrameLw(), 300, 300, 600, 600);
-        assertRect(w.mContentInsets, 0, 0, 100, 100);
+        assertRect(w.mFrame, taskLeft, taskTop, taskRight, taskBottom);
+        contentInsetRight = insetRight - cfRight;
+        contentInsetBottom = insetBottom - cfBottom;
+        assertRect(w.mContentInsets, 0, 0, contentInsetRight, contentInsetBottom);
+        assertRect(w.getContentFrameLw(), taskLeft, taskTop, taskRight - contentInsetRight,
+                taskBottom - contentInsetBottom);
     }
 
     @Test
@@ -289,13 +309,16 @@
                 new TaskWithBounds(null), FILL_PARENT, FILL_PARENT);
         w.mAttrs.gravity = Gravity.LEFT | Gravity.TOP;
 
-        final Rect pf = new Rect(0, 0, 1000, 1000);
+        final DisplayInfo displayInfo = w.getDisplayContent().getDisplayInfo();
+        final int logicalWidth = displayInfo.logicalWidth;
+        final int logicalHeight = displayInfo.logicalHeight;
+        final Rect pf = new Rect(0, 0, logicalWidth, logicalHeight);
         final Rect df = pf;
         final Rect of = df;
         final Rect cf = new Rect(pf);
         // Produce some insets
-        cf.top += 50;
-        cf.bottom -= 100;
+        cf.top += displayInfo.logicalWidth / 10;
+        cf.bottom -= displayInfo.logicalWidth / 5;
         final Rect vf = cf;
         final Rect sf = vf;
         // We use a decor content frame with insets to produce cropping.
@@ -308,35 +331,34 @@
         // If we were above system decor we wouldnt' get any cropping though
         w.mLayer = sWm.mSystemDecorLayer + 1;
         w.calculatePolicyCrop(policyCrop);
-        assertRect(policyCrop, 0, 0, 1000, 1000);
+        assertRect(policyCrop, 0, 0, logicalWidth, logicalHeight);
         w.mLayer = 1;
         dcf.setEmpty();
         // Likewise with no decor frame we would get no crop
         w.computeFrameLw(pf, df, of, cf, vf, dcf, sf, null);
         w.calculatePolicyCrop(policyCrop);
-        assertRect(policyCrop, 0, 0, 1000, 1000);
+        assertRect(policyCrop, 0, 0, logicalWidth, logicalHeight);
 
         // Now we set up a window which doesn't fill the entire decor frame.
         // Normally it would be cropped to it's frame but in the case of docked resizing
         // we need to account for the fact the windows surface will be made
         // fullscreen and thus also make the crop fullscreen.
         w.mAttrs.gravity = Gravity.LEFT | Gravity.TOP;
-        w.mAttrs.width = 500;
-        w.mAttrs.height = 500;
-        w.mRequestedWidth = 500;
-        w.mRequestedHeight = 500;
+        w.mAttrs.width = logicalWidth / 2;
+        w.mAttrs.height = logicalHeight / 2;
+        w.mRequestedWidth = logicalWidth / 2;
+        w.mRequestedHeight = logicalHeight / 2;
         w.computeFrameLw(pf, pf, pf, pf, pf, pf, pf, pf);
 
         w.calculatePolicyCrop(policyCrop);
         // Normally the crop is shrunk from the decor frame
         // to the computed window frame.
-        assertRect(policyCrop, 0, 0, 500, 500);
+        assertRect(policyCrop, 0, 0, logicalWidth / 2, logicalHeight / 2);
 
         w.mDockedResizingForTest = true;
         w.calculatePolicyCrop(policyCrop);
         // But if we are docked resizing it won't be, however we will still be
         // shrunk to the decor frame and the display.
-        final DisplayInfo displayInfo = w.getDisplayContent().getDisplayInfo();
         assertRect(policyCrop, 0, 0,
                 Math.min(pf.width(), displayInfo.logicalWidth),
                 Math.min(pf.height(), displayInfo.logicalHeight));
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 26c9430..061c0af 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -2395,7 +2395,7 @@
      *   OR
      *   {@link android.Manifest.permission#READ_SMS}
      *   OR
-     *   {@link android.Manifest.permission#READ_PHONE_NUMBER}
+     *   {@link android.Manifest.permission#READ_PHONE_NUMBERS}
      * <p>
      * The default SMS app can also use this.
      */
@@ -2412,7 +2412,7 @@
      *   OR
      *   {@link android.Manifest.permission#READ_SMS}
      *   OR
-     *   {@link android.Manifest.permission#READ_PHONE_NUMBER}
+     *   {@link android.Manifest.permission#READ_PHONE_NUMBERS}
      * <p>
      * The default SMS app can also use this.
      *