diff options
71 files changed, 903 insertions, 580 deletions
diff --git a/api/current.txt b/api/current.txt index 1bce2ce..1abcdb1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3920,6 +3920,46 @@ package android.app { field public java.lang.String serviceDetails; } + public final class AssistData implements android.os.Parcelable { + method public int describeContents(); + method public static android.app.AssistData getAssistData(android.os.Bundle); + method public void getWindowAt(int, android.app.AssistData.ViewNode); + method public int getWindowCount(); + method public void writeToParcel(android.os.Parcel, int); + field public static final java.lang.String ASSIST_KEY = "android:assist"; + field public static final android.os.Parcelable.Creator<android.app.AssistData> CREATOR; + } + + public static class AssistData.ViewNode { + ctor public AssistData.ViewNode(); + method public void getChildAt(int, android.app.AssistData.ViewNode); + method public int getChildCount(); + method public java.lang.String getClassName(); + method public java.lang.String getContentDescription(); + method public android.os.Bundle getExtras(); + method public int getHeight(); + method public java.lang.String getHint(); + method public int getLeft(); + method public int getScrollX(); + method public int getScrollY(); + method public java.lang.String getText(); + method public int getTextSelectionEnd(); + method public int getTextSelectionStart(); + method public int getTop(); + method public int getVisibility(); + method public int getWidth(); + method public boolean isAccessibilityFocused(); + method public boolean isActivated(); + method public boolean isCheckable(); + method public boolean isChecked(); + method public boolean isClickable(); + method public boolean isEnabled(); + method public boolean isFocusable(); + method public boolean isFocused(); + method public boolean isLongClickable(); + method public boolean isSelected(); + } + public class DatePickerDialog extends android.app.AlertDialog implements android.widget.DatePicker.OnDateChangedListener android.content.DialogInterface.OnClickListener { ctor public DatePickerDialog(android.content.Context, android.app.DatePickerDialog.OnDateSetListener, int, int, int); ctor public DatePickerDialog(android.content.Context, int, android.app.DatePickerDialog.OnDateSetListener, int, int, int); @@ -33923,6 +33963,7 @@ package android.view { method public android.view.View focusSearch(int); method public void forceLayout(); method public static int generateViewId(); + method public java.lang.CharSequence getAccessibilityClassName(); method public int getAccessibilityLiveRegion(); method public android.view.accessibility.AccessibilityNodeProvider getAccessibilityNodeProvider(); method public int getAccessibilityTraversalAfter(); @@ -34148,6 +34189,7 @@ package android.view { method protected void onMeasure(int, int); method protected void onOverScrolled(int, int, boolean, boolean); method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent); + method public void onProvideAssistData(android.view.ViewAssistData, android.os.Bundle); method protected void onRestoreInstanceState(android.os.Parcelable); method public void onRtlPropertiesChanged(int); method protected android.os.Parcelable onSaveInstanceState(); @@ -34550,6 +34592,17 @@ package android.view { method public static android.animation.Animator createCircularReveal(android.view.View, int, int, float, float); } + public abstract class ViewAssistData { + ctor public ViewAssistData(); + method public abstract java.lang.CharSequence getHint(); + method public abstract java.lang.CharSequence getText(); + method public abstract int getTextSelectionEnd(); + method public abstract int getTextSelectionStart(); + method public abstract void setHint(java.lang.CharSequence); + method public abstract void setText(java.lang.CharSequence); + method public abstract void setText(java.lang.CharSequence, int, int); + } + public class ViewConfiguration { ctor public deprecated ViewConfiguration(); method public static android.view.ViewConfiguration get(android.content.Context); diff --git a/api/system-current.txt b/api/system-current.txt index 15eca58..f74538f 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4010,6 +4010,46 @@ package android.app { field public java.lang.String serviceDetails; } + public final class AssistData implements android.os.Parcelable { + method public int describeContents(); + method public static android.app.AssistData getAssistData(android.os.Bundle); + method public void getWindowAt(int, android.app.AssistData.ViewNode); + method public int getWindowCount(); + method public void writeToParcel(android.os.Parcel, int); + field public static final java.lang.String ASSIST_KEY = "android:assist"; + field public static final android.os.Parcelable.Creator<android.app.AssistData> CREATOR; + } + + public static class AssistData.ViewNode { + ctor public AssistData.ViewNode(); + method public void getChildAt(int, android.app.AssistData.ViewNode); + method public int getChildCount(); + method public java.lang.String getClassName(); + method public java.lang.String getContentDescription(); + method public android.os.Bundle getExtras(); + method public int getHeight(); + method public java.lang.String getHint(); + method public int getLeft(); + method public int getScrollX(); + method public int getScrollY(); + method public java.lang.String getText(); + method public int getTextSelectionEnd(); + method public int getTextSelectionStart(); + method public int getTop(); + method public int getVisibility(); + method public int getWidth(); + method public boolean isAccessibilityFocused(); + method public boolean isActivated(); + method public boolean isCheckable(); + method public boolean isChecked(); + method public boolean isClickable(); + method public boolean isEnabled(); + method public boolean isFocusable(); + method public boolean isFocused(); + method public boolean isLongClickable(); + method public boolean isSelected(); + } + public class DatePickerDialog extends android.app.AlertDialog implements android.widget.DatePicker.OnDateChangedListener android.content.DialogInterface.OnClickListener { ctor public DatePickerDialog(android.content.Context, android.app.DatePickerDialog.OnDateSetListener, int, int, int); ctor public DatePickerDialog(android.content.Context, int, android.app.DatePickerDialog.OnDateSetListener, int, int, int); @@ -36076,6 +36116,7 @@ package android.view { method public android.view.View focusSearch(int); method public void forceLayout(); method public static int generateViewId(); + method public java.lang.CharSequence getAccessibilityClassName(); method public int getAccessibilityLiveRegion(); method public android.view.accessibility.AccessibilityNodeProvider getAccessibilityNodeProvider(); method public int getAccessibilityTraversalAfter(); @@ -36301,6 +36342,7 @@ package android.view { method protected void onMeasure(int, int); method protected void onOverScrolled(int, int, boolean, boolean); method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent); + method public void onProvideAssistData(android.view.ViewAssistData, android.os.Bundle); method protected void onRestoreInstanceState(android.os.Parcelable); method public void onRtlPropertiesChanged(int); method protected android.os.Parcelable onSaveInstanceState(); @@ -36703,6 +36745,17 @@ package android.view { method public static android.animation.Animator createCircularReveal(android.view.View, int, int, float, float); } + public abstract class ViewAssistData { + ctor public ViewAssistData(); + method public abstract java.lang.CharSequence getHint(); + method public abstract java.lang.CharSequence getText(); + method public abstract int getTextSelectionEnd(); + method public abstract int getTextSelectionStart(); + method public abstract void setHint(java.lang.CharSequence); + method public abstract void setText(java.lang.CharSequence); + method public abstract void setText(java.lang.CharSequence, int, int); + } + public class ViewConfiguration { ctor public deprecated ViewConfiguration(); method public static android.view.ViewConfiguration get(android.content.Context); diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index a09bca1..8b4b292 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -1534,13 +1534,17 @@ public class Activity extends ContextThemeWrapper * {@link Intent#ACTION_ASSIST} Intent with all of the context of the current * application. You can override this method to place into the bundle anything * you would like to appear in the {@link Intent#EXTRA_ASSIST_CONTEXT} part - * of the assist Intent. The default implementation does nothing. + * of the assist Intent. The default implementation automatically generates a + * {@link AssistData} from your activity and places it in to the Bundle; if you + * don't want your UI reported to the assistant, don't call this default + * implementation. * * <p>This function will be called after any global assist callbacks that had * been registered with {@link Application#registerOnProvideAssistDataListener * Application.registerOnProvideAssistDataListener}. */ public void onProvideAssistData(Bundle data) { + data.putParcelable(AssistData.ASSIST_KEY, new AssistData(this)); } /** diff --git a/core/java/android/app/AssistData.java b/core/java/android/app/AssistData.java new file mode 100644 index 0000000..8d3d348 --- /dev/null +++ b/core/java/android/app/AssistData.java @@ -0,0 +1,519 @@ +/* + * 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.app; + +import android.graphics.Rect; +import android.os.Bundle; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.Log; +import android.view.View; +import android.view.ViewAssistData; +import android.view.ViewGroup; +import android.view.ViewRootImpl; +import android.view.WindowManagerGlobal; +import android.widget.Checkable; + +import java.util.ArrayList; + +/** + * Assist data automatically created by the platform's implementation + * of {@link Activity#onProvideAssistData}. Retrieve it from the assist + * data with {@link #getAssistData(android.os.Bundle)}. + */ +final public class AssistData implements Parcelable { + static final String TAG = "AssistData"; + + /** + * Key name this data structure is stored in the Bundle generated by + * {@link Activity#onProvideAssistData}. + */ + public static final String ASSIST_KEY = "android:assist"; + + final ArrayList<ViewNodeImpl> mRootViews = new ArrayList<>(); + + ViewAssistDataImpl mTmpViewAssistDataImpl = new ViewAssistDataImpl(); + Bundle mTmpExtras = new Bundle(); + + final static class ViewAssistDataImpl extends ViewAssistData { + CharSequence mText; + int mTextSelectionStart = -1; + int mTextSelectionEnd = -1; + CharSequence mHint; + + @Override + public void setText(CharSequence text) { + mText = text; + mTextSelectionStart = mTextSelectionEnd = -1; + } + + @Override + public void setText(CharSequence text, int selectionStart, int selectionEnd) { + mText = text; + mTextSelectionStart = selectionStart; + mTextSelectionEnd = selectionEnd; + } + + @Override + public void setHint(CharSequence hint) { + mHint = hint; + } + + @Override + public CharSequence getText() { + return mText; + } + + @Override + public int getTextSelectionStart() { + return mTextSelectionStart; + } + + @Override + public int getTextSelectionEnd() { + return mTextSelectionEnd; + } + + @Override + public CharSequence getHint() { + return mHint; + } + } + + final static class ViewNodeTextImpl { + final String mText; + final int mTextSelectionStart; + final int mTextSelectionEnd; + final String mHint; + + ViewNodeTextImpl(ViewAssistDataImpl data) { + mText = data.mText != null ? data.mText.toString() : null; + mTextSelectionStart = data.mTextSelectionStart; + mTextSelectionEnd = data.mTextSelectionEnd; + mHint = data.mHint != null ? data.mHint.toString() : null; + } + + ViewNodeTextImpl(Parcel in) { + mText = in.readString(); + mTextSelectionStart = in.readInt(); + mTextSelectionEnd = in.readInt(); + mHint = in.readString(); + } + + void writeToParcel(Parcel out) { + out.writeString(mText); + out.writeInt(mTextSelectionStart); + out.writeInt(mTextSelectionEnd); + out.writeString(mHint); + } + } + + final static class ViewNodeImpl { + final int mX; + final int mY; + final int mScrollX; + final int mScrollY; + final int mWidth; + final int mHeight; + + static final int FLAGS_DISABLED = 0x00000001; + static final int FLAGS_VISIBILITY_MASK = View.VISIBLE|View.INVISIBLE|View.GONE; + static final int FLAGS_FOCUSABLE = 0x00000010; + static final int FLAGS_FOCUSED = 0x00000020; + static final int FLAGS_ACCESSIBILITY_FOCUSED = 0x04000000; + static final int FLAGS_SELECTED = 0x00000040; + static final int FLAGS_ACTIVATED = 0x40000000; + static final int FLAGS_CHECKABLE = 0x00000100; + static final int FLAGS_CHECKED = 0x00000200; + static final int FLAGS_CLICKABLE = 0x00004000; + static final int FLAGS_LONG_CLICKABLE = 0x00200000; + + final int mFlags; + + final String mClassName; + final String mContentDescription; + + final ViewNodeTextImpl mText; + final Bundle mExtras; + + final ViewNodeImpl[] mChildren; + + ViewNodeImpl(AssistData assistData, View view, int left, int top, + CharSequence contentDescription) { + mX = left; + mY = top; + mScrollX = view.getScrollX(); + mScrollY = view.getScrollY(); + mWidth = view.getWidth(); + mHeight = view.getHeight(); + int flags = view.getVisibility(); + if (!view.isEnabled()) { + flags |= FLAGS_DISABLED; + } + if (!view.isClickable()) { + flags |= FLAGS_CLICKABLE; + } + if (!view.isFocusable()) { + flags |= FLAGS_FOCUSABLE; + } + if (!view.isFocused()) { + flags |= FLAGS_FOCUSED; + } + if (!view.isAccessibilityFocused()) { + flags |= FLAGS_ACCESSIBILITY_FOCUSED; + } + if (!view.isSelected()) { + flags |= FLAGS_SELECTED; + } + if (!view.isActivated()) { + flags |= FLAGS_ACTIVATED; + } + if (!view.isLongClickable()) { + flags |= FLAGS_LONG_CLICKABLE; + } + if (view instanceof Checkable) { + flags |= FLAGS_CHECKABLE; + if (((Checkable)view).isChecked()) { + flags |= FLAGS_CHECKED; + } + } + mFlags = flags; + mClassName = view.getAccessibilityClassName().toString(); + mContentDescription = contentDescription != null ? contentDescription.toString() : null; + final ViewAssistDataImpl viewData = assistData.mTmpViewAssistDataImpl; + final Bundle extras = assistData.mTmpExtras; + view.onProvideAssistData(viewData, extras); + if (viewData.mText != null || viewData.mHint != null) { + mText = new ViewNodeTextImpl(viewData); + assistData.mTmpViewAssistDataImpl = new ViewAssistDataImpl(); + } else { + mText = null; + } + if (!extras.isEmpty()) { + mExtras = extras; + assistData.mTmpExtras = new Bundle(); + } else { + mExtras = null; + } + if (view instanceof ViewGroup) { + ViewGroup vg = (ViewGroup)view; + final int NCHILDREN = vg.getChildCount(); + if (NCHILDREN > 0) { + mChildren = new ViewNodeImpl[NCHILDREN]; + for (int i=0; i<NCHILDREN; i++) { + mChildren[i] = new ViewNodeImpl(assistData, vg.getChildAt(i)); + } + } else { + mChildren = null; + } + } else { + mChildren = null; + } + } + + ViewNodeImpl(AssistData assistData, View view) { + this(assistData, view, view.getLeft(), view.getTop(), view.getContentDescription()); + } + + ViewNodeImpl(Parcel in) { + mX = in.readInt(); + mY = in.readInt(); + mScrollX = in.readInt(); + mScrollY = in.readInt(); + mWidth = in.readInt(); + mHeight = in.readInt(); + mFlags = in.readInt(); + mClassName = in.readString(); + mContentDescription = in.readString(); + if (in.readInt() != 0) { + mText = new ViewNodeTextImpl(in); + } else { + mText = null; + } + mExtras = in.readBundle(); + final int NCHILDREN = in.readInt(); + if (NCHILDREN > 0) { + mChildren = new ViewNodeImpl[NCHILDREN]; + for (int i=0; i<NCHILDREN; i++) { + mChildren[i] = new ViewNodeImpl(in); + } + } else { + mChildren = null; + } + } + + void writeToParcel(Parcel out) { + out.writeInt(mX); + out.writeInt(mY); + out.writeInt(mScrollX); + out.writeInt(mScrollY); + out.writeInt(mWidth); + out.writeInt(mHeight); + out.writeInt(mFlags); + out.writeString(mClassName); + out.writeString(mContentDescription); + if (mText != null) { + out.writeInt(1); + mText.writeToParcel(out); + } else { + out.writeInt(0); + } + out.writeBundle(mExtras); + if (mChildren != null) { + final int NCHILDREN = mChildren.length; + out.writeInt(NCHILDREN); + for (int i=0; i<NCHILDREN; i++) { + mChildren[i].writeToParcel(out); + } + } else { + out.writeInt(0); + } + } + } + + /** + * Provides access to information about a single view in the assist data. + */ + static public class ViewNode { + ViewNodeImpl mImpl; + + public ViewNode() { + } + + public int getLeft() { + return mImpl.mX; + } + + public int getTop() { + return mImpl.mY; + } + + public int getScrollX() { + return mImpl.mScrollX; + } + + public int getScrollY() { + return mImpl.mScrollY; + } + + public int getWidth() { + return mImpl.mWidth; + } + + public int getHeight() { + return mImpl.mHeight; + } + + public int getVisibility() { + return mImpl.mFlags&ViewNodeImpl.FLAGS_VISIBILITY_MASK; + } + + public boolean isEnabled() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_DISABLED) == 0; + } + + public boolean isClickable() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_CLICKABLE) != 0; + } + + public boolean isFocusable() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_FOCUSABLE) != 0; + } + + public boolean isFocused() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_FOCUSED) != 0; + } + + public boolean isAccessibilityFocused() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_ACCESSIBILITY_FOCUSED) != 0; + } + + public boolean isCheckable() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_CHECKABLE) != 0; + } + + public boolean isChecked() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_CHECKED) != 0; + } + + public boolean isSelected() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_SELECTED) != 0; + } + + public boolean isActivated() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_ACTIVATED) != 0; + } + + public boolean isLongClickable() { + return (mImpl.mFlags&ViewNodeImpl.FLAGS_LONG_CLICKABLE) != 0; + } + + public String getClassName() { + return mImpl.mClassName; + } + + public String getContentDescription() { + return mImpl.mContentDescription; + } + + public String getText() { + return mImpl.mText != null ? mImpl.mText.mText : null; + } + + public int getTextSelectionStart() { + return mImpl.mText != null ? mImpl.mText.mTextSelectionStart : -1; + } + + public int getTextSelectionEnd() { + return mImpl.mText != null ? mImpl.mText.mTextSelectionEnd : -1; + } + + public String getHint() { + return mImpl.mText != null ? mImpl.mText.mHint : null; + } + + public Bundle getExtras() { + return mImpl.mExtras; + } + + public int getChildCount() { + return mImpl.mChildren != null ? mImpl.mChildren.length : 0; + } + + public void getChildAt(int index, ViewNode outNode) { + outNode.mImpl = mImpl.mChildren[index]; + } + } + + AssistData(Activity activity) { + ArrayList<ViewRootImpl> views = WindowManagerGlobal.getInstance().getRootViews( + activity.getActivityToken()); + for (int i=0; i<views.size(); i++) { + ViewRootImpl root = views.get(i); + View view = root.getView(); + Rect rect = new Rect(); + view.getBoundsOnScreen(rect); + CharSequence title = root.getTitle(); + mRootViews.add(new ViewNodeImpl(this, view, rect.left, rect.top, + title != null ? title : view.getContentDescription())); + } + } + + AssistData(Parcel in) { + final int N = in.readInt(); + for (int i=0; i<N; i++) { + mRootViews.add(new ViewNodeImpl(in)); + } + //dump(); + } + + void dump() { + ViewNode node = new ViewNode(); + final int N = getWindowCount(); + for (int i=0; i<N; i++) { + Log.i(TAG, "Window #" + i + ":"); + getWindowAt(i, node); + dump(" ", node); + } + } + + void dump(String prefix, ViewNode node) { + Log.i(TAG, prefix + "View [" + node.getLeft() + "," + node.getTop() + + " " + node.getWidth() + "x" + node.getHeight() + "]" + " " + node.getClassName()); + int scrollX = node.getScrollX(); + int scrollY = node.getScrollY(); + if (scrollX != 0 || scrollY != 0) { + Log.i(TAG, prefix + " Scroll: " + scrollX + "," + scrollY); + } + String contentDescription = node.getContentDescription(); + if (contentDescription != null) { + Log.i(TAG, prefix + " Content description: " + contentDescription); + } + String text = node.getText(); + if (text != null) { + Log.i(TAG, prefix + " Text (sel " + node.getTextSelectionStart() + "-" + + node.getTextSelectionEnd() + "): " + text); + } + String hint = node.getHint(); + if (hint != null) { + Log.i(TAG, prefix + " Hint: " + hint); + } + Bundle extras = node.getExtras(); + if (extras != null) { + Log.i(TAG, prefix + " Extras: " + extras); + } + final int NCHILDREN = node.getChildCount(); + if (NCHILDREN > 0) { + Log.i(TAG, prefix + " Children:"); + String cprefix = prefix + " "; + ViewNode cnode = new ViewNode(); + for (int i=0; i<NCHILDREN; i++) { + node.getChildAt(i, cnode); + dump(cprefix, cnode); + } + } + } + + /** + * Retrieve the framework-generated AssistData that is stored within + * the Bundle filled in by {@link Activity#onProvideAssistData}. + */ + public static AssistData getAssistData(Bundle assistBundle) { + return assistBundle.getParcelable(ASSIST_KEY); + } + + /** + * Return the number of window contents that have been collected in this assist data. + */ + public int getWindowCount() { + return mRootViews.size(); + } + + /** + * Return the root view for one of the windows in the assist data. + * @param index Which window to retrieve, may be 0 to {@link #getWindowCount()}-1. + * @param outNode Node in which to place the window's root view. + */ + public void getWindowAt(int index, ViewNode outNode) { + outNode.mImpl = mRootViews.get(index); + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel out, int flags) { + int start = out.dataPosition(); + final int N = mRootViews.size(); + out.writeInt(N); + for (int i=0; i<N; i++) { + mRootViews.get(i).writeToParcel(out); + } + Log.i(TAG, "Flattened assist data: " + (out.dataPosition() - start) + " bytes"); + } + + public static final Parcelable.Creator<AssistData> CREATOR + = new Parcelable.Creator<AssistData>() { + public AssistData createFromParcel(Parcel in) { + return new AssistData(in); + } + + public AssistData[] newArray(int size) { + return new AssistData[size]; + } + }; +} diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index bac087e..7fb61e2 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5430,7 +5430,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { event.setSource(this); - event.setClassName(View.class.getName()); + event.setClassName(getAccessibilityClassName()); event.setPackageName(getContext().getPackageName()); event.setEnabled(isEnabled()); event.setContentDescription(mContentDescription); @@ -5600,6 +5600,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** + * Return the class name of this object to be used for accessibility purposes. + * Subclasses should only override this if they are implementing something that + * should be seen as a completely new class of view when used by accessibility, + * unrelated to the class it is deriving from. This is used to fill in + * {@link AccessibilityNodeInfo#setClassName AccessibilityNodeInfo.setClassName}. + */ + public CharSequence getAccessibilityClassName() { + return View.class.getName(); + } + + /** + * Called when assist data is being retrieved from a view as part of + * {@link android.app.Activity#onProvideAssistData Activity.onProvideAssistData}. + * @param data + * @param extras + */ + public void onProvideAssistData(ViewAssistData data, Bundle extras) { + } + + /** * @see #onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo) * * Note: Called from the default {@link AccessibilityDelegate}. @@ -5681,7 +5701,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, info.setVisibleToUser(isVisibleToUser()); info.setPackageName(mContext.getPackageName()); - info.setClassName(View.class.getName()); + info.setClassName(getAccessibilityClassName()); info.setContentDescription(getContentDescription()); info.setEnabled(isEnabled()); diff --git a/core/java/android/view/ViewAssistData.java b/core/java/android/view/ViewAssistData.java new file mode 100644 index 0000000..74436ea --- /dev/null +++ b/core/java/android/view/ViewAssistData.java @@ -0,0 +1,32 @@ +/* + * 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; + +/** + * Container for storing data generated by {@link View#onProvideAssistData + * View.onProvideAssistData}. + */ +public abstract class ViewAssistData { + public abstract void setText(CharSequence text); + public abstract void setText(CharSequence text, int selectionStart, int selectionEnd); + public abstract void setHint(CharSequence hint); + + public abstract CharSequence getText(); + public abstract int getTextSelectionStart(); + public abstract int getTextSelectionEnd(); + public abstract CharSequence getHint(); +} diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index f78c018..570cb72 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -651,6 +651,10 @@ public final class ViewRootImpl implements ViewParent, return (mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE) != 0; } + public CharSequence getTitle() { + return mWindowAttributes.getTitle(); + } + void destroyHardwareResources() { if (mAttachInfo.mHardwareRenderer != null) { mAttachInfo.mHardwareRenderer.destroyHardwareResources(mView); diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java index ed17e3f..279627a 100644 --- a/core/java/android/view/WindowManagerGlobal.java +++ b/core/java/android/view/WindowManagerGlobal.java @@ -190,6 +190,39 @@ public final class WindowManagerGlobal { } } + public ArrayList<ViewRootImpl> getRootViews(IBinder token) { + ArrayList<ViewRootImpl> views = new ArrayList<>(); + synchronized (mLock) { + final int numRoots = mRoots.size(); + for (int i = 0; i < numRoots; ++i) { + WindowManager.LayoutParams params = mParams.get(i); + if (params.token == null) { + continue; + } + if (params.token != token) { + boolean isChild = false; + if (params.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW + && params.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { + for (int j = 0 ; j < numRoots; ++j) { + View viewj = mViews.get(j); + WindowManager.LayoutParams paramsj = mParams.get(j); + if (params.token == viewj.getWindowToken() + && paramsj.token == token) { + isChild = true; + break; + } + } + } + if (!isChild) { + continue; + } + } + views.add(mRoots.get(i)); + } + } + return views; + } + public View getRootView(String name) { synchronized (mLock) { for (int i = mRoots.size() - 1; i >= 0; --i) { diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 4a7cc6d..01a506c 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2387,11 +2387,14 @@ public class WebView extends AbsoluteLayout return mProvider.getViewDelegate().shouldDelayChildPressedState(); } + public CharSequence getAccessibilityClassName() { + return WebView.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(WebView.class.getName()); mProvider.getViewDelegate().onInitializeAccessibilityNodeInfo(info); } @@ -2399,7 +2402,6 @@ public class WebView extends AbsoluteLayout @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(WebView.class.getName()); mProvider.getViewDelegate().onInitializeAccessibilityEvent(event); } diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 897749f..e87a117 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -1492,18 +1492,15 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te super.sendAccessibilityEventInternal(eventType); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(AbsListView.class.getName()); + public CharSequence getAccessibilityClassName() { + return AbsListView.class.getName(); } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(AbsListView.class.getName()); if (isEnabled()) { if (canScrollUp()) { info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index 1f7be63..4f6ea23 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -715,18 +715,15 @@ public abstract class AbsSeekBar extends ProgressBar { return super.onKeyDown(keyCode, event); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(AbsSeekBar.class.getName()); + public CharSequence getAccessibilityClassName() { + return AbsSeekBar.class.getName(); } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(AbsSeekBar.class.getName()); if (isEnabled()) { final int progress = getProgress(); diff --git a/core/java/android/widget/AbsSpinner.java b/core/java/android/widget/AbsSpinner.java index 5d8d48f..e432747 100644 --- a/core/java/android/widget/AbsSpinner.java +++ b/core/java/android/widget/AbsSpinner.java @@ -470,17 +470,8 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(AbsSpinner.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(AbsSpinner.class.getName()); + public CharSequence getAccessibilityClassName() { + return AbsSpinner.class.getName(); } } diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java index 428b6ce..9b977fa 100644 --- a/core/java/android/widget/AdapterView.java +++ b/core/java/android/widget/AdapterView.java @@ -955,11 +955,15 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { return false; } + @Override + public CharSequence getAccessibilityClassName() { + return AdapterView.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(AdapterView.class.getName()); info.setScrollable(isScrollableForAccessibility()); View selectedView = getSelectedView(); if (selectedView != null) { @@ -971,7 +975,6 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(AdapterView.class.getName()); event.setScrollable(isScrollableForAccessibility()); View selectedView = getSelectedView(); if (selectedView != null) { diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java index 96eb0e2..a242175 100644 --- a/core/java/android/widget/AdapterViewAnimator.java +++ b/core/java/android/widget/AdapterViewAnimator.java @@ -1084,17 +1084,8 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter> public void fyiWillBeAdvancedByHostKThx() { } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(AdapterViewAnimator.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(AdapterViewAnimator.class.getName()); + public CharSequence getAccessibilityClassName() { + return AdapterViewAnimator.class.getName(); } } diff --git a/core/java/android/widget/AdapterViewFlipper.java b/core/java/android/widget/AdapterViewFlipper.java index a7ba617..01b6530 100644 --- a/core/java/android/widget/AdapterViewFlipper.java +++ b/core/java/android/widget/AdapterViewFlipper.java @@ -304,17 +304,8 @@ public class AdapterViewFlipper extends AdapterViewAnimator { updateRunning(false); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(AdapterViewFlipper.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(AdapterViewFlipper.class.getName()); + public CharSequence getAccessibilityClassName() { + return AdapterViewFlipper.class.getName(); } } diff --git a/core/java/android/widget/Button.java b/core/java/android/widget/Button.java index 90d77f9..9b0d0dd 100644 --- a/core/java/android/widget/Button.java +++ b/core/java/android/widget/Button.java @@ -111,17 +111,8 @@ public class Button extends TextView { super(context, attrs, defStyleAttr, defStyleRes); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(Button.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(Button.class.getName()); + public CharSequence getAccessibilityClassName() { + return Button.class.getName(); } } diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java index d58da8f..5e43916 100644 --- a/core/java/android/widget/CalendarView.java +++ b/core/java/android/widget/CalendarView.java @@ -501,16 +501,9 @@ public class CalendarView extends FrameLayout { mDelegate.onConfigurationChanged(newConfig); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - event.setClassName(CalendarView.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - info.setClassName(CalendarView.class.getName()); + public CharSequence getAccessibilityClassName() { + return CalendarView.class.getName(); } /** diff --git a/core/java/android/widget/CheckBox.java b/core/java/android/widget/CheckBox.java index b1fb338..5a7d585 100644 --- a/core/java/android/widget/CheckBox.java +++ b/core/java/android/widget/CheckBox.java @@ -72,17 +72,8 @@ public class CheckBox extends CompoundButton { super(context, attrs, defStyleAttr, defStyleRes); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(CheckBox.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(CheckBox.class.getName()); + public CharSequence getAccessibilityClassName() { + return CheckBox.class.getName(); } } diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java index 477862b..344d00a 100644 --- a/core/java/android/widget/CheckedTextView.java +++ b/core/java/android/widget/CheckedTextView.java @@ -435,11 +435,15 @@ public class CheckedTextView extends TextView implements Checkable { } } + @Override + public CharSequence getAccessibilityClassName() { + return CheckedTextView.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(CheckedTextView.class.getName()); event.setChecked(mChecked); } @@ -447,7 +451,6 @@ public class CheckedTextView extends TextView implements Checkable { @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(CheckedTextView.class.getName()); info.setCheckable(true); info.setChecked(mChecked); } diff --git a/core/java/android/widget/Chronometer.java b/core/java/android/widget/Chronometer.java index 05fc6a1..019d475 100644 --- a/core/java/android/widget/Chronometer.java +++ b/core/java/android/widget/Chronometer.java @@ -281,17 +281,8 @@ public class Chronometer extends TextView { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(Chronometer.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(Chronometer.class.getName()); + public CharSequence getAccessibilityClassName() { + return Chronometer.class.getName(); } } diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index 41a3915..fede493 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -324,11 +324,15 @@ public abstract class CompoundButton extends Button implements Checkable { } } + @Override + public CharSequence getAccessibilityClassName() { + return CompoundButton.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(CompoundButton.class.getName()); event.setChecked(mChecked); } @@ -336,7 +340,6 @@ public abstract class CompoundButton extends Button implements Checkable { @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(CompoundButton.class.getName()); info.setCheckable(true); info.setChecked(mChecked); } diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 0f0cd2e..7c6055a 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -296,18 +296,9 @@ public class DatePicker extends FrameLayout { mDelegate.onPopulateAccessibilityEvent(event); } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - mDelegate.onInitializeAccessibilityEvent(event); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - mDelegate.onInitializeAccessibilityNodeInfo(info); + public CharSequence getAccessibilityClassName() { + return DatePicker.class.getName(); } @Override @@ -476,8 +467,6 @@ public class DatePicker extends FrameLayout { boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event); void onPopulateAccessibilityEvent(AccessibilityEvent event); - void onInitializeAccessibilityEvent(AccessibilityEvent event); - void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info); } /** @@ -892,16 +881,6 @@ public class DatePicker extends FrameLayout { event.getText().add(selectedDateUtterance); } - @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - event.setClassName(DatePicker.class.getName()); - } - - @Override - public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { - info.setClassName(DatePicker.class.getName()); - } - /** * Sets the current locale. * diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java index a3b834e..85b4d30 100644 --- a/core/java/android/widget/DatePickerCalendarDelegate.java +++ b/core/java/android/widget/DatePickerCalendarDelegate.java @@ -584,14 +584,8 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i event.getText().add(mCurrentDate.getTime().toString()); } - @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - event.setClassName(DatePicker.class.getName()); - } - - @Override - public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { - info.setClassName(DatePicker.class.getName()); + public CharSequence getAccessibilityClassName() { + return DatePicker.class.getName(); } @Override diff --git a/core/java/android/widget/DigitalClock.java b/core/java/android/widget/DigitalClock.java index 372bdb3..b936a5b 100644 --- a/core/java/android/widget/DigitalClock.java +++ b/core/java/android/widget/DigitalClock.java @@ -115,19 +115,9 @@ public class DigitalClock extends TextView { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); + public CharSequence getAccessibilityClassName() { //noinspection deprecation - event.setClassName(DigitalClock.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - //noinspection deprecation - info.setClassName(DigitalClock.class.getName()); + return DigitalClock.class.getName(); } } diff --git a/core/java/android/widget/EditText.java b/core/java/android/widget/EditText.java index f54beb5..24cc2d8 100644 --- a/core/java/android/widget/EditText.java +++ b/core/java/android/widget/EditText.java @@ -122,18 +122,9 @@ public class EditText extends TextView { super.setEllipsize(ellipsis); } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(EditText.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(EditText.class.getName()); + public CharSequence getAccessibilityClassName() { + return EditText.class.getName(); } /** @hide */ diff --git a/core/java/android/widget/ExpandableListView.java b/core/java/android/widget/ExpandableListView.java index 675dc9b..323ddb6 100644 --- a/core/java/android/widget/ExpandableListView.java +++ b/core/java/android/widget/ExpandableListView.java @@ -1341,17 +1341,8 @@ public class ExpandableListView extends ListView { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ExpandableListView.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ExpandableListView.class.getName()); + public CharSequence getAccessibilityClassName() { + return ExpandableListView.class.getName(); } } diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index b5782fc..57bbc42 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -708,19 +708,9 @@ public class FrameLayout extends ViewGroup { return new LayoutParams(p); } - - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(FrameLayout.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(FrameLayout.class.getName()); + public CharSequence getAccessibilityClassName() { + return FrameLayout.class.getName(); } /** diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java index 3c428b0..ac19e6d 100644 --- a/core/java/android/widget/Gallery.java +++ b/core/java/android/widget/Gallery.java @@ -1373,18 +1373,15 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(Gallery.class.getName()); + public CharSequence getAccessibilityClassName() { + return Gallery.class.getName(); } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(Gallery.class.getName()); info.setScrollable(mItemCount > 1); if (isEnabled()) { if (mItemCount > 0 && mSelectedPosition < mItemCount - 1) { diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index cc925eb..41ddc98 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -1190,18 +1190,9 @@ public class GridLayout extends ViewGroup { } } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(GridLayout.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(GridLayout.class.getName()); + public CharSequence getAccessibilityClassName() { + return GridLayout.class.getName(); } // Inner classes diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index f7ce57b..8b2217c 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -2341,18 +2341,15 @@ public class GridView extends AbsListView { return result; } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(GridView.class.getName()); + public CharSequence getAccessibilityClassName() { + return GridView.class.getName(); } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(GridView.class.getName()); final int columnsCount = getNumColumns(); final int rowsCount = getCount() / columnsCount; diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java index f1fa1b6..b37495f 100644 --- a/core/java/android/widget/HorizontalScrollView.java +++ b/core/java/android/widget/HorizontalScrollView.java @@ -795,11 +795,15 @@ public class HorizontalScrollView extends FrameLayout { return false; } + @Override + public CharSequence getAccessibilityClassName() { + return HorizontalScrollView.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(HorizontalScrollView.class.getName()); final int scrollRange = getScrollRange(); if (scrollRange > 0) { info.setScrollable(true); @@ -816,7 +820,6 @@ public class HorizontalScrollView extends FrameLayout { @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(HorizontalScrollView.class.getName()); event.setScrollable(getScrollRange() > 0); event.setScrollX(mScrollX); event.setScrollY(mScrollY); diff --git a/core/java/android/widget/ImageButton.java b/core/java/android/widget/ImageButton.java index 3b6825d..22f9c10 100644 --- a/core/java/android/widget/ImageButton.java +++ b/core/java/android/widget/ImageButton.java @@ -92,17 +92,8 @@ public class ImageButton extends ImageView { return false; } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ImageButton.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ImageButton.class.getName()); + public CharSequence getAccessibilityClassName() { + return ImageButton.class.getName(); } } diff --git a/core/java/android/widget/ImageSwitcher.java b/core/java/android/widget/ImageSwitcher.java index 0910eb0..80e908a 100644 --- a/core/java/android/widget/ImageSwitcher.java +++ b/core/java/android/widget/ImageSwitcher.java @@ -56,17 +56,8 @@ public class ImageSwitcher extends ViewSwitcher showNext(); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ImageSwitcher.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ImageSwitcher.class.getName()); + public CharSequence getAccessibilityClassName() { + return ImageSwitcher.class.getName(); } } diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index fbad314..757038c 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -1419,17 +1419,8 @@ public class ImageView extends View { } } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ImageView.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ImageView.class.getName()); + public CharSequence getAccessibilityClassName() { + return ImageView.class.getName(); } } diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index 28e50c4..c0f63d2 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -1806,18 +1806,9 @@ public class LinearLayout extends ViewGroup { return p instanceof LinearLayout.LayoutParams; } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(LinearLayout.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(LinearLayout.class.getName()); + public CharSequence getAccessibilityClassName() { + return LinearLayout.class.getName(); } /** diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index df0d1fd..0aaef6d 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -3878,18 +3878,15 @@ public class ListView extends AbsListView { return false; } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ListView.class.getName()); + public CharSequence getAccessibilityClassName() { + return ListView.class.getName(); } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ListView.class.getName()); final int rowsCount = getCount(); final int selectionMode = getSelectionModeForAccessibility(); diff --git a/core/java/android/widget/MediaController.java b/core/java/android/widget/MediaController.java index 4cafe72..380b328 100644 --- a/core/java/android/widget/MediaController.java +++ b/core/java/android/widget/MediaController.java @@ -625,18 +625,9 @@ public class MediaController extends FrameLayout { super.setEnabled(enabled); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(MediaController.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(MediaController.class.getName()); + public CharSequence getAccessibilityClassName() { + return MediaController.class.getName(); } private View.OnClickListener mRewListener = new View.OnClickListener() { diff --git a/core/java/android/widget/MultiAutoCompleteTextView.java b/core/java/android/widget/MultiAutoCompleteTextView.java index 6954eea..c10e581 100644 --- a/core/java/android/widget/MultiAutoCompleteTextView.java +++ b/core/java/android/widget/MultiAutoCompleteTextView.java @@ -202,18 +202,9 @@ public class MultiAutoCompleteTextView extends AutoCompleteTextView { editable.replace(start, end, mTokenizer.terminateToken(text)); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(MultiAutoCompleteTextView.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(MultiAutoCompleteTextView.class.getName()); + public CharSequence getAccessibilityClassName() { + return MultiAutoCompleteTextView.class.getName(); } public static interface Tokenizer { diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index d32cb10..9c3296b 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -1825,22 +1825,19 @@ public class ProgressBar extends View { mAttached = false; } + @Override + public CharSequence getAccessibilityClassName() { + return ProgressBar.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ProgressBar.class.getName()); event.setItemCount(mMax); event.setCurrentItemIndex(mProgress); } - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ProgressBar.class.getName()); - } - /** * Schedule a command for sending an accessibility event. * </br> diff --git a/core/java/android/widget/QuickContactBadge.java b/core/java/android/widget/QuickContactBadge.java index d0e8081..3068de9 100644 --- a/core/java/android/widget/QuickContactBadge.java +++ b/core/java/android/widget/QuickContactBadge.java @@ -304,18 +304,9 @@ public class QuickContactBadge extends ImageView implements OnClickListener { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(QuickContactBadge.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(QuickContactBadge.class.getName()); + public CharSequence getAccessibilityClassName() { + return QuickContactBadge.class.getName(); } /** diff --git a/core/java/android/widget/RadioButton.java b/core/java/android/widget/RadioButton.java index 82280b4..aebc1b6 100644 --- a/core/java/android/widget/RadioButton.java +++ b/core/java/android/widget/RadioButton.java @@ -79,17 +79,8 @@ public class RadioButton extends CompoundButton { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(RadioButton.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(RadioButton.class.getName()); + public CharSequence getAccessibilityClassName() { + return RadioButton.class.getName(); } } diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java index c0f60eb..f04bb3d 100644 --- a/core/java/android/widget/RadioGroup.java +++ b/core/java/android/widget/RadioGroup.java @@ -240,18 +240,9 @@ public class RadioGroup extends LinearLayout { return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(RadioGroup.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(RadioGroup.class.getName()); + public CharSequence getAccessibilityClassName() { + return RadioGroup.class.getName(); } /** diff --git a/core/java/android/widget/RatingBar.java b/core/java/android/widget/RatingBar.java index 2d0649d..4268961 100644 --- a/core/java/android/widget/RatingBar.java +++ b/core/java/android/widget/RatingBar.java @@ -330,18 +330,9 @@ public class RatingBar extends AbsSeekBar { super.setMax(max); } - - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(RatingBar.class.getName()); - } - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(RatingBar.class.getName()); + public CharSequence getAccessibilityClassName() { + return RatingBar.class.getName(); } } diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index 71f4da0..89b1d54 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -1103,18 +1103,9 @@ public class RelativeLayout extends ViewGroup { return false; } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(RelativeLayout.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(RelativeLayout.class.getName()); + public CharSequence getAccessibilityClassName() { + return RelativeLayout.class.getName(); } /** diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 1098419..b95c27d 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -839,11 +839,15 @@ public class ScrollView extends FrameLayout { return false; } + @Override + public CharSequence getAccessibilityClassName() { + return ScrollView.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ScrollView.class.getName()); if (isEnabled()) { final int scrollRange = getScrollRange(); if (scrollRange > 0) { @@ -862,7 +866,6 @@ public class ScrollView extends FrameLayout { @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ScrollView.class.getName()); final boolean scrollable = getScrollRange() > 0; event.setScrollable(scrollable); event.setScrollX(mScrollX); diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index a1f361a..8846421 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -1325,18 +1325,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { setIconified(false); } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(SearchView.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(SearchView.class.getName()); + public CharSequence getAccessibilityClassName() { + return SearchView.class.getName(); } private void adjustDropDownSizeAndPosition() { diff --git a/core/java/android/widget/SeekBar.java b/core/java/android/widget/SeekBar.java index aa5c055..e97bdf2 100644 --- a/core/java/android/widget/SeekBar.java +++ b/core/java/android/widget/SeekBar.java @@ -124,17 +124,8 @@ public class SeekBar extends AbsSeekBar { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(SeekBar.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(SeekBar.class.getName()); + public CharSequence getAccessibilityClassName() { + return SeekBar.class.getName(); } } diff --git a/core/java/android/widget/SlidingDrawer.java b/core/java/android/widget/SlidingDrawer.java index e3f4a10..272f4b0 100644 --- a/core/java/android/widget/SlidingDrawer.java +++ b/core/java/android/widget/SlidingDrawer.java @@ -837,18 +837,9 @@ public class SlidingDrawer extends ViewGroup { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(SlidingDrawer.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(SlidingDrawer.class.getName()); + public CharSequence getAccessibilityClassName() { + return SlidingDrawer.class.getName(); } private void closeDrawer() { diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index a6e0e6d..6ee2b4c 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -765,18 +765,15 @@ public class Spinner extends AbsSpinner implements OnClickListener { dialog.dismiss(); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(Spinner.class.getName()); + public CharSequence getAccessibilityClassName() { + return Spinner.class.getName(); } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(Spinner.class.getName()); if (mAdapter != null) { info.setCanOpenPopup(true); diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index 2aa1c09..803ba4b 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -1224,18 +1224,15 @@ public class StackView extends AdapterViewAnimator { measureChildren(); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(StackView.class.getName()); + public CharSequence getAccessibilityClassName() { + return StackView.class.getName(); } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(StackView.class.getName()); info.setScrollable(getChildCount() > 1); if (isEnabled()) { if (getDisplayedChild() < getChildCount() - 1) { diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index a282cf5..b959ddc 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -30,6 +30,7 @@ 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; @@ -43,6 +44,7 @@ import android.view.Gravity; import android.view.MotionEvent; import android.view.SoundEffectConstants; import android.view.VelocityTracker; +import android.view.ViewAssistData; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -1353,18 +1355,31 @@ public class Switch extends CompoundButton { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(Switch.class.getName()); + public CharSequence getAccessibilityClassName() { + return Switch.class.getName(); + } + + @Override + public void onProvideAssistData(ViewAssistData data, Bundle extras) { + super.onProvideAssistData(data, extras); + CharSequence switchText = isChecked() ? mTextOn : mTextOff; + if (!TextUtils.isEmpty(switchText)) { + CharSequence oldText = data.getText(); + if (TextUtils.isEmpty(oldText)) { + data.setText(switchText); + } else { + StringBuilder newText = new StringBuilder(); + newText.append(oldText).append(' ').append(switchText); + data.setText(newText); + } + } } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(Switch.class.getName()); CharSequence switchText = isChecked() ? mTextOn : mTextOff; if (!TextUtils.isEmpty(switchText)) { CharSequence oldText = info.getText(); diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java index 3c3389a..bf35cf9 100644 --- a/core/java/android/widget/TabHost.java +++ b/core/java/android/widget/TabHost.java @@ -384,18 +384,9 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); } } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(TabHost.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(TabHost.class.getName()); + public CharSequence getAccessibilityClassName() { + return TabHost.class.getName(); } public void setCurrentTab(int index) { diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java index bddee91..88ecb13 100644 --- a/core/java/android/widget/TabWidget.java +++ b/core/java/android/widget/TabWidget.java @@ -415,11 +415,15 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { return false; } + @Override + public CharSequence getAccessibilityClassName() { + return TabWidget.class.getName(); + } + /** @hide */ @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(TabWidget.class.getName()); event.setItemCount(getTabCount()); event.setCurrentItemIndex(mSelectedTab); } @@ -436,13 +440,6 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { super.sendAccessibilityEventUncheckedInternal(event); } - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(TabWidget.class.getName()); - } - /** * Sets the current tab and focuses the UI on it. * This method makes sure that the focused tab matches the selected diff --git a/core/java/android/widget/TableLayout.java b/core/java/android/widget/TableLayout.java index a6b78a4..c825d17 100644 --- a/core/java/android/widget/TableLayout.java +++ b/core/java/android/widget/TableLayout.java @@ -666,18 +666,9 @@ public class TableLayout extends LinearLayout { return new LayoutParams(p); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(TableLayout.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(TableLayout.class.getName()); + public CharSequence getAccessibilityClassName() { + return TableLayout.class.getName(); } /** diff --git a/core/java/android/widget/TableRow.java b/core/java/android/widget/TableRow.java index c29296a..72fce3f 100644 --- a/core/java/android/widget/TableRow.java +++ b/core/java/android/widget/TableRow.java @@ -379,18 +379,9 @@ public class TableRow extends LinearLayout { return new LayoutParams(p); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(TableRow.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(TableRow.class.getName()); + public CharSequence getAccessibilityClassName() { + return TableRow.class.getName(); } /** diff --git a/core/java/android/widget/TextSwitcher.java b/core/java/android/widget/TextSwitcher.java index 7c883ba..22822b1 100644 --- a/core/java/android/widget/TextSwitcher.java +++ b/core/java/android/widget/TextSwitcher.java @@ -91,17 +91,8 @@ public class TextSwitcher extends ViewSwitcher { ((TextView)getCurrentView()).setText(text); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(TextSwitcher.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(TextSwitcher.class.getName()); + public CharSequence getAccessibilityClassName() { + return TextSwitcher.class.getName(); } } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 94fc9e9..848c1c0 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -109,6 +109,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.ViewAssistData; import android.view.ViewConfiguration; import android.view.ViewDebug; import android.view.ViewGroup.LayoutParams; @@ -8531,12 +8532,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener UserHandle.USER_CURRENT_OR_SELF) == 1); } + @Override + public CharSequence getAccessibilityClassName() { + return TextView.class.getName(); + } + + @Override + public void onProvideAssistData(ViewAssistData data, Bundle extras) { + super.onProvideAssistData(data, extras); + final boolean isPassword = hasPasswordTransformationMethod(); + if (!isPassword) { + data.setText(getText(), getSelectionStart(), getSelectionEnd()); + } + data.setHint(getHint()); + } + /** @hide */ @Override public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { super.onInitializeAccessibilityEventInternal(event); - event.setClassName(TextView.class.getName()); final boolean isPassword = hasPasswordTransformationMethod(); event.setPassword(isPassword); @@ -8552,7 +8567,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(TextView.class.getName()); final boolean isPassword = hasPasswordTransformationMethod(); info.setPassword(isPassword); diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java index bbf5f53..9df8a21 100644 --- a/core/java/android/widget/TimePicker.java +++ b/core/java/android/widget/TimePicker.java @@ -195,31 +195,15 @@ public class TimePicker extends FrameLayout { mDelegate.onRestoreInstanceState(ss); } - /** @hide */ - @Override - public boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) { - return mDelegate.dispatchPopulateAccessibilityEvent(event); - } - - /** @hide */ @Override - public void onPopulateAccessibilityEventInternal(AccessibilityEvent event) { - super.onPopulateAccessibilityEventInternal(event); - mDelegate.onPopulateAccessibilityEvent(event); + public CharSequence getAccessibilityClassName() { + return TimePicker.class.getName(); } /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - mDelegate.onInitializeAccessibilityEvent(event); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - mDelegate.onInitializeAccessibilityNodeInfo(info); + public boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) { + return mDelegate.dispatchPopulateAccessibilityEvent(event); } /** @@ -252,8 +236,6 @@ public class TimePicker extends FrameLayout { boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event); void onPopulateAccessibilityEvent(AccessibilityEvent event); - void onInitializeAccessibilityEvent(AccessibilityEvent event); - void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info); } /** diff --git a/core/java/android/widget/TimePickerClockDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java index 1534429..05c7a5f 100644 --- a/core/java/android/widget/TimePickerClockDelegate.java +++ b/core/java/android/widget/TimePickerClockDelegate.java @@ -466,16 +466,6 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate impl event.getText().add(selectedDate); } - @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - event.setClassName(TimePicker.class.getName()); - } - - @Override - public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { - info.setClassName(TimePicker.class.getName()); - } - /** * Set whether in keyboard mode or not. * diff --git a/core/java/android/widget/TimePickerSpinnerDelegate.java b/core/java/android/widget/TimePickerSpinnerDelegate.java index e162f4a..af69110 100644 --- a/core/java/android/widget/TimePickerSpinnerDelegate.java +++ b/core/java/android/widget/TimePickerSpinnerDelegate.java @@ -427,16 +427,6 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate { event.getText().add(selectedDateUtterance); } - @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - event.setClassName(TimePicker.class.getName()); - } - - @Override - public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { - info.setClassName(TimePicker.class.getName()); - } - private void updateInputState() { // Make sure that if the user changes the value and the IME is active // for one of the inputs if this widget, the IME is closed. If the user diff --git a/core/java/android/widget/ToggleButton.java b/core/java/android/widget/ToggleButton.java index 1b23778..4f8342b 100644 --- a/core/java/android/widget/ToggleButton.java +++ b/core/java/android/widget/ToggleButton.java @@ -153,17 +153,8 @@ public class ToggleButton extends CompoundButton { } } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ToggleButton.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ToggleButton.class.getName()); + public CharSequence getAccessibilityClassName() { + return ToggleButton.class.getName(); } } diff --git a/core/java/android/widget/TwoLineListItem.java b/core/java/android/widget/TwoLineListItem.java index 9035dbe..0cd7eb9 100644 --- a/core/java/android/widget/TwoLineListItem.java +++ b/core/java/android/widget/TwoLineListItem.java @@ -93,17 +93,8 @@ public class TwoLineListItem extends RelativeLayout { return mText2; } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(TwoLineListItem.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(TwoLineListItem.class.getName()); + public CharSequence getAccessibilityClassName() { + return TwoLineListItem.class.getName(); } } diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java index a240dc2..48283d4 100644 --- a/core/java/android/widget/VideoView.java +++ b/core/java/android/widget/VideoView.java @@ -201,18 +201,9 @@ public class VideoView extends SurfaceView setMeasuredDimension(width, height); } - /** @hide */ - @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(VideoView.class.getName()); - } - - /** @hide */ @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(VideoView.class.getName()); + public CharSequence getAccessibilityClassName() { + return VideoView.class.getName(); } public int resolveAdjustedSize(int desiredSize, int measureSpec) { diff --git a/core/java/android/widget/ViewAnimator.java b/core/java/android/widget/ViewAnimator.java index d31754b..5ef5222 100644 --- a/core/java/android/widget/ViewAnimator.java +++ b/core/java/android/widget/ViewAnimator.java @@ -357,17 +357,8 @@ public class ViewAnimator extends FrameLayout { return (getCurrentView() != null) ? getCurrentView().getBaseline() : super.getBaseline(); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ViewAnimator.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ViewAnimator.class.getName()); + public CharSequence getAccessibilityClassName() { + return ViewAnimator.class.getName(); } } diff --git a/core/java/android/widget/ViewFlipper.java b/core/java/android/widget/ViewFlipper.java index 587f469..a43a185 100644 --- a/core/java/android/widget/ViewFlipper.java +++ b/core/java/android/widget/ViewFlipper.java @@ -149,18 +149,9 @@ public class ViewFlipper extends ViewAnimator { updateRunning(); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ViewFlipper.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ViewFlipper.class.getName()); + public CharSequence getAccessibilityClassName() { + return ViewFlipper.class.getName(); } /** diff --git a/core/java/android/widget/ViewSwitcher.java b/core/java/android/widget/ViewSwitcher.java index c97770f..2f544cc 100644 --- a/core/java/android/widget/ViewSwitcher.java +++ b/core/java/android/widget/ViewSwitcher.java @@ -68,18 +68,9 @@ public class ViewSwitcher extends ViewAnimator { super.addView(child, index, params); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ViewSwitcher.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ViewSwitcher.class.getName()); + public CharSequence getAccessibilityClassName() { + return ViewSwitcher.class.getName(); } /** diff --git a/core/java/android/widget/ZoomButton.java b/core/java/android/widget/ZoomButton.java index e0be0ab..6b3faed 100644 --- a/core/java/android/widget/ZoomButton.java +++ b/core/java/android/widget/ZoomButton.java @@ -103,17 +103,8 @@ public class ZoomButton extends ImageButton implements OnLongClickListener { return super.dispatchUnhandledMove(focused, direction); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ZoomButton.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ZoomButton.class.getName()); + public CharSequence getAccessibilityClassName() { + return ZoomButton.class.getName(); } } diff --git a/core/java/android/widget/ZoomControls.java b/core/java/android/widget/ZoomControls.java index a0aacea..bef1ace 100644 --- a/core/java/android/widget/ZoomControls.java +++ b/core/java/android/widget/ZoomControls.java @@ -109,17 +109,8 @@ public class ZoomControls extends LinearLayout { return mZoomIn.hasFocus() || mZoomOut.hasFocus(); } - /** @hide */ @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); - event.setClassName(ZoomControls.class.getName()); - } - - /** @hide */ - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - info.setClassName(ZoomControls.class.getName()); + public CharSequence getAccessibilityClassName() { + return ZoomControls.class.getName(); } } diff --git a/core/java/com/android/internal/widget/ResolverDrawerLayout.java b/core/java/com/android/internal/widget/ResolverDrawerLayout.java index 4e48454..01e835b 100644 --- a/core/java/com/android/internal/widget/ResolverDrawerLayout.java +++ b/core/java/com/android/internal/widget/ResolverDrawerLayout.java @@ -593,15 +593,13 @@ public class ResolverDrawerLayout extends ViewGroup { } @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - super.onInitializeAccessibilityEvent(event); - event.setClassName(ResolverDrawerLayout.class.getName()); + public CharSequence getAccessibilityClassName() { + return ResolverDrawerLayout.class.getName(); } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); - info.setClassName(ResolverDrawerLayout.class.getName()); if (isEnabled()) { if (mCollapseOffset != 0) { info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); diff --git a/core/java/com/android/internal/widget/ScrollingTabContainerView.java b/core/java/com/android/internal/widget/ScrollingTabContainerView.java index a306697..825fcad 100644 --- a/core/java/com/android/internal/widget/ScrollingTabContainerView.java +++ b/core/java/com/android/internal/widget/ScrollingTabContainerView.java @@ -393,17 +393,9 @@ public class ScrollingTabContainerView extends HorizontalScrollView } @Override - public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { - super.onInitializeAccessibilityEventInternal(event); + public CharSequence getAccessibilityClassName() { // This view masquerades as an action bar tab. - event.setClassName(ActionBar.Tab.class.getName()); - } - - @Override - public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfoInternal(info); - // This view masquerades as an action bar tab. - info.setClassName(ActionBar.Tab.class.getName()); + return ActionBar.Tab.class.getName(); } @Override diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PreviewPageFrame.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PreviewPageFrame.java index feb0316..6a6f1d3 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/widget/PreviewPageFrame.java +++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PreviewPageFrame.java @@ -48,16 +48,19 @@ public final class PreviewPageFrame extends LinearLayout { } @Override + public CharSequence getAccessibilityClassName() { + return CompoundButton.class.getName(); + } + + @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); - event.setClassName(CompoundButton.class.getName()); event.setChecked(isSelected()); } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); - info.setClassName(CompoundButton.class.getName()); info.setSelected(false); info.setCheckable(true); info.setChecked(isSelected()); |