Merge "send accessibility events on view property invalidation" into klp-modular-dev
diff --git a/api/current.txt b/api/current.txt
index a3a8938..e5e0f6c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -28772,26 +28772,17 @@
     method public abstract void onFocusLost(android.view.WindowId);
   }
 
-  public class WindowInsets {
+  public final class WindowInsets {
     ctor public WindowInsets(android.view.WindowInsets);
-    method public android.view.WindowInsets cloneWithSystemWindowInsets(int, int, int, int);
-    method public android.view.WindowInsets cloneWithSystemWindowInsetsConsumed();
-    method public android.view.WindowInsets cloneWithSystemWindowInsetsConsumed(boolean, boolean, boolean, boolean);
-    method public android.view.WindowInsets cloneWithWindowDecorInsets(int, int, int, int);
-    method public android.view.WindowInsets cloneWithWindowDecorInsetsConsumed();
-    method public android.view.WindowInsets cloneWithWindowDecorInsetsConsumed(boolean, boolean, boolean, boolean);
+    method public android.view.WindowInsets consumeSystemWindowInsets();
     method public int getSystemWindowInsetBottom();
     method public int getSystemWindowInsetLeft();
     method public int getSystemWindowInsetRight();
     method public int getSystemWindowInsetTop();
-    method public int getWindowDecorInsetBottom();
-    method public int getWindowDecorInsetLeft();
-    method public int getWindowDecorInsetRight();
-    method public int getWindowDecorInsetTop();
     method public boolean hasInsets();
     method public boolean hasSystemWindowInsets();
-    method public boolean hasWindowDecorInsets();
     method public boolean isRound();
+    method public android.view.WindowInsets replaceSystemWindowInsets(int, int, int, int);
   }
 
   public abstract interface WindowManager implements android.view.ViewManager {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index cf414bb..4c53df7 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -5989,12 +5989,12 @@
             // call into it as a fallback in case we're in a class that overrides it
             // and has logic to perform.
             if (fitSystemWindows(insets.getSystemWindowInsets())) {
-                return insets.cloneWithSystemWindowInsetsConsumed();
+                return insets.consumeSystemWindowInsets();
             }
         } else {
             // We were called from within a direct call to fitSystemWindows.
             if (fitSystemWindowsInt(insets.getSystemWindowInsets())) {
-                return insets.cloneWithSystemWindowInsetsConsumed();
+                return insets.consumeSystemWindowInsets();
             }
         }
         return insets;
diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java
index 2160efe..294f472 100644
--- a/core/java/android/view/WindowInsets.java
+++ b/core/java/android/view/WindowInsets.java
@@ -29,7 +29,7 @@
  * @see View.OnApplyWindowInsetsListener
  * @see View#onApplyWindowInsets(WindowInsets)
  */
-public class WindowInsets {
+public final class WindowInsets {
     private Rect mSystemWindowInsets;
     private Rect mWindowDecorInsets;
     private Rect mTempRect;
@@ -151,6 +151,7 @@
      * This can include action bars, title bars, toolbars, etc.</p>
      *
      * @return The left window decor inset
+     * @hide pending API
      */
     public int getWindowDecorInsetLeft() {
         return mWindowDecorInsets.left;
@@ -164,6 +165,7 @@
      * This can include action bars, title bars, toolbars, etc.</p>
      *
      * @return The top window decor inset
+     * @hide pending API
      */
     public int getWindowDecorInsetTop() {
         return mWindowDecorInsets.top;
@@ -177,6 +179,7 @@
      * This can include action bars, title bars, toolbars, etc.</p>
      *
      * @return The right window decor inset
+     * @hide pending API
      */
     public int getWindowDecorInsetRight() {
         return mWindowDecorInsets.right;
@@ -190,6 +193,7 @@
      * This can include action bars, title bars, toolbars, etc.</p>
      *
      * @return The bottom window decor inset
+     * @hide pending API
      */
     public int getWindowDecorInsetBottom() {
         return mWindowDecorInsets.bottom;
@@ -217,6 +221,7 @@
      * This can include action bars, title bars, toolbars, etc.</p>
      *
      * @return true if any of the window decor inset values are nonzero
+     * @hide pending API
      */
     public boolean hasWindowDecorInsets() {
         return mWindowDecorInsets.left != 0 || mWindowDecorInsets.top != 0 ||
@@ -246,13 +251,28 @@
         return mIsRound;
     }
 
-    public WindowInsets cloneWithSystemWindowInsetsConsumed() {
+    /**
+     * Returns a copy of this WindowInsets with the system window insets fully consumed.
+     *
+     * @return A modified copy of this WindowInsets
+     */
+    public WindowInsets consumeSystemWindowInsets() {
         final WindowInsets result = new WindowInsets(this);
         result.mSystemWindowInsets = new Rect(0, 0, 0, 0);
         return result;
     }
 
-    public WindowInsets cloneWithSystemWindowInsetsConsumed(boolean left, boolean top,
+    /**
+     * Returns a copy of this WindowInsets with selected system window insets fully consumed.
+     *
+     * @param left true to consume the left system window inset
+     * @param top true to consume the top system window inset
+     * @param right true to consume the right system window inset
+     * @param bottom true to consume the bottom system window inset
+     * @return A modified copy of this WindowInsets
+     * @hide pending API
+     */
+    public WindowInsets consumeSystemWindowInsets(boolean left, boolean top,
             boolean right, boolean bottom) {
         if (left || top || right || bottom) {
             final WindowInsets result = new WindowInsets(this);
@@ -265,19 +285,36 @@
         return this;
     }
 
-    public WindowInsets cloneWithSystemWindowInsets(int left, int top, int right, int bottom) {
+    /**
+     * Returns a copy of this WindowInsets with selected system window insets replaced
+     * with new values.
+     *
+     * @param left New left inset in pixels
+     * @param top New top inset in pixels
+     * @param right New right inset in pixels
+     * @param bottom New bottom inset in pixels
+     * @return A modified copy of this WindowInsets
+     */
+    public WindowInsets replaceSystemWindowInsets(int left, int top,
+            int right, int bottom) {
         final WindowInsets result = new WindowInsets(this);
         result.mSystemWindowInsets = new Rect(left, top, right, bottom);
         return result;
     }
 
-    public WindowInsets cloneWithWindowDecorInsetsConsumed() {
+    /**
+     * @hide
+     */
+    public WindowInsets consumeWindowDecorInsets() {
         final WindowInsets result = new WindowInsets(this);
         result.mWindowDecorInsets.set(0, 0, 0, 0);
         return result;
     }
 
-    public WindowInsets cloneWithWindowDecorInsetsConsumed(boolean left, boolean top,
+    /**
+     * @hide
+     */
+    public WindowInsets consumeWindowDecorInsets(boolean left, boolean top,
             boolean right, boolean bottom) {
         if (left || top || right || bottom) {
             final WindowInsets result = new WindowInsets(this);
@@ -290,7 +327,10 @@
         return this;
     }
 
-    public WindowInsets cloneWithWindowDecorInsets(int left, int top, int right, int bottom) {
+    /**
+     * @hide
+     */
+    public WindowInsets replaceWindowDecorInsets(int left, int top, int right, int bottom) {
         final WindowInsets result = new WindowInsets(this);
         result.mWindowDecorInsets = new Rect(left, top, right, bottom);
         return result;
diff --git a/docs/html/guide/components/intents-common.jd b/docs/html/guide/components/intents-common.jd
index a0f7ce1..b4813a5 100644
--- a/docs/html/guide/components/intents-common.jd
+++ b/docs/html/guide/components/intents-common.jd
@@ -737,7 +737,7 @@
 <pre>
 public void editContact(Uri contactUri, String email) {
     Intent intent = new Intent(Intent.ACTION_EDIT);
-    intent.setDataAndType(contactUri, Contacts.CONTENT_TYPE);
+    intent.setData(contactUri);
     intent.putExtra(Intents.Insert.EMAIL, email);
     if (intent.resolveActivity(getPackageManager()) != null) {
         startActivity(intent);
diff --git a/services/core/java/com/android/server/dreams/DreamManagerService.java b/services/core/java/com/android/server/dreams/DreamManagerService.java
index fd2f8a1..8968da3 100644
--- a/services/core/java/com/android/server/dreams/DreamManagerService.java
+++ b/services/core/java/com/android/server/dreams/DreamManagerService.java
@@ -642,8 +642,9 @@
             try {
                 synchronized (mMcuHal) {
                     if (mReleased) {
-                        throw new IllegalStateException("This operation cannot be performed "
-                                + "because the dream has ended.");
+                        Slog.w(TAG, "Ignoring message to MCU HAL because the dream "
+                                + "has already ended: " + msg);
+                        return null;
                     }
                     return mMcuHal.sendMessage(msg, arg);
                 }