diff options
author | Dianne Hackborn <hackbod@google.com> | 2015-06-11 13:29:01 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2015-06-11 18:07:43 -0700 |
commit | ece0f4f5198e9e9cb60e96f036baf22c73411bec (patch) | |
tree | bbbbce3ca974998bdea2347266173985a06d54b0 | |
parent | 2430f47be7b7de7456e16eb5098242c22a6317ee (diff) | |
download | frameworks_base-ece0f4f5198e9e9cb60e96f036baf22c73411bec.zip frameworks_base-ece0f4f5198e9e9cb60e96f036baf22c73411bec.tar.gz frameworks_base-ece0f4f5198e9e9cb60e96f036baf22c73411bec.tar.bz2 |
Fix APIs.
Issue #21039494: API Review: android.os.PowerManager.isDeviceIdleMode()
Issue #21347000: API Review: android.content.IntentFilter
Issue #20654534: API Review: android.app.assist
Also allow use of ActivityManager.setWatchHeapLimit on any platform
build as long as the calling app is debuggable.
Change-Id: Ic597e596fa772fcdf2553b64f444b3d9269e8b92
-rw-r--r-- | api/current.txt | 5 | ||||
-rw-r--r-- | api/system-current.txt | 5 | ||||
-rw-r--r-- | core/java/android/app/ActivityManager.java | 4 | ||||
-rw-r--r-- | core/java/android/app/AssistContent.java | 11 | ||||
-rw-r--r-- | core/java/android/app/AssistStructure.java | 190 | ||||
-rw-r--r-- | core/java/android/content/IntentFilter.java | 2 | ||||
-rw-r--r-- | core/java/android/os/PowerManager.java | 5 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 4 | ||||
-rw-r--r-- | core/java/android/view/ViewStructure.java | 11 | ||||
-rw-r--r-- | core/java/android/widget/TextView.java | 27 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 7 |
11 files changed, 249 insertions, 22 deletions
diff --git a/api/current.txt b/api/current.txt index 43c1ade..a2fc0de 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3999,6 +3999,7 @@ package android.app { 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); @@ -4057,6 +4058,7 @@ package android.app { } public static class AssistStructure.WindowNode { + method public int getDisplayId(); method public int getHeight(); method public int getLeft(); method public android.app.AssistStructure.ViewNode getRootViewNode(); @@ -8456,8 +8458,6 @@ package android.content { 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 } @@ -37053,6 +37053,7 @@ package android.view { 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 2345ef6..b340766 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4095,6 +4095,7 @@ package android.app { 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); @@ -4153,6 +4154,7 @@ package android.app { } public static class AssistStructure.WindowNode { + method public int getDisplayId(); method public int getHeight(); method public int getLeft(); method public android.app.AssistStructure.ViewNode getRootViewNode(); @@ -8688,8 +8690,6 @@ package android.content { 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 } @@ -39330,6 +39330,7 @@ package android.view { 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 @@ public class ActivityManager { * 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 @@ public class AssistContent { private Intent mIntent; private ClipData mClipData; private Uri mUri; + private final Bundle mExtras; /** * @hide @@ -53,6 +54,7 @@ public class AssistContent { } public AssistContent() { + mExtras = new Bundle(); } /** @@ -143,6 +145,13 @@ public class AssistContent { 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 @@ public class AssistContent { mUri = Uri.CREATOR.createFromParcel(in); } mIsAppProvidedIntent = in.readInt() == 1; + mExtras = in.readBundle(); } /** @hide */ @@ -178,5 +188,6 @@ public class AssistContent { 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 @@ public class AssistStructure { final int mWidth; final int mHeight; final CharSequence mTitle; + final int mDisplayId; final ViewNode mRoot; WindowNode(AssistStructure assist, ViewRootImpl root) { @@ -142,6 +143,7 @@ public class AssistStructure { 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 @@ public class AssistStructure { 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 @@ public class AssistStructure { 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 @@ public class AssistStructure { } } + /** + * 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 @@ public class AssistStructure { } @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 @@ public class AssistStructure { 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 @@ public class IntentFilter implements Parcelable { * 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 @@ public final class PowerManager { * 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 @@ public final class ViewRootImpl implements ViewParent, 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 class ViewStructure { 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 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @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 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * 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 @@ public final class ActivityManagerService extends ActivityManagerNative 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)) { |