Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b0afb49 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Adding API for refreshing the state of an AccessibilityNodeInfo.

Sometimes a client needs to hold onto an accessibility node info and
this info may get into a stale state. The clent has to be able to
request a refresh of the info. This change adds a refresh call to
AccessibilityNodeInfo.

bug:6711796

Change-Id: I580a9a5d9fd1f705ea0a2cf4d3ff65543714c9c3
parent 6a6f51ff
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26240,6 +26240,7 @@ package android.view.accessibility {
    method public boolean performAction(int);
    method public boolean performAction(int, android.os.Bundle);
    method public void recycle();
    method public boolean refresh();
    method public void setAccessibilityFocused(boolean);
    method public void setBoundsInParent(android.graphics.Rect);
    method public void setBoundsInScreen(android.graphics.Rect);
+25 −0
Original line number Diff line number Diff line
@@ -485,6 +485,31 @@ public class AccessibilityNodeInfo implements Parcelable {
        return mWindowId;
    }

    /**
     * Refreshes this info with the latest state of the view it represents.
     * <p>
     * <strong>Note:</strong> If this method returns false this info is obsolete
     * since it represents a view that is no longer in the view tree and should
     * be recycled.
     * </p>
     * @return Whether the refresh succeeded.
     */
    public boolean refresh() {
        enforceSealed();
        if (!canPerformRequestOverConnection(mSourceNodeId)) {
            return false;
        }
        AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
        AccessibilityNodeInfo refreshedInfo = client.findAccessibilityNodeInfoByAccessibilityId(
                mConnectionId, mWindowId, mSourceNodeId, 0);
        if (refreshedInfo == null) {
            return false;
        }
        init(refreshedInfo);
        refreshedInfo.recycle();
        return true;
    }

    /**
     * @return The ids of the children.
     *