android.view.accessibility.AccessibilityNodeInfo#isFocused ( )源码实例Demo

下面列出了android.view.accessibility.AccessibilityNodeInfo#isFocused ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: oversec   文件: Tree.java
public void refresh(AccessibilityNodeInfo node) {
    if (sealed) {
        throw new IllegalArgumentException("sealed! " + super.toString());
    }

    mFocused = node.isFocused();
    node.getBoundsInScreen(mBoundsInScreen);
    node.getBoundsInParent(mBoundsInParent);

    mBoundsInScreen.offset(0, -OverlayDecryptView.SCREEN_OFFSET_Y);


    mText = AccessibilityNodeInfoUtils.getNodeText(node);
    mTextString = mText == null ? null : mText.toString();

    mIsEncoded = mText == null ? false : CryptoHandlerFacade.Companion.isEncoded(mCtx, mTextString);
    if (mIsEncoded) {
        mIsTextView = true;
    }
    mIsEditableTextNode = (node.isEditable()
            && node.isEnabled()
            && mIsEditText
            && !node.isPassword());
}
 
源代码2 项目: za-Farmer   文件: UiObject.java
/**
 * Check if the UI element's <code>focused</code> property is currently true
 *
 * @return true if it is else false
 * @throws UiObjectNotFoundException
 * @since API Level 16
 */
public boolean isFocused() throws UiObjectNotFoundException {
    Tracer.trace();
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
    if(node == null) {
        throw new UiObjectNotFoundException(mUiSelector.toString());
    }
    return node.isFocused();
}
 
源代码3 项目: oversec   文件: OversecAccessibilityService.java
private void checkFocusedNode_PreLollipop(AccessibilityNodeInfo node) {
    //if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) return;
    //need to keep that anyway if we want to find focus in WebViews
    synchronized (mSEMAPHORE_FocusedNode_PreLollipop) {

        if (node.isFocused()) {
            mFocusedNode_PreLollipop_INTRANSACTION = AccessibilityNodeInfo.obtain(node);
        }
    }
}
 
源代码4 项目: JsDroidCmd   文件: UiObject.java
/**
 * Check if the UI element's <code>focused</code> property is currently true
 *
 * @return true if it is else false
 * @throws UiObjectNotFoundException
 * @since API Level 16
 */
public boolean isFocused() throws UiObjectNotFoundException {
    Tracer.trace();
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
    if(node == null) {
        throw new UiObjectNotFoundException(mUiSelector.toString());
    }
    return node.isFocused();
}
 
源代码5 项目: JsDroidCmd   文件: AccessibilityNodeInfoDumper.java
public static void dumpNode(AccessibilityNodeInfo info, Node root,
		int index, int width, int height) {
	root.sourceId = info.getSourceNodeId();
	root.index = index;
	root.text = safeCharSeqToString(info.getText());
	root.res = safeCharSeqToString(info.getViewIdResourceName());
	root.clazz = safeCharSeqToString(info.getClassName());
	root.pkg = safeCharSeqToString(info.getPackageName());
	root.desc = safeCharSeqToString(info.getContentDescription());
	root.checkable = info.isCheckable();
	root.checked = info.isChecked();
	root.clickable = info.isClickable();
	root.enabled = info.isEnabled();
	root.focusable = info.isFocusable();
	root.focused = info.isFocused();
	root.scrollable = info.isScrollable();
	root.longClickable = info.isLongClickable();
	root.password = info.isPassword();
	root.selected = info.isSelected();
	android.graphics.Rect r = AccessibilityNodeInfoHelper
			.getVisibleBoundsInScreen(info, width, height);
	root.rect = new Rect(r.left, r.top, r.right, r.bottom);
	root.children = new ArrayList<Node>();
	int count = info.getChildCount();
	for (int i = 0; i < count; i++) {
		AccessibilityNodeInfo child = info.getChild(i);
		if (child != null) {
			if (child.isVisibleToUser()) {
				Node childNode = new Node();
				dumpNode(child, childNode, i, width, height);
				root.children.add(childNode);
				child.recycle();
			}
		}
	}
}
 
private void enforceNodeTreeConsistent(List<AccessibilityNodeInfo> nodes) {
    LongSparseArray<AccessibilityNodeInfo> nodeMap =
            new LongSparseArray<AccessibilityNodeInfo>();
    final int nodeCount = nodes.size();
    for (int i = 0; i < nodeCount; i++) {
        AccessibilityNodeInfo node = nodes.get(i);
        nodeMap.put(node.getSourceNodeId(), node);
    }

    // If the nodes are a tree it does not matter from
    // which node we start to search for the root.
    AccessibilityNodeInfo root = nodeMap.valueAt(0);
    AccessibilityNodeInfo parent = root;
    while (parent != null) {
        root = parent;
        parent = nodeMap.get(parent.getParentNodeId());
    }

    // Traverse the tree and do some checks.
    AccessibilityNodeInfo accessFocus = null;
    AccessibilityNodeInfo inputFocus = null;
    HashSet<AccessibilityNodeInfo> seen = new HashSet<AccessibilityNodeInfo>();
    Queue<AccessibilityNodeInfo> fringe = new LinkedList<AccessibilityNodeInfo>();
    fringe.add(root);

    while (!fringe.isEmpty()) {
        AccessibilityNodeInfo current = fringe.poll();

        // Check for duplicates
        if (!seen.add(current)) {
            throw new IllegalStateException("Duplicate node: "
                    + current + " in window:"
                    + mViewRootImpl.mAttachInfo.mAccessibilityWindowId);
        }

        // Check for one accessibility focus.
        if (current.isAccessibilityFocused()) {
            if (accessFocus != null) {
                throw new IllegalStateException("Duplicate accessibility focus:"
                        + current
                        + " in window:" + mViewRootImpl.mAttachInfo.mAccessibilityWindowId);
            } else {
                accessFocus = current;
            }
        }

        // Check for one input focus.
        if (current.isFocused()) {
            if (inputFocus != null) {
                throw new IllegalStateException("Duplicate input focus: "
                    + current + " in window:"
                    + mViewRootImpl.mAttachInfo.mAccessibilityWindowId);
            } else {
                inputFocus = current;
            }
        }

        final int childCount = current.getChildCount();
        for (int j = 0; j < childCount; j++) {
            final long childId = current.getChildId(j);
            final AccessibilityNodeInfo child = nodeMap.get(childId);
            if (child != null) {
                fringe.add(child);
            }
        }
    }

    // Check for disconnected nodes.
    for (int j = nodeMap.size() - 1; j >= 0; j--) {
        AccessibilityNodeInfo info = nodeMap.valueAt(j);
        if (!seen.contains(info)) {
            throw new IllegalStateException("Disconnected node: " + info);
        }
    }
}
 
源代码7 项目: oversec   文件: OversecAccessibilityService.java
private void refreshNode_MAIN(AccessibilityNodeInfo node) {
    checkHandlerThread();
    if (LoggingConfig.INSTANCE.getLOG()) {
        Ln.d("SKRAPE: refreshNode node= %s", node.hashCode());
    }

    long t1 = System.currentTimeMillis();

    //no need to explicitly refresh, the ACS event shouldhave passed us the latest version already!
    //node.refresh();
    if (node.isFocused()) {
        checkFocusedNode_PreLollipop(node);
    }


    Tree.TreeNode treeNode = mTree.get(node);


    if (treeNode == null) {
        mTree.put(node);
    } else {
        treeNode.refresh(node);
    }


    long t2 = System.currentTimeMillis();
    Ln.d("SKRAPE refreshNode took %s", (t2 - t1));


}