Merge "Fix APIs." into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index d5685a6..3e0a1b3 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4000,6 +4000,7 @@
   public deprecated class AssistContent {
     ctor public AssistContent();
     method public android.content.ClipData getClipData();
+    method public android.os.Bundle getExtras();
     method public android.net.Uri getWebUri();
     method public boolean isAppProvidedIntent();
     method public void setClipData(android.content.ClipData);
@@ -4058,6 +4059,7 @@
   }
 
   public static class AssistStructure.WindowNode {
+    method public int getDisplayId();
     method public int getHeight();
     method public int getLeft();
     method public android.app.AssistStructure.ViewNode getRootViewNode();
@@ -8457,8 +8459,6 @@
     field public static final int NO_MATCH_CATEGORY = -4; // 0xfffffffc
     field public static final int NO_MATCH_DATA = -2; // 0xfffffffe
     field public static final int NO_MATCH_TYPE = -1; // 0xffffffff
-    field public static final java.lang.String SCHEME_HTTP = "http";
-    field public static final java.lang.String SCHEME_HTTPS = "https";
     field public static final int SYSTEM_HIGH_PRIORITY = 1000; // 0x3e8
     field public static final int SYSTEM_LOW_PRIORITY = -1000; // 0xfffffc18
   }
@@ -37054,6 +37054,7 @@
 
   public abstract class ViewStructure {
     ctor public ViewStructure();
+    method public abstract int addChildCount(int);
     method public abstract void asyncCommit();
     method public abstract android.view.ViewAssistStructure asyncNewChild(int);
     method public abstract int getChildCount();
diff --git a/api/system-current.txt b/api/system-current.txt
index fbf8d1d..a61b9fb53 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4096,6 +4096,7 @@
   public deprecated class AssistContent {
     ctor public AssistContent();
     method public android.content.ClipData getClipData();
+    method public android.os.Bundle getExtras();
     method public android.net.Uri getWebUri();
     method public boolean isAppProvidedIntent();
     method public void setClipData(android.content.ClipData);
@@ -4154,6 +4155,7 @@
   }
 
   public static class AssistStructure.WindowNode {
+    method public int getDisplayId();
     method public int getHeight();
     method public int getLeft();
     method public android.app.AssistStructure.ViewNode getRootViewNode();
@@ -8689,8 +8691,6 @@
     field public static final int NO_MATCH_CATEGORY = -4; // 0xfffffffc
     field public static final int NO_MATCH_DATA = -2; // 0xfffffffe
     field public static final int NO_MATCH_TYPE = -1; // 0xffffffff
-    field public static final java.lang.String SCHEME_HTTP = "http";
-    field public static final java.lang.String SCHEME_HTTPS = "https";
     field public static final int SYSTEM_HIGH_PRIORITY = 1000; // 0x3e8
     field public static final int SYSTEM_LOW_PRIORITY = -1000; // 0xfffffc18
   }
@@ -39331,6 +39331,7 @@
 
   public abstract class ViewStructure {
     ctor public ViewStructure();
+    method public abstract int addChildCount(int);
     method public abstract void asyncCommit();
     method public abstract android.view.ViewAssistStructure asyncNewChild(int);
     method public abstract int getChildCount();
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index da345a6..b65593d 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -2812,7 +2812,9 @@
      * continues running even if the process is killed and restarted.  To remove the watch,
      * use {@link #clearWatchHeapLimit()}.
      *
-     * <p>This API only work if running on a debuggable (userdebug or eng) build.</p>
+     * <p>This API only work if the calling process has been marked as
+     * {@link ApplicationInfo#FLAG_DEBUGGABLE} or this is running on a debuggable
+     * (userdebug or eng) build.</p>
      *
      * <p>Callers can optionally implement {@link #ACTION_REPORT_HEAP_LIMIT} to directly
      * handle heap limit reports themselves.</p>
diff --git a/core/java/android/app/AssistContent.java b/core/java/android/app/AssistContent.java
index 173b237..0df9ce5 100644
--- a/core/java/android/app/AssistContent.java
+++ b/core/java/android/app/AssistContent.java
@@ -35,6 +35,7 @@
     private Intent mIntent;
     private ClipData mClipData;
     private Uri mUri;
+    private final Bundle mExtras;
 
     /**
      * @hide
@@ -53,6 +54,7 @@
     }
 
     public AssistContent() {
+        mExtras = new Bundle();
     }
 
     /**
@@ -143,6 +145,13 @@
         return mUri;
     }
 
+    /**
+     * Return Bundle for extra vendor-specific data that can be modified and examined.
+     */
+    public Bundle getExtras() {
+        return mExtras;
+    }
+
     /** @hide */
     public AssistContent(Parcel in) {
         if (in.readInt() != 0) {
@@ -155,6 +164,7 @@
             mUri = Uri.CREATOR.createFromParcel(in);
         }
         mIsAppProvidedIntent = in.readInt() == 1;
+        mExtras = in.readBundle();
     }
 
     /** @hide */
@@ -178,5 +188,6 @@
             dest.writeInt(0);
         }
         dest.writeInt(mIsAppProvidedIntent ? 1 : 0);
+        dest.writeBundle(mExtras);
     }
 }
diff --git a/core/java/android/app/AssistStructure.java b/core/java/android/app/AssistStructure.java
index 0f69817..7f6dae5 100644
--- a/core/java/android/app/AssistStructure.java
+++ b/core/java/android/app/AssistStructure.java
@@ -131,6 +131,7 @@
         final int mWidth;
         final int mHeight;
         final CharSequence mTitle;
+        final int mDisplayId;
         final ViewNode mRoot;
 
         WindowNode(AssistStructure assist, ViewRootImpl root) {
@@ -142,6 +143,7 @@
             mWidth = rect.width();
             mHeight = rect.height();
             mTitle = root.getTitle();
+            mDisplayId = root.getDisplayId();
             mRoot = new ViewNode();
             ViewNodeBuilder builder = new ViewNodeBuilder(assist, mRoot, false);
             if ((root.getWindowFlags()&WindowManager.LayoutParams.FLAG_SECURE) != 0) {
@@ -160,6 +162,7 @@
             mWidth = in.readInt();
             mHeight = in.readInt();
             mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+            mDisplayId = in.readInt();
             mRoot = new ViewNode(in, preader);
         }
 
@@ -169,29 +172,58 @@
             out.writeInt(mWidth);
             out.writeInt(mHeight);
             TextUtils.writeToParcel(mTitle, out, 0);
+            out.writeInt(mDisplayId);
             mRoot.writeToParcel(out, pwriter);
         }
 
+        /**
+         * Returns the left edge of the window, in pixels, relative to the left
+         * edge of the screen.
+         */
         public int getLeft() {
             return mX;
         }
 
+        /**
+         * Returns the top edge of the window, in pixels, relative to the top
+         * edge of the screen.
+         */
         public int getTop() {
             return mY;
         }
 
+        /**
+         * Returns the total width of the window in pixels.
+         */
         public int getWidth() {
             return mWidth;
         }
 
+        /**
+         * Returns the total height of the window in pixels.
+         */
         public int getHeight() {
             return mHeight;
         }
 
+        /**
+         * Returns the title associated with the window, if it has one.
+         */
         public CharSequence getTitle() {
             return mTitle;
         }
 
+        /**
+         * Returns the ID of the display this window is on, for use with
+         * {@link android.hardware.display.DisplayManager#getDisplay DisplayManager.getDisplay()}.
+         */
+        public int getDisplayId() {
+            return mDisplayId;
+        }
+
+        /**
+         * Returns the {@link ViewNode} containing the root content of the window.
+         */
         public ViewNode getRootViewNode() {
             return mRoot;
         }
@@ -325,146 +357,288 @@
             }
         }
 
+        /**
+         * Returns the ID associated with this view, as per {@link View#getId() View.getId()}.
+         */
         public int getId() {
             return mId;
         }
 
+        /**
+         * If {@link #getId()} is a resource identifier, this is the package name of that
+         * identifier.  See {@link android.view.ViewStructure#setId ViewStructure.setId}
+         * for more information.
+         */
         public String getIdPackage() {
             return mIdPackage;
         }
 
+        /**
+         * If {@link #getId()} is a resource identifier, this is the type name of that
+         * identifier.  See {@link android.view.ViewStructure#setId ViewStructure.setId}
+         * for more information.
+         */
         public String getIdType() {
             return mIdType;
         }
 
+        /**
+         * If {@link #getId()} is a resource identifier, this is the entry name of that
+         * identifier.  See {@link android.view.ViewStructure#setId ViewStructure.setId}
+         * for more information.
+         */
         public String getIdEntry() {
             return mIdEntry;
         }
 
+        /**
+         * Returns the left edge of this view, in pixels, relative to the left edge of its parent.
+         */
         public int getLeft() {
             return mX;
         }
 
+        /**
+         * Returns the top edge of this view, in pixels, relative to the top edge of its parent.
+         */
         public int getTop() {
             return mY;
         }
 
+        /**
+         * Returns the current X scroll offset of this view, as per
+         * {@link android.view.View#getScrollX() View.getScrollX()}.
+         */
         public int getScrollX() {
             return mScrollX;
         }
 
+        /**
+         * Returns the current Y scroll offset of this view, as per
+         * {@link android.view.View#getScrollX() View.getScrollY()}.
+         */
         public int getScrollY() {
             return mScrollY;
         }
 
+        /**
+         * Returns the width of this view, in pixels.
+         */
         public int getWidth() {
             return mWidth;
         }
 
+        /**
+         * Returns the height of this view, in pixels.
+         */
         public int getHeight() {
             return mHeight;
         }
 
+        /**
+         * Returns the visibility mode of this view, as per
+         * {@link android.view.View#getVisibility() View.getVisibility()}.
+         */
         public int getVisibility() {
             return mFlags&ViewNode.FLAGS_VISIBILITY_MASK;
         }
 
+        /**
+         * Returns true if assist data has been blocked starting at this node in the hierarchy.
+         */
         public boolean isAssistBlocked() {
             return (mFlags&ViewNode.FLAGS_ASSIST_BLOCKED) == 0;
         }
 
+        /**
+         * Returns true if this node is in an enabled state.
+         */
         public boolean isEnabled() {
             return (mFlags&ViewNode.FLAGS_DISABLED) == 0;
         }
 
+        /**
+         * Returns true if this node is clickable by the user.
+         */
         public boolean isClickable() {
             return (mFlags&ViewNode.FLAGS_CLICKABLE) != 0;
         }
 
+        /**
+         * Returns true if this node can take input focus.
+         */
         public boolean isFocusable() {
             return (mFlags&ViewNode.FLAGS_FOCUSABLE) != 0;
         }
 
+        /**
+         * Returns true if this node currently had input focus at the time that the
+         * structure was collected.
+         */
         public boolean isFocused() {
             return (mFlags&ViewNode.FLAGS_FOCUSED) != 0;
         }
 
+        /**
+         * Returns true if this node currently had accessibility focus at the time that the
+         * structure was collected.
+         */
         public boolean isAccessibilityFocused() {
             return (mFlags&ViewNode.FLAGS_ACCESSIBILITY_FOCUSED) != 0;
         }
 
+        /**
+         * Returns true if this node represents something that is checkable by the user.
+         */
         public boolean isCheckable() {
             return (mFlags&ViewNode.FLAGS_CHECKABLE) != 0;
         }
 
+        /**
+         * Returns true if this node is currently in a checked state.
+         */
         public boolean isChecked() {
             return (mFlags&ViewNode.FLAGS_CHECKED) != 0;
         }
 
+        /**
+         * Returns true if this node has currently been selected by the user.
+         */
         public boolean isSelected() {
             return (mFlags&ViewNode.FLAGS_SELECTED) != 0;
         }
 
+        /**
+         * Returns true if this node has currently been activated by the user.
+         */
         public boolean isActivated() {
             return (mFlags&ViewNode.FLAGS_ACTIVATED) != 0;
         }
 
+        /**
+         * Returns true if this node is something the user can perform a long click/press on.
+         */
         public boolean isLongClickable() {
             return (mFlags&ViewNode.FLAGS_LONG_CLICKABLE) != 0;
         }
 
+        /**
+         * Returns true if this node is something the user can perform a context click on.
+         */
         public boolean isContextClickable() {
             return (mFlags&ViewNode.FLAGS_CONTEXT_CLICKABLE) != 0;
         }
 
+        /**
+         * Returns the class name of the node's implementation, indicating its behavior.
+         * For example, a button will report "android.widget.Button" meaning it behaves
+         * like a {@link android.widget.Button}.
+         */
         public String getClassName() {
             return mClassName;
         }
 
+        /**
+         * Returns any content description associated with the node, which semantically describes
+         * its purpose for accessibility and other uses.
+         */
         public CharSequence getContentDescription() {
             return mContentDescription;
         }
 
+        /**
+         * Returns any text associated with the node that is displayed to the user, or null
+         * if there is none.
+         */
         public CharSequence getText() {
             return mText != null ? mText.mText : null;
         }
 
+        /**
+         * If {@link #getText()} is non-null, this is where the current selection starts.
+         */
         public int getTextSelectionStart() {
             return mText != null ? mText.mTextSelectionStart : -1;
         }
 
+        /**
+         * If {@link #getText()} is non-null, this is where the current selection starts.
+         * If there is no selection, returns the same value as {@link #getTextSelectionStart()},
+         * indicating the cursor position.
+         */
         public int getTextSelectionEnd() {
             return mText != null ? mText.mTextSelectionEnd : -1;
         }
 
+        /**
+         * If {@link #getText()} is non-null, this is the main text color associated with it.
+         * If there is no text color, {@link #TEXT_COLOR_UNDEFINED} is returned.
+         * Note that the text may also contain style spans that modify the color of specific
+         * parts of the text.
+         */
         public int getTextColor() {
             return mText != null ? mText.mTextColor : TEXT_COLOR_UNDEFINED;
         }
 
+        /**
+         * If {@link #getText()} is non-null, this is the main text background color associated
+         * with it.
+         * If there is no text background color, {@link #TEXT_COLOR_UNDEFINED} is returned.
+         * Note that the text may also contain style spans that modify the color of specific
+         * parts of the text.
+         */
         public int getTextBackgroundColor() {
             return mText != null ? mText.mTextBackgroundColor : TEXT_COLOR_UNDEFINED;
         }
 
+        /**
+         * If {@link #getText()} is non-null, this is the main text size (in pixels) associated
+         * with it.
+         * Note that the text may also contain style spans that modify the size of specific
+         * parts of the text.
+         */
         public float getTextSize() {
             return mText != null ? mText.mTextSize : 0;
         }
 
+        /**
+         * If {@link #getText()} is non-null, this is the main text style associated
+         * with it, containing a bit mask of {@link #TEXT_STYLE_BOLD},
+         * {@link #TEXT_STYLE_BOLD}, {@link #TEXT_STYLE_STRIKE_THRU}, and/or
+         * {@link #TEXT_STYLE_UNDERLINE}.
+         * Note that the text may also contain style spans that modify the style of specific
+         * parts of the text.
+         */
         public int getTextStyle() {
             return mText != null ? mText.mTextStyle : 0;
         }
 
+        /**
+         * Return additional hint text associated with the node; this is typically used with
+         * a node that takes user input, describing to the user what the input means.
+         */
         public String getHint() {
             return mText != null ? mText.mHint : null;
         }
 
+        /**
+         * Return a Bundle containing optional vendor-specific extension information.
+         */
         public Bundle getExtras() {
             return mExtras;
         }
 
+        /**
+         * Return the number of children this node has.
+         */
         public int getChildCount() {
             return mChildren != null ? mChildren.length : 0;
         }
 
+        /**
+         * Return a child of this node, given an index value from 0 to
+         * {@link #getChildCount()}-1.
+         */
         public ViewNode getChildAt(int index) {
             return mChildren[index];
         }
@@ -663,6 +837,19 @@
         }
 
         @Override
+        public int addChildCount(int num) {
+            if (mNode.mChildren == null) {
+                setChildCount(num);
+                return 0;
+            }
+            final int start = mNode.mChildren.length;
+            ViewNode[] newArray = new ViewNode[start + num];
+            System.arraycopy(mNode.mChildren, 0, newArray, 0, start);
+            mNode.mChildren = newArray;
+            return start;
+        }
+
+        @Override
         public int getChildCount() {
             return mNode.mChildren != null ? mNode.mChildren.length : 0;
         }
@@ -801,6 +988,9 @@
         return assistBundle.getParcelable(ASSIST_KEY);
     }
 
+    /**
+     * Return the activity this AssistStructure came from.
+     */
     public ComponentName getActivityComponent() {
         ensureData();
         return mActivityComponent;
diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java
index 33c0b87..08c5236 100644
--- a/core/java/android/content/IntentFilter.java
+++ b/core/java/android/content/IntentFilter.java
@@ -254,12 +254,14 @@
      * HTTP scheme.
      *
      * @see #addDataScheme(String)
+     * @hide
      */
     public static final String SCHEME_HTTP = "http";
     /**
      * HTTPS scheme.
      *
      * @see #addDataScheme(String)
+     * @hide
      */
     public static final String SCHEME_HTTPS = "https";
 
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 8b18f32..7a1aa1e 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -878,7 +878,10 @@
      * off network access to apps.  You can monitor for changes to this state with
      * {@link #ACTION_DEVICE_IDLE_MODE_CHANGED}.
      *
-     * @return Returns true if currently in low power mode, else false.
+     * @return Returns true if currently in active device idle mode, else false.  This is
+     * when idle mode restrictions are being actively applied; it will return false if the
+     * device is in a long-term idle mode but currently running a maintenance window where
+     * restrictions have been lifted.
      */
     public boolean isDeviceIdleMode() {
         try {
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index e2f42db..8b57d96 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -663,6 +663,10 @@
         return mWindowAttributes.flags;
     }
 
+    public int getDisplayId() {
+        return mDisplay.getDisplayId();
+    }
+
     public CharSequence getTitle() {
         return mWindowAttributes.getTitle();
     }
diff --git a/core/java/android/view/ViewStructure.java b/core/java/android/view/ViewStructure.java
index 8ceb166..d06cd83 100644
--- a/core/java/android/view/ViewStructure.java
+++ b/core/java/android/view/ViewStructure.java
@@ -201,6 +201,17 @@
     public abstract void setChildCount(int num);
 
     /**
+     * Add to this view's child count.  This increases the current child count by
+     * <var>num</var> children beyond what was last set by {@link #setChildCount}
+     * or {@link #addChildCount}.  The index at which the new child starts in the child
+     * array is returned.
+     *
+     * @param num The number of new children to add.
+     * @return Returns the index in the child array at which the new children start.
+     */
+    public abstract int addChildCount(int num);
+
+    /**
      * Return the child count as set by {@link #setChildCount}.
      */
     public abstract int getChildCount();
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 353901c..78b5d5d 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8790,7 +8790,8 @@
     @Override
     public void onProvideStructure(ViewStructure structure) {
         super.onProvideStructure(structure);
-        final boolean isPassword = hasPasswordTransformationMethod();
+        final boolean isPassword = hasPasswordTransformationMethod()
+                || isPasswordInputType(getInputType());
         if (!isPassword) {
             structure.setText(getText(), getSelectionStart(), getSelectionEnd());
 
@@ -9244,25 +9245,25 @@
     /**
      * If provided, this ActionMode.Callback will be used to create the ActionMode when text
      * insertion is initiated in this View.
-     *
      * The standard implementation populates the menu with a subset of Select All,
      * Paste and Replace actions, depending on what this View supports.
      *
-     * A custom implementation can add new entries in the default menu in its
-     * {@link android.view.ActionMode.Callback#onPrepareActionMode(ActionMode, Menu)} method. The
-     * default actions can also be removed from the menu using
+     * <p>A custom implementation can add new entries in the default menu in its
+     * {@link android.view.ActionMode.Callback#onPrepareActionMode(android.view.ActionMode,
+     * android.view.Menu)} method. The default actions can also be removed from the menu using
      * {@link android.view.Menu#removeItem(int)} and passing {@link android.R.id#selectAll},
-     * {@link android.R.id#paste} or {@link android.R.id#replaceText} ids as parameters.
+     * {@link android.R.id#paste} or {@link android.R.id#replaceText} ids as parameters.</p>
      *
-     * Returning false from
-     * {@link android.view.ActionMode.Callback#onCreateActionMode(ActionMode, Menu)} will prevent
-     * the action mode from being started.
+     * <p>Returning false from
+     * {@link android.view.ActionMode.Callback#onCreateActionMode(android.view.ActionMode,
+     * android.view.Menu)} will prevent the action mode from being started.</p>
      *
-     * Action click events should be handled by the custom implementation of
-     * {@link android.view.ActionMode.Callback#onActionItemClicked(ActionMode, MenuItem)}.
+     * <p>Action click events should be handled by the custom implementation of
+     * {@link android.view.ActionMode.Callback#onActionItemClicked(android.view.ActionMode,
+     * android.view.MenuItem)}.</p>
      *
-     * Note that text insertion mode is not started when a TextView receives focus and the
-     * {@link android.R.attr#selectAllOnFocus} flag has been set.
+     * <p>Note that text insertion mode is not started when a TextView receives focus and the
+     * {@link android.R.attr#selectAllOnFocus} flag has been set.</p>
      */
     public void setCustomInsertionActionModeCallback(ActionMode.Callback actionModeCallback) {
         createEditorIfNeeded();
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 6496ba2..029a3b2 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -19382,15 +19382,16 @@
             enforceCallingPermission(android.Manifest.permission.SET_DEBUG_APP,
                     "setDumpHeapDebugLimit()");
         } else {
-            if (!Build.IS_DEBUGGABLE) {
-                throw new SecurityException("Not running a debuggable build");
-            }
             synchronized (mPidsSelfLocked) {
                 ProcessRecord proc = mPidsSelfLocked.get(Binder.getCallingPid());
                 if (proc == null) {
                     throw new SecurityException("No process found for calling pid "
                             + Binder.getCallingPid());
                 }
+                if (!Build.IS_DEBUGGABLE
+                        && (proc.info.flags&ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
+                    throw new SecurityException("Not running a debuggable build");
+                }
                 processName = proc.processName;
                 uid = proc.uid;
                 if (reportPackage != null && !proc.pkgList.containsKey(reportPackage)) {