diff options
author | Dianne Hackborn <hackbod@google.com> | 2015-05-08 20:42:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-08 20:42:12 +0000 |
commit | ed9af066b2407a36699fae2e475c4d1b53d2ca1d (patch) | |
tree | 005f834b928f7a47220e1468b7aa90d6fee1bfd3 /core | |
parent | 180fd27832b429aaca0a35e8b93c88195b6451be (diff) | |
parent | 49b043f37d7231b1544cb72e1bfb616e5a00688d (diff) | |
download | frameworks_base-ed9af066b2407a36699fae2e475c4d1b53d2ca1d.zip frameworks_base-ed9af066b2407a36699fae2e475c4d1b53d2ca1d.tar.gz frameworks_base-ed9af066b2407a36699fae2e475c4d1b53d2ca1d.tar.bz2 |
Merge "Fix issue #20655182: API Review: ViewAssistStructure" into mnc-dev
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/AssistStructure.java | 16 | ||||
-rw-r--r-- | core/java/android/view/View.java | 52 | ||||
-rw-r--r-- | core/java/android/view/ViewAssistStructure.java | 67 | ||||
-rw-r--r-- | core/java/android/view/ViewGroup.java | 10 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 4 | ||||
-rw-r--r-- | core/java/android/view/ViewStructure.java | 86 | ||||
-rw-r--r-- | core/java/android/webkit/WebView.java | 4 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewProvider.java | 4 | ||||
-rw-r--r-- | core/java/android/widget/Switch.java | 8 | ||||
-rw-r--r-- | core/java/android/widget/TextView.java | 6 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 5 | ||||
-rw-r--r-- | core/res/res/values/public.xml | 4 |
12 files changed, 152 insertions, 114 deletions
diff --git a/core/java/android/app/AssistStructure.java b/core/java/android/app/AssistStructure.java index 3abbb5b..a06bc31 100644 --- a/core/java/android/app/AssistStructure.java +++ b/core/java/android/app/AssistStructure.java @@ -35,6 +35,7 @@ import android.util.Log; import android.view.View; import android.view.ViewAssistStructure; import android.view.ViewRootImpl; +import android.view.WindowManager; import android.view.WindowManagerGlobal; import java.util.ArrayList; @@ -140,7 +141,14 @@ final public class AssistStructure implements Parcelable { mTitle = root.getTitle(); mRoot = new ViewNode(); ViewNodeBuilder builder = new ViewNodeBuilder(assist, mRoot, false); - view.dispatchProvideAssistStructure(builder); + if ((root.getWindowFlags()&WindowManager.LayoutParams.FLAG_SECURE) != 0) { + // This is a secure window, so it doesn't want a screenshot, and that + // means we should also not copy out its view hierarchy. + view.onProvideStructure(builder); + builder.setAssistBlocked(true); + return; + } + view.dispatchProvideStructure(builder); } WindowNode(Parcel in, PooledStringReader preader) { @@ -652,7 +660,7 @@ final public class AssistStructure implements Parcelable { } @Override - public Bundle editExtras() { + public Bundle getExtras() { if (mNode.mExtras != null) { return mNode.mExtras; } @@ -661,8 +669,8 @@ final public class AssistStructure implements Parcelable { } @Override - public void clearExtras() { - mNode.mExtras = null; + public boolean hasExtras() { + return mNode.mExtras != null; } @Override diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index a3d0b2a..e1f1816 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -633,7 +633,6 @@ import java.util.concurrent.atomic.AtomicInteger; * </p> * * @attr ref android.R.styleable#View_alpha - * @attr ref android.R.styleable#View_assistBlocked * @attr ref android.R.styleable#View_background * @attr ref android.R.styleable#View_clickable * @attr ref android.R.styleable#View_contentDescription @@ -2533,7 +2532,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, PFLAG3_SCROLL_INDICATOR_END >> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; /** - * <p>Indicates that we are allowing {@link android.view.ViewAssistStructure} to traverse + * <p>Indicates that we are allowing {@link ViewStructure} to traverse * into this view.<p> */ static final int PFLAG3_ASSIST_BLOCKED = 0x100; @@ -4050,11 +4049,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, viewFlagMasks |= SAVE_DISABLED_MASK; } break; - case com.android.internal.R.styleable.View_assistBlocked: - if (a.getBoolean(attr, false)) { - mPrivateFlags3 |= PFLAG3_ASSIST_BLOCKED; - } - break; case com.android.internal.R.styleable.View_duplicateParentState: if (a.getBoolean(attr, false)) { viewFlagValues |= DUPLICATE_PARENT_STATE; @@ -6163,7 +6157,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @param structure Fill in with structured view data. The default implementation * fills in all data that can be inferred from the view itself. */ - public void onProvideAssistStructure(ViewAssistStructure structure) { + public void onProvideStructure(ViewStructure structure) { final int id = mID; if (id > 0 && (id&0xff000000) != 0 && (id&0x00ff0000) != 0 && (id&0x0000ffff) != 0) { @@ -6217,6 +6211,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, structure.setContentDescription(getContentDescription()); } + /** @hide */ + public void onProvideAssistStructure(ViewStructure structure) { + onProvideStructure(structure); + } + /** * Called when assist structure is being retrieved from a view as part of * {@link android.app.Activity#onProvideAssistData Activity.onProvideAssistData} to @@ -6225,19 +6224,24 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * view's virtual accessibility nodes, if any. You can override this for a more * optimal implementation providing this data. */ - public void onProvideVirtualAssistStructure(ViewAssistStructure structure) { + public void onProvideVirtualStructure(ViewStructure structure) { AccessibilityNodeProvider provider = getAccessibilityNodeProvider(); if (provider != null) { AccessibilityNodeInfo info = createAccessibilityNodeInfo(); Log.i("View", "Provider of " + this + ": children=" + info.getChildCount()); structure.setChildCount(1); - ViewAssistStructure root = structure.newChild(0); - populateVirtualAssistStructure(root, provider, info); + ViewStructure root = structure.newChild(0); + populateVirtualStructure(root, provider, info); info.recycle(); } } - private void populateVirtualAssistStructure(ViewAssistStructure structure, + /** @hide */ + public void onProvideVirtualAssistStructure(ViewStructure structure) { + onProvideVirtualStructure(structure); + } + + private void populateVirtualStructure(ViewStructure structure, AccessibilityNodeProvider provider, AccessibilityNodeInfo info) { structure.setId(AccessibilityNodeInfo.getVirtualDescendantId(info.getSourceNodeId()), null, null, null); @@ -6288,19 +6292,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, for (int i=0; i<NCHILDREN; i++) { AccessibilityNodeInfo cinfo = provider.createAccessibilityNodeInfo( AccessibilityNodeInfo.getVirtualDescendantId(info.getChildId(i))); - ViewAssistStructure child = structure.newChild(i); - populateVirtualAssistStructure(child, provider, cinfo); + ViewStructure child = structure.newChild(i); + populateVirtualStructure(child, provider, cinfo); cinfo.recycle(); } } } /** - * Dispatch creation of {@link ViewAssistStructure} down the hierarchy. The default - * implementation calls {@link #onProvideAssistStructure} and - * {@link #onProvideVirtualAssistStructure}. + * Dispatch creation of {@link ViewStructure} down the hierarchy. The default + * implementation calls {@link #onProvideStructure} and + * {@link #onProvideVirtualStructure}. */ - public void dispatchProvideAssistStructure(ViewAssistStructure structure) { + public void dispatchProvideStructure(ViewStructure structure) { if (!isAssistBlocked()) { onProvideAssistStructure(structure); onProvideVirtualAssistStructure(structure); @@ -7904,8 +7908,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** + * @hide * Indicates whether this view will participate in data collection through - * {@link android.view.ViewAssistStructure}. If true, it will not provide any data + * {@link ViewStructure}. If true, it will not provide any data * for itself or its children. If false, the normal data collection will be allowed. * * @return Returns false if assist data collection is not blocked, else true. @@ -7918,17 +7923,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** + * @hide * Controls whether assist data collection from this view and its children is enabled - * (that is, whether {@link #onProvideAssistStructure} and - * {@link #onProvideVirtualAssistStructure} will be called). The default value is false, + * (that is, whether {@link #onProvideStructure} and + * {@link #onProvideVirtualStructure} will be called). The default value is false, * allowing normal assist collection. Setting this to false will disable assist collection. * * @param enabled Set to true to <em>disable</em> assist data collection, or false * (the default) to allow it. * * @see #isAssistBlocked() - * @see #onProvideAssistStructure - * @see #onProvideVirtualAssistStructure + * @see #onProvideStructure + * @see #onProvideVirtualStructure * @attr ref android.R.styleable#View_assistBlocked */ public void setAssistBlocked(boolean enabled) { diff --git a/core/java/android/view/ViewAssistStructure.java b/core/java/android/view/ViewAssistStructure.java index fccfbb8..a66d93c 100644 --- a/core/java/android/view/ViewAssistStructure.java +++ b/core/java/android/view/ViewAssistStructure.java @@ -16,70 +16,9 @@ package android.view; -import android.graphics.Rect; -import android.os.Bundle; -import android.text.TextPaint; - /** - * Container for storing additional per-view data generated by {@link View#onProvideAssistStructure - * View.onProvideAssistStructure}. + * @deprecated Temporary until old apps can move off this. */ -public abstract class ViewAssistStructure { - public abstract void setId(int id, String packageName, String typeName, String entryName); - - public abstract void setDimens(int left, int top, int scrollX, int scrollY, int width, - int height); - - public abstract void setVisibility(int visibility); - - public abstract void setAssistBlocked(boolean state); - - public abstract void setEnabled(boolean state); - - public abstract void setClickable(boolean state); - - public abstract void setLongClickable(boolean state); - - public abstract void setStylusButtonPressable(boolean state); - - public abstract void setFocusable(boolean state); - - public abstract void setFocused(boolean state); - - public abstract void setAccessibilityFocused(boolean state); - - public abstract void setCheckable(boolean state); - - public abstract void setChecked(boolean state); - - public abstract void setSelected(boolean state); - - public abstract void setActivated(boolean state); - - public abstract void setClassName(String className); - - public abstract void setContentDescription(CharSequence contentDescription); - - public abstract void setText(CharSequence text); - public abstract void setText(CharSequence text, int selectionStart, int selectionEnd); - public abstract void setTextPaint(TextPaint paint); - public abstract void setHint(CharSequence hint); - - public abstract CharSequence getText(); - public abstract int getTextSelectionStart(); - public abstract int getTextSelectionEnd(); - public abstract CharSequence getHint(); - - public abstract Bundle editExtras(); - public abstract void clearExtras(); - - public abstract void setChildCount(int num); - public abstract int getChildCount(); - public abstract ViewAssistStructure newChild(int index); - - public abstract ViewAssistStructure asyncNewChild(int index); - public abstract void asyncCommit(); - - /** @hide */ - public abstract Rect getTempRect(); +@Deprecated +public abstract class ViewAssistStructure extends ViewStructure { } diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index d0738b0..51c4760 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2878,12 +2878,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } /** - * Dispatch creation of {@link ViewAssistStructure} down the hierarchy. This implementation + * Dispatch creation of {@link ViewStructure} down the hierarchy. This implementation * adds in all child views of the view group, in addition to calling the default View * implementation. */ - public void dispatchProvideAssistStructure(ViewAssistStructure structure) { - super.dispatchProvideAssistStructure(structure); + public void dispatchProvideStructure(ViewStructure structure) { + super.dispatchProvideStructure(structure); if (!isAssistBlocked()) { if (structure.getChildCount() == 0) { final int childrenCount = getChildCount(); @@ -2898,8 +2898,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager ? getChildDrawingOrder(childrenCount, i) : i; final View child = (preorderedList == null) ? children[childIndex] : preorderedList.get(childIndex); - ViewAssistStructure cstructure = structure.newChild(i); - child.dispatchProvideAssistStructure(cstructure); + ViewStructure cstructure = structure.newChild(i); + child.dispatchProvideStructure(cstructure); } } } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index c9c2a82..ea1dadb 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -654,6 +654,10 @@ public final class ViewRootImpl implements ViewParent, return (mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE) != 0; } + public int getWindowFlags() { + return mWindowAttributes.flags; + } + public CharSequence getTitle() { return mWindowAttributes.getTitle(); } diff --git a/core/java/android/view/ViewStructure.java b/core/java/android/view/ViewStructure.java new file mode 100644 index 0000000..8dc49ac --- /dev/null +++ b/core/java/android/view/ViewStructure.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view; + +import android.graphics.Rect; +import android.os.Bundle; +import android.text.TextPaint; + +/** + * Container for storing additional per-view data generated by {@link View#onProvideStructure + * View.onProvideStructure}. + */ +public abstract class ViewStructure { + public abstract void setId(int id, String packageName, String typeName, String entryName); + + public abstract void setDimens(int left, int top, int scrollX, int scrollY, int width, + int height); + + public abstract void setVisibility(int visibility); + + /** @hide */ + public abstract void setAssistBlocked(boolean state); + + public abstract void setEnabled(boolean state); + + public abstract void setClickable(boolean state); + + public abstract void setLongClickable(boolean state); + + public abstract void setStylusButtonPressable(boolean state); + + public abstract void setFocusable(boolean state); + + public abstract void setFocused(boolean state); + + public abstract void setAccessibilityFocused(boolean state); + + public abstract void setCheckable(boolean state); + + public abstract void setChecked(boolean state); + + public abstract void setSelected(boolean state); + + public abstract void setActivated(boolean state); + + public abstract void setClassName(String className); + + public abstract void setContentDescription(CharSequence contentDescription); + + public abstract void setText(CharSequence text); + public abstract void setText(CharSequence text, int selectionStart, int selectionEnd); + public abstract void setTextPaint(TextPaint paint); + public abstract void setHint(CharSequence hint); + + public abstract CharSequence getText(); + public abstract int getTextSelectionStart(); + public abstract int getTextSelectionEnd(); + public abstract CharSequence getHint(); + + public abstract Bundle getExtras(); + public abstract boolean hasExtras(); + + public abstract void setChildCount(int num); + public abstract int getChildCount(); + public abstract ViewAssistStructure newChild(int index); + + public abstract ViewAssistStructure asyncNewChild(int index); + public abstract void asyncCommit(); + + /** @hide */ + public abstract Rect getTempRect(); +} diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index a261aaf..e27e253 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -41,7 +41,7 @@ import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -import android.view.ViewAssistStructure; +import android.view.ViewStructure; import android.view.ViewDebug; import android.view.ViewGroup; import android.view.ViewHierarchyEncoder; @@ -2428,7 +2428,7 @@ public class WebView extends AbsoluteLayout } @Override - public void onProvideVirtualAssistStructure(ViewAssistStructure structure) { + public void onProvideVirtualStructure(ViewStructure structure) { mProvider.getViewDelegate().onProvideVirtualAssistStructure(structure); } diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java index d5787de..e367192 100644 --- a/core/java/android/webkit/WebViewProvider.java +++ b/core/java/android/webkit/WebViewProvider.java @@ -32,7 +32,7 @@ import android.print.PrintDocumentAdapter; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -import android.view.ViewAssistStructure; +import android.view.ViewStructure; import android.view.ViewGroup.LayoutParams; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -299,7 +299,7 @@ public interface WebViewProvider { interface ViewDelegate { public boolean shouldDelayChildPressedState(); - public void onProvideVirtualAssistStructure(ViewAssistStructure structure); + public void onProvideVirtualAssistStructure(ViewStructure structure); public AccessibilityNodeProvider getAccessibilityNodeProvider(); diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index f94f97c..ff587c2 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -26,13 +26,11 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Insets; -import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.Region.Op; import android.graphics.drawable.Drawable; -import android.os.Bundle; import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; @@ -46,7 +44,7 @@ import android.view.Gravity; import android.view.MotionEvent; import android.view.SoundEffectConstants; import android.view.VelocityTracker; -import android.view.ViewAssistStructure; +import android.view.ViewStructure; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -1363,8 +1361,8 @@ public class Switch extends CompoundButton { } @Override - public void onProvideAssistStructure(ViewAssistStructure structure) { - super.onProvideAssistStructure(structure); + public void onProvideStructure(ViewStructure structure) { + super.onProvideStructure(structure); CharSequence switchText = isChecked() ? mTextOn : mTextOff; if (!TextUtils.isEmpty(switchText)) { CharSequence oldText = structure.getText(); diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b9a08f5..68c49cd 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -114,7 +114,7 @@ import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -import android.view.ViewAssistStructure; +import android.view.ViewStructure; import android.view.ViewConfiguration; import android.view.ViewDebug; import android.view.ViewGroup.LayoutParams; @@ -8715,8 +8715,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } @Override - public void onProvideAssistStructure(ViewAssistStructure structure) { - super.onProvideAssistStructure(structure); + public void onProvideStructure(ViewStructure structure) { + super.onProvideStructure(structure); final boolean isPassword = hasPasswordTransformationMethod(); if (!isPassword) { structure.setText(getText(), getSelectionStart(), getSelectionEnd()); diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index eaa6278..0b96d22 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2347,11 +2347,6 @@ be saved. --> <attr name="saveEnabled" format="boolean" /> - <!-- If true, no {@link android.view.ViewAssistStructure} data will be collected from - this view or any of its children. The default is false, allowing assist structure - to be reported by it. --> - <attr name="assistBlocked" format="boolean" /> - <!-- Specifies whether to filter touches when the view's window is obscured by another visible window. When set to true, the view will not receive touches whenever a toast, dialog or other window appears above the view's window. diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 297b302..e403a16 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2682,7 +2682,9 @@ <!-- NFC CardEmulation: dynamically load service resources --> <public type="attr" name="dynamicResources" /> - <public type="attr" name="assistBlocked" /> + <attr name="__reserved0" format="boolean" /> + <public type="attr" name="__reserved0" /> + <public type="attr" name="stylusButtonPressable" /> <public type="attr" name="supportsLaunchVoiceAssistFromKeyguard" /> <public type="attr" name="scrollIndicators" /> |