FileDocCategorySizeDatePackage
AccessibilityWindowInfo.javaAPI DocAndroid 5.1 API17707Thu Mar 12 22:22:10 GMT 2015android.view.accessibility

AccessibilityWindowInfo

public final class AccessibilityWindowInfo extends Object implements android.os.Parcelable
This class represents a state snapshot of a window for accessibility purposes. The screen content contains one or more windows where some windows can be descendants of other windows, which is the windows are hierarchically ordered. Note that there is no root window. Hence, the screen content can be seen as a collection of window trees.

Fields Summary
private static final boolean
DEBUG
public static final int
TYPE_APPLICATION
Window type: This is an application window. Such a window shows UI for interacting with an application.
public static final int
TYPE_INPUT_METHOD
Window type: This is an input method window. Such a window shows UI for inputting text such as keyboard, suggestions, etc.
public static final int
TYPE_SYSTEM
Window type: This is an system window. Such a window shows UI for interacting with the system.
public static final int
TYPE_ACCESSIBILITY_OVERLAY
Window type: Windows that are overlaid only by an {@link android.accessibilityservice.AccessibilityService} for interception of user interactions without changing the windows an accessibility service can introspect. In particular, an accessibility service can introspect only windows that a sighted user can interact with which they can touch these windows or can type into these windows. For example, if there is a full screen accessibility overlay that is touchable, the windows below it will be introspectable by an accessibility service regardless they are covered by a touchable window.
private static final int
UNDEFINED
private static final int
BOOLEAN_PROPERTY_ACTIVE
private static final int
BOOLEAN_PROPERTY_FOCUSED
private static final int
BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED
private static final int
MAX_POOL_SIZE
private static final android.util.Pools.SynchronizedPool
sPool
private int
mType
private int
mLayer
private int
mBooleanProperties
private int
mId
private int
mParentId
private final android.graphics.Rect
mBoundsInScreen
private android.util.LongArray
mChildIds
private int
mConnectionId
public static final Parcelable.Creator
CREATOR
Constructors Summary
private AccessibilityWindowInfo()


      
        /* do nothing - hide constructor */
    
Methods Summary
public voidaddChild(int childId)
Adds a child window.

param
childId The child window id.
hide

        if (mChildIds == null) {
            mChildIds = new LongArray();
        }
        mChildIds.add(childId);
    
public booleanchanged(android.view.accessibility.AccessibilityWindowInfo other)
Checks whether this window changed. The argument should be another state of the same window, which is have the same id and type as they never change.

param
other The new state.
return
Whether something changed.
hide

        if (other.mId != mId) {
            throw new IllegalArgumentException("Not same window.");
        }
        if (other.mType != mType) {
            throw new IllegalArgumentException("Not same type.");
        }
        if (!mBoundsInScreen.equals(mBoundsInScreen)) {
            return true;
        }
        if (mLayer != other.mLayer) {
            return true;
        }
        if (mBooleanProperties != other.mBooleanProperties) {
            return true;
        }
        if (mParentId != other.mParentId) {
            return true;
        }
        if (mChildIds == null) {
            if (other.mChildIds != null) {
                return true;
            }
        } else if (!mChildIds.equals(other.mChildIds)) {
            return true;
        }
        return false;
    
private voidclear()
Clears the internal state.

        mType = UNDEFINED;
        mLayer = UNDEFINED;
        mBooleanProperties = 0;
        mId = UNDEFINED;
        mParentId = UNDEFINED;
        mBoundsInScreen.setEmpty();
        if (mChildIds != null) {
            mChildIds.clear();
        }
        mConnectionId = UNDEFINED;
    
public intdescribeContents()

        return 0;
    
public booleanequals(java.lang.Object obj)

        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        AccessibilityWindowInfo other = (AccessibilityWindowInfo) obj;
        return (mId == other.mId);
    
private booleangetBooleanProperty(int property)
Gets the value of a boolean property.

param
property The property.
return
The value.

        return (mBooleanProperties & property) != 0;
    
public voidgetBoundsInScreen(android.graphics.Rect outBounds)
Gets the bounds of this window in the screen.

param
outBounds The out window bounds.

        outBounds.set(mBoundsInScreen);
    
public android.view.accessibility.AccessibilityWindowInfogetChild(int index)
Gets the child window at a given index.

param
index The index.
return
The child.

        if (mChildIds == null) {
            throw new IndexOutOfBoundsException();
        }
        if (mConnectionId == UNDEFINED) {
            return null;
        }
        final int childId = (int) mChildIds.get(index);
        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
        return client.getWindow(mConnectionId, childId);
    
public intgetChildCount()
Gets the number of child windows.

return
The child count.

        return (mChildIds != null) ? mChildIds.size() : 0;
    
public intgetId()
Gets the unique window id.

return
windowId The window id.

        return mId;
    
public intgetLayer()
Gets the layer which determines the Z-order of the window. Windows with greater layer appear on top of windows with lesser layer.

return
The window layer.

        return mLayer;
    
public android.view.accessibility.AccessibilityWindowInfogetParent()
Gets the parent window if such.

return
The parent window.

        if (mConnectionId == UNDEFINED || mParentId == UNDEFINED) {
            return null;
        }
        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
        return client.getWindow(mConnectionId, mParentId);
    
public AccessibilityNodeInfogetRoot()
Gets the root node in the window's hierarchy.

return
The root node.

        if (mConnectionId == UNDEFINED) {
            return null;
        }
        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
        return client.findAccessibilityNodeInfoByAccessibilityId(mConnectionId,
                mId, AccessibilityNodeInfo.ROOT_NODE_ID,
                true, AccessibilityNodeInfo.FLAG_PREFETCH_DESCENDANTS);
    
public intgetType()
Gets the type of the window.

return
The type.
see
#TYPE_APPLICATION
see
#TYPE_INPUT_METHOD
see
#TYPE_SYSTEM
see
#TYPE_ACCESSIBILITY_OVERLAY

        return mType;
    
public inthashCode()

        return mId;
    
private voidinitFromParcel(android.os.Parcel parcel)

        mType = parcel.readInt();
        mLayer = parcel.readInt();
        mBooleanProperties = parcel.readInt();
        mId = parcel.readInt();
        mParentId = parcel.readInt();
        mBoundsInScreen.readFromParcel(parcel);

        final int childCount = parcel.readInt();
        if (childCount > 0) {
            if (mChildIds == null) {
                mChildIds = new LongArray(childCount);
            }
            for (int i = 0; i < childCount; i++) {
                final int childId = parcel.readInt();
                mChildIds.add(childId);
            }
        }

        mConnectionId = parcel.readInt();
    
public booleanisAccessibilityFocused()
Gets if this window has accessibility focus.

return
Whether has accessibility focus.

        return getBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED);
    
public booleanisActive()
Gets if this window is active. An active window is the one the user is currently touching or the window has input focus and the user is not touching any window.

return
Whether this is the active window.

        return getBooleanProperty(BOOLEAN_PROPERTY_ACTIVE);
    
public booleanisFocused()
Gets if this window has input focus.

return
Whether has input focus.

        return getBooleanProperty(BOOLEAN_PROPERTY_FOCUSED);
    
public static android.view.accessibility.AccessibilityWindowInfoobtain()
Returns a cached instance if such is available or a new one is created.

return
An instance.

        AccessibilityWindowInfo info = sPool.acquire();
        if (info == null) {
            info = new AccessibilityWindowInfo();
        }
        return info;
    
public static android.view.accessibility.AccessibilityWindowInfoobtain(android.view.accessibility.AccessibilityWindowInfo info)
Returns a cached instance if such is available or a new one is created. The returned instance is initialized from the given info.

param
info The other info.
return
An instance.

        AccessibilityWindowInfo infoClone = obtain();

        infoClone.mType = info.mType;
        infoClone.mLayer = info.mLayer;
        infoClone.mBooleanProperties = info.mBooleanProperties;
        infoClone.mId = info.mId;
        infoClone.mParentId = info.mParentId;
        infoClone.mBoundsInScreen.set(info.mBoundsInScreen);

        if (info.mChildIds != null && info.mChildIds.size() > 0) {
            if (infoClone.mChildIds == null) {
                infoClone.mChildIds = info.mChildIds.clone();
            } else {
                infoClone.mChildIds.addAll(info.mChildIds);
            }
        }

        infoClone.mConnectionId = info.mConnectionId;

        return infoClone;
    
public voidrecycle()
Return an instance back to be reused.

Note: You must not touch the object after calling this function.

throws
IllegalStateException If the info is already recycled.

        clear();
        sPool.release(this);
    
public voidsetAccessibilityFocused(boolean focused)
Sets if this window has accessibility focus.

param
focused Whether has accessibility focus.
hide

        setBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBILITY_FOCUSED, focused);
    
public voidsetActive(boolean active)
Sets if this window is active, which is this is the window the user is currently touching or the window has input focus and the user is not touching any window.

param
active Whether this is the active window.
hide

        setBooleanProperty(BOOLEAN_PROPERTY_ACTIVE, active);
    
private voidsetBooleanProperty(int property, boolean value)
Sets a boolean property.

param
property The property.
param
value The value.
throws
IllegalStateException If called from an AccessibilityService.

        if (value) {
            mBooleanProperties |= property;
        } else {
            mBooleanProperties &= ~property;
        }
    
public voidsetBoundsInScreen(android.graphics.Rect bounds)
Sets the bounds of this window in the screen.

param
bounds The out window bounds.
hide

        mBoundsInScreen.set(bounds);
    
public voidsetConnectionId(int connectionId)
Sets the unique id of the IAccessibilityServiceConnection over which this instance can send requests to the system.

param
connectionId The connection id.
hide

        mConnectionId = connectionId;
    
public voidsetFocused(boolean focused)
Sets if this window has input focus.

param
focused Whether has input focus.
hide

        setBooleanProperty(BOOLEAN_PROPERTY_FOCUSED, focused);
    
public voidsetId(int id)
Sets the unique window id.

param
id The window id.
hide

        mId = id;
    
public voidsetLayer(int layer)
Sets the layer which determines the Z-order of the window. Windows with greater layer appear on top of windows with lesser layer.

param
layer The window layer.
hide

        mLayer = layer;
    
public voidsetParentId(int parentId)
Sets the parent window id.

param
parentId The parent id.
hide

        mParentId = parentId;
    
public voidsetType(int type)
Sets the type of the window.

param
type The type
hide

        mType = type;
    
public java.lang.StringtoString()

        StringBuilder builder = new StringBuilder();
        builder.append("AccessibilityWindowInfo[");
        builder.append("id=").append(mId);
        builder.append(", type=").append(typeToString(mType));
        builder.append(", layer=").append(mLayer);
        builder.append(", bounds=").append(mBoundsInScreen);
        builder.append(", focused=").append(isFocused());
        builder.append(", active=").append(isActive());
        if (DEBUG) {
            builder.append(", parent=").append(mParentId);
            builder.append(", children=[");
            if (mChildIds != null) {
                final int childCount = mChildIds.size();
                for (int i = 0; i < childCount; i++) {
                    builder.append(mChildIds.get(i));
                    if (i < childCount - 1) {
                        builder.append(',");
                    }
                }
            } else {
                builder.append("null");
            }
            builder.append(']");
        } else {
            builder.append(", hasParent=").append(mParentId != UNDEFINED);
            builder.append(", hasChildren=").append(mChildIds != null
                    && mChildIds.size() > 0);
        }
        builder.append(']");
        return builder.toString();
    
private static java.lang.StringtypeToString(int type)

        switch (type) {
            case TYPE_APPLICATION: {
                return "TYPE_APPLICATION";
            }
            case TYPE_INPUT_METHOD: {
                return "TYPE_INPUT_METHOD";
            }
            case TYPE_SYSTEM: {
                return "TYPE_SYSTEM";
            }
            case TYPE_ACCESSIBILITY_OVERLAY: {
                return "TYPE_ACCESSIBILITY_OVERLAY";
            }
            default:
                return "<UNKNOWN>";
        }
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)

        parcel.writeInt(mType);
        parcel.writeInt(mLayer);
        parcel.writeInt(mBooleanProperties);
        parcel.writeInt(mId);
        parcel.writeInt(mParentId);
        mBoundsInScreen.writeToParcel(parcel, flags);

        final LongArray childIds = mChildIds;
        if (childIds == null) {
            parcel.writeInt(0);
        } else {
            final int childCount = childIds.size();
            parcel.writeInt(childCount);
            for (int i = 0; i < childCount; i++) {
                parcel.writeInt((int) childIds.get(i));
            }
        }

        parcel.writeInt(mConnectionId);