Java 类android.view.accessibility.AccessibilityNodeInfo 实例源码

项目:adb-install-robot    文件:AutoInstallAccessibilityService.java   
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    int eventType = event.getEventType();
    switch (eventType) {
        case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
            for (String id : installBtnId) {
                AccessibilityNodeInfo node = AccessibilityNodeUtil.findNodeById(event.getSource(), id);
                if (node != null) {
                    AccessibilityNodeUtil.click(node);
                    Toast.makeText(this, "安装成功", Toast.LENGTH_SHORT).show();
                    break;
                }
            }
            break;
        default:
            break;
    }
}
项目:QiangHongBao    文件:WeChatAccessibilityJob.java   
/** 是否为群聊天 */
private boolean isMemberChatUi(AccessibilityNodeInfo nodeInfo) {
    if(nodeInfo == null) {
        return false;
    }

    AccessibilityNodeInfo label = AccessibilityUtils.findNodeInfosById(nodeInfo, ID_GROUP_NAME);
    if(label != null) {
        String title = String.valueOf(label.getText());
        LogUtils.printOut("title", title);
        if(title != null && title.endsWith(")")) {
            return true;
        }
    }
    return false;
}
项目:DateTimePicker    文件:NumberPicker.java   
@Override
public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String searched,
                                                                    int virtualViewId) {
    if (TextUtils.isEmpty(searched)) {
        return Collections.emptyList();
    }
    String searchedLowerCase = searched.toLowerCase();
    List<AccessibilityNodeInfo> result = new ArrayList<AccessibilityNodeInfo>();
    switch (virtualViewId) {
        case View.NO_ID: {
            findAccessibilityNodeInfosByTextInChild(searchedLowerCase,
                    VIRTUAL_VIEW_ID_DECREMENT, result);
            findAccessibilityNodeInfosByTextInChild(searchedLowerCase,
                    VIRTUAL_VIEW_ID_INPUT, result);
            findAccessibilityNodeInfosByTextInChild(searchedLowerCase,
                    VIRTUAL_VIEW_ID_INCREMENT, result);
            return result;
        }
        case VIRTUAL_VIEW_ID_DECREMENT:
        case VIRTUAL_VIEW_ID_INCREMENT:
        case VIRTUAL_VIEW_ID_INPUT: {
            findAccessibilityNodeInfosByTextInChild(searchedLowerCase, virtualViewId,
                    result);
            return result;
        }
    }
    return super.findAccessibilityNodeInfosByText(searched, virtualViewId);
}
项目:keepass2android    文件:AutoFillService.java   
@TargetApi(21)
private void FillPassword(String url, AccessibilityNodeInfo usernameEdit, List<AccessibilityNodeInfo> passwordFields)
{
    if ((keepass2android.kbbridge.KeyboardData.hasData()) && (_hasUsedData == false))
    {
        fillDataInTextField(usernameEdit, getLastReceivedCredentialsUser());
        for (int i=0;i<passwordFields.size();i++)
        {
            fillDataInTextField(passwordFields.get(i), getLastReceivedCredentialsPassword());
        }
        _hasUsedData = true;
    }



    //LookupCredentialsActivity.LastReceivedCredentials = null;
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:ActionFactory.java   
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static SimpleAction createActionWithEditableFilter(final int action, int index, final String text) {
    return new SearchTargetAction(action, new FilterAction.EditableFilter(index)) {

        @Override
        protected void performAction(UiObject node) {
            Bundle args = new Bundle();
            if (action == AccessibilityNodeInfo.ACTION_SET_TEXT) {
                args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text);
            } else {
                args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, node.text() + text);
            }
            node.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args);
        }
    };
}
项目:ReplyMessage    文件:PerformClickUtils.java   
/**
 * 在当前页面查找文字内容并点击
 *
 * @param text
 */
public static void findTextAndClick(AccessibilityService accessibilityService, String text) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;
    }

    List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text);
    if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
            if (nodeInfo != null && (text.equals(nodeInfo.getText()) || text.equals(nodeInfo.getContentDescription()))) {
                performClick(nodeInfo);
                break;
            }
        }
    }
}
项目:miser-utils    文件:ComeOnMoneyService.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void openEnvelopeWx() {
    AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
    if (nodeInfo == null) {
        Log.w(TAG, "rootWindow为空");
        return;
    }
    List<AccessibilityNodeInfo> list6 = nodeInfo.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/b43");
    Log.w(TAG, "b43list:" + list6);
    for (AccessibilityNodeInfo n : list6) {
        n.performAction(AccessibilityNodeInfo.ACTION_CLICK);
        isAutoOpen = true;
    }
    /**
     * 判断一下是否已经被抢完了 抢完了就返回
     */
    List<AccessibilityNodeInfo> list7 = nodeInfo.findAccessibilityNodeInfosByText(WX_ACTION_BACK_NO_MONEY);
    if (list7 != null && list7.size() != 0) {
        Log.e(TAG, "[红包被抢完],手动返回");
        performGlobalAction(GLOBAL_ACTION_HOME);
    }
}
项目:Accessibility    文件:BaseAccessibility.java   
public static boolean hasAccessibilityNode(AccessibilityNodeInfo info, String[] texts) {
    if (texts != null) {
        for (String textItem : texts) {
            List<AccessibilityNodeInfo> nodes = info.findAccessibilityNodeInfosByText(textItem);
            if (nodes != null && !nodes.isEmpty()) {
                AccessibilityNodeInfo node;
                for (int i = 0; i < nodes.size(); i++) {
                    node = nodes.get(i);
                    BaseAccessibility.logPrint("find text=" + textItem + "  enable=" + node.isEnabled());
                    CharSequence text = node.getText();
                    if (TextUtils.equals(text, textItem)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
项目:PreviewSeekBar-master    文件:CustomTimeBar.java   
@TargetApi(21)
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName(com.google.android.exoplayer2.ui.DefaultTimeBar.class.getCanonicalName());
    info.setContentDescription(getProgressText());
    if (duration <= 0) {
        return;
    }
    if (Util.SDK_INT >= 21) {
        info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
        info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
    } else if (Util.SDK_INT >= 16) {
        info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
    }
}
项目:stynico    文件:AnimatedEditText.java   
/**
    * 爬遍所有节点查找可点的按钮,用于解决Android5.1等组件层次分离的情况
    * @param root 界面根节点
    */
   void crawlButton(AccessibilityNodeInfo root)
   {
AccessibilityNodeInfo child;
Integer size = root.getChildCount();
for (Integer i=0;i < size;i++)
{
    child = root.getChild(i);
    if (child != null)
    {
    if (child.getClassName().toString().equals("android.widget.Button"))
    {
        //  Log.d("crawl-button", child.toString());
        //Log.d("click", "OPEN");
        child.performAction(AccessibilityNodeInfo.ACTION_CLICK); // 拆红包
        cnt_open += 1;
        flags_detail = 1; // 红包有效
        state = State.DETAIL;
    }
    crawlButton(child);
    }

}
   }
项目:DateTimePicker    文件:RadialTimePickerView.java   
@Override
public boolean performAccessibilityAction(View host, int action, Bundle arguments) {
    if (super.performAccessibilityAction(host, action, arguments)) {
        return true;
    }

    switch (action) {
        case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
            adjustPicker(1);
            return true;
        case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
            adjustPicker(-1);
            return true;
    }

    return false;
}
项目:AutoInteraction-Library    文件:UiTree.java   
public static AccessibilityNodeInfo getRootAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo accessibilityNodeInfo) throws MyException {
    if (null == accessibilityNodeInfo) {
        throw new NullPointerException("accessibilityNodeInfo");
    }
    AccessibilityNodeInfo current = null;
    try {
        current = accessibilityNodeInfo;
        while (true) {
            AccessibilityNodeInfo parent = current.getParent();
            if (null == parent) {
                return current;
            }
            current = parent;
        }
    } catch (Exception e) {
        if (null != current) {
            current.recycle();
        }
        throw new MyException(e);
    }
}
项目:Auto.js    文件:AccessibilityNodeInfoHelper.java   
/**
 * Returns the node's bounds clipped to the size of the display
 *
 * @param node
 * @param width  pixel width of the display
 * @param height pixel height of the display
 * @return null if node is null, else a Rect containing visible bounds
 */
public static Rect getVisibleBoundsInScreen(AccessibilityNodeInfo node, int width, int height) {
    if (node == null) {
        return null;
    }
    // targeted node's bounds
    Rect nodeRect = new Rect();
    node.getBoundsInScreen(nodeRect);

    Rect displayRect = new Rect();
    displayRect.top = 0;
    displayRect.left = 0;
    displayRect.right = width;
    displayRect.bottom = height;
    boolean intersect = nodeRect.intersect(displayRect);
    return nodeRect;
}
项目:QiangHongBao    文件:QQAccessibilityJob.java   
/** 查看领取详情或者返回 */
private void clickRedPacketAfter() {
    // 到这, 领取流程算是完了
    isReceived = false;

    // 查看领取详情, 或者返回
    if(!config().isSmartBackQQ()){
        SystemClock.sleep(999);
        AccessibilityNodeInfo nodeInfo = mService.getRootInActiveWindow();
        if(nodeInfo == null) {
            LogUtils.printErr(TAG, "rootWindow为空");
            return;
        }

        AccessibilityNodeInfo look = AccessibilityUtils.findNodeInfosByText(nodeInfo, KEY_LOOK);
        if(look != null){
            AccessibilityUtils.performClick(look);
        }
    }else{
        back();
    }
}
项目:ReplyMessage    文件:PerformClickUtils.java   
/**
 * 检查viewId进行点击
 *
 * @param accessibilityService
 * @param id
 */
public static void findViewIdAndClick(AccessibilityService accessibilityService, String id) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;
    }

    List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByViewId(id);
    if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
            if (nodeInfo != null) {
                performClick(nodeInfo);
                break;
            }
        }
    }
}
项目:weixin_auto    文件:ParseRootUtil.java   
/**
 * 封装节点属性
 * @param node
 * @param childNum
 * @param childPath
 * @return
 */
private static NodeAttr setFuntion(AccessibilityNodeInfo node,int childNum,String childPath){
    NodeAttr attr = new NodeAttr();
    //attr.setChildNum(childNum);
    attr.setChildPath(childPath+childNum);
    attr.setNode(node);
    Map<String,Object> function = new HashMap<String,Object>();
    function.put("isClickable",node.isClickable());
    function.put("isEditable",node.isEditable());
    function.put("getChildCount",node.getChildCount());
    function.put("getClassName",node.getClassName());
    function.put("getText",node.getText());
    function.put("getContentDescription",node.getContentDescription());
    attr.setFunction(function);
    return attr;
}
项目:Auto.js    文件:AccessibilityActionConverter.java   
@Override
public void onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event, StringBuilder sb) {
    AccessibilityNodeInfo source = event.getSource();
    if (source == null)
        return;
    String bounds = NodeInfo.boundsToString(AccessibilityNodeInfoHelper.getBoundsInScreen(source));
    source.recycle();
    onAccessibilityEvent(event, bounds, sb);
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:LayoutInspector.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void refreshChildList(AccessibilityNodeInfo root) {
    if (root == null)
        return;
    root.refresh();
    int childCount = root.getChildCount();
    for (int i = 0; i < childCount; i++) {
        refreshChildList(root.getChild(i));
    }
}
项目:TPlayer    文件:AceHelper.java   
/**
 * 通过文本查找节点(注: text是包含contains,而不是完全equals)
 * @param nodeInfo
 * @param text
 * @return
 */
public static AccessibilityNodeInfo findNodeByText(AccessibilityNodeInfo nodeInfo, String text) {
    List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(text);
    if(list == null || list.isEmpty()) {
        return null;
    }
    return list.get(0);
}
项目:letv    文件:AbsHListView.java   
@TargetApi(14)
@SuppressLint({"Override"})
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName(AbsHListView.class.getName());
    if (isEnabled()) {
        if (getFirstVisiblePosition() > 0) {
            info.addAction(8192);
        }
        if (getLastVisiblePosition() < getCount() - 1) {
            info.addAction(4096);
        }
    }
}
项目:stynico    文件:dex_smali.java   
/**
    * 获取一个可以点击的节点
    */
   private AccessibilityNodeInfo getClickableNode(AccessibilityNodeInfo node)
   {
AccessibilityNodeInfo parent=node;
while (parent != null)
{
    if (parent.isClickable())
    {
    break;
    }
    parent = parent.getParent();
}
return parent;
   }
项目:PrivacyStreams    文件:AccessibilityUtils.java   
/**
 *
 * @param root is the rootview of a given page.
 * @param packageName denotes the related app for this given page.
 * @return A list of accessibility node infos representing a list of messages in a given chat app
 */

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public static List<AccessibilityNodeInfo> getMessageList(AccessibilityNodeInfo root, String packageName){
    if(root!=null)
        return root.findAccessibilityNodeInfosByViewId(getMessageListResourceId(packageName));

    else
        return new ArrayList<>();
}
项目:AutoInteraction-Library    文件:UiTree.java   
public UiTree(@NonNull String className, @Nullable AccessibilityNodeInfo accessibilityNodeInfo) throws UiNode.NullChildAccessibilityNodeInfoException, MyException {
    if (null == className) {
        throw new NullPointerException("className");
    }
    mClassName = className;
    mNode = (null == accessibilityNodeInfo ? null : new UiNode(getRootAccessibilityNodeInfo(accessibilityNodeInfo)));
    mFoundForm = findForm();
    mLog = obtainLog();
}
项目:android_ui    文件:ViewPagerWidget.java   
/**
 */
@Override
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void onInitializeAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName(ViewPagerWidget.class.getName());
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:AccessibilityNodeInfoAllocator.java   
public static void recycleList(AccessibilityNodeInfo root, List<AccessibilityNodeInfo> list) {
    for (AccessibilityNodeInfo nodeInfo : list) {
        if (nodeInfo != root && nodeInfo != null) {
            //// FIXME: 2017/5/1 Issue #180
            nodeInfo.recycle();
        }
    }
}
项目:CSipSimple    文件:IcsAdapterView.java   
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setScrollable(isScrollableForAccessibility());
    View selectedView = getSelectedView();
    if (selectedView != null) {
        info.setEnabled(selectedView.isEnabled());
    }
}
项目:espresso-support    文件:AccessibilityViewMatchers.java   
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static AccessibilityNodeInfo.AccessibilityAction findAction(View view, int actionId) {
    AccessibilityNodeInfo accessibilityNodeInfo = view.createAccessibilityNodeInfo();
    for (AccessibilityNodeInfo.AccessibilityAction accessibilityAction : accessibilityNodeInfo.getActionList()) {
        if (actionId == accessibilityAction.getId()) {
            return accessibilityAction;
        }
    }
    throw new AccessibilityActionNotFoundException(actionId);
}
项目:pc-android-controller-android    文件:AccessUtil.java   
private void openDelay(final AccessibilityNodeInfo nodeInfo, final int delaytime, final String text) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            Looper.prepare();
            try {
                sleep(delaytime);
            } catch (InterruptedException mE) {
                mE.printStackTrace();
            }
            openNext(nodeInfo, text);
        }
    }).start();
}
项目:PrivacyStreams    文件:AccessibilityUtils.java   
/**
 *
 * @param root
 * @param appName
 * @return
 */

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getBrowserCurrentUrl(AccessibilityNodeInfo root, String appName){
    try{
        AccessibilityNodeInfo bar = root.findAccessibilityNodeInfosByViewId(getUrlResourceId(appName)).get(0);
        if(bar!=null){
            return bar.getText().toString();
        }
    }
    catch (Exception exception){
        return null;
    }
    return null;
}
项目:WeChatLuckyMoney    文件:HongbaoSignature.java   
private String[] getSenderContentDescriptionFromNode(AccessibilityNodeInfo node) {
    int count = node.getChildCount();
    String[] result = {"unknownSender", "unknownTime"};
    for (int i = 0; i < count; i++) {
        AccessibilityNodeInfo thisNode = node.getChild(i);
        if ("android.widget.ImageView".equals(thisNode.getClassName()) && "unknownSender".equals(result[0])) {
            CharSequence contentDescription = thisNode.getContentDescription();
            if (contentDescription != null) result[0] = contentDescription.toString().replaceAll("头像$", "");
        } else if ("android.widget.TextView".equals(thisNode.getClassName()) && "unknownTime".equals(result[1])) {
            CharSequence thisNodeText = thisNode.getText();
            if (thisNodeText != null) result[1] = thisNodeText.toString();
        }
    }
    return result;
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:AccessibilityActionConverter.java   
@Override
public void onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event, StringBuilder sb) {
    AccessibilityNodeInfo source = event.getSource();
    if (source == null)
        return;
    UiObject uiObject = UiObject.createRoot(service.getRootInActiveWindow());
    List<UiObject> editableList = FilterAction.EditableFilter.findEditable(uiObject);
    int i = findInEditableList(editableList, source);
    sb.append("while(!input(").append(i).append(", \"").append(source.getText()).append("\"));");
    source.recycle();
}
项目:RNLearn_Project1    文件:AccessibilityHelper.java   
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
  super.onInitializeAccessibilityNodeInfo(host, info);
  info.setClassName(RadioButton.class.getName());
  info.setCheckable(true);
  info.setChecked(false);
}
项目:QiangYixia    文件:HelpService.java   
private void WeChatUIRobRedMoney(AccessibilityNodeInfo nodeInfo) {
    if (isSelfSendMoney) {
        // 自己发的,回复一下数据
        detailGetMoneyOk = false;
        detailGetNameOk = false;
    }



    if (!isNotDO) {
        S(" 准备点击红包--");
        // 红包
        List<AccessibilityNodeInfo> redMoneyItems = nodeInfo.findAccessibilityNodeInfosByViewId(WechatVersionUtils.getWechatGetRedMoneyId(context));
        S("  redMoneyItems:" + redMoneyItems);
        if (redMoneyItems != null && redMoneyItems.size() > 0) {
            AccessibilityNodeInfo nodeInfo1 = redMoneyItems.get(redMoneyItems.size() - 1);
            S(" 要开始点击红包了:" + nodeInfo1.getText().toString());
            if (nodeInfo1.getText().toString().equals("查看红包")||nodeInfo1.getText().toString().equals("领取红包")) {
                // TODO 是否抢自己的红包
                boolean isRobSelf = true;
                if (!isRobSelf) {
                    return;
                }
                isSelfSendMoney = true;
            } else {
                isSelfSendMoney = false;
            }
            // TODO 随机延时 固定延时
            delayRob(nodeInfo1.getParent());
        }
    }
    isNotDO = false;
}
项目:UIAutomatorWD    文件:MUiDevice.java   
/**
 * Returns the first object to match the {@code selector} criteria.
 */
public UiObject2 findObject(Object selector) throws Exception {
    AccessibilityNodeInfo node;
    uiDevice.waitForIdle();
    node = ((NodeInfoList) selector).getNodeList().size() > 0 ? ((NodeInfoList) selector).getNodeList().get(0) : null;
    selector = By.clazz(node.getClassName().toString());
    if (node == null) {
        return null;
    }
    return doFindObject(selector, node);
}
项目:stynico    文件:AppCompatDlalog.java   
@SuppressLint("NewApi")
   private boolean fill()
   {
       AccessibilityNodeInfo rootNode = getRootInActiveWindow();
       if (rootNode != null)
{
    SharedPreferences sharedPreferences = getSharedPreferences("hook_Cosplay", AccessibilityService.MODE_PRIVATE); 
    String htmly = sharedPreferences.getString("io_kii", "");
           return findEditText(rootNode, htmly);
       }
       return false;
   }
项目:boohee_v5.6    文件:SurfaceRenderView.java   
@TargetApi(14)
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (VERSION.SDK_INT >= 14) {
        info.setClassName(SurfaceRenderView.class.getName());
    }
}
项目:PrivacyStreams    文件:AccessibilityUtils.java   
/**
 * Find out whether you are at the main page of chatting
 * @param root
 * @param appName
 * @return boolean whether you are at the main page of a chatting application or not
 */
public static boolean getMainPageSymbol(AccessibilityNodeInfo root, String appName){
    try{
        AccessibilityNodeInfo mainPage = root.findAccessibilityNodeInfosByViewId(getMainPageSymbolResourceId(appName)).get(0);
        if(mainPage!=null){
            return true;
        }
    }
    catch (Exception exception){
        return false;
    }
    return false;
}
项目:android_ui    文件:ButtonWidget.java   
/**
 */
@Override
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void onInitializeAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName(ButtonWidget.class.getName());
}
项目:PrivacyStreams    文件:AccessibilityUtils.java   
/**
 *
 * @param nodeInfoList is the complete list of node infos in a page.
 * @return the first webview node.
 */
public static String getWebViewTitle(List<AccessibilityNodeInfo> nodeInfoList) {
    for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
        Logging.debug(nodeInfo.getClassName().toString());
        if (nodeInfo.getClassName().equals(ANDROID_WEBVIEW_CLASSNAME)) {
            return nodeInfo.getContentDescription().toString();
        }else if (nodeInfo.getClassName().equals(ANDROID_VIEW_FIREFOXCLASSNAME)) {
            return nodeInfo.getText().toString();
        }
    }
    return null;
}
项目:GetRedPackets    文件:GetRedPacketService.java   
private void parseNodeInfoAndOpenGetPacketDialog(AccessibilityNodeInfo accessibilityNodeInfo){
    if(accessibilityNodeInfo != null && accessibilityNodeInfo.getChildCount() >0){
        for(int i = 0;i<accessibilityNodeInfo.getChildCount();i++){
            AccessibilityNodeInfo child = accessibilityNodeInfo.getChild(i);
            parseNodeInfoAndOpenGetPacketDialog(child);
        }
    }else{
        if(accessibilityNodeInfo != null && !TextUtils.isEmpty(accessibilityNodeInfo.getText())&&accessibilityNodeInfo.getText().toString().contains("领取红包")){
            Log.i(TAG,"领取红包");
            if(accessibilityNodeInfo.isClickable()){
                accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
            }else{
                AccessibilityNodeInfo parent  = accessibilityNodeInfo.getParent();
                while(parent != null ){
                    if(parent.isClickable()){
                        parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
                        break;
                    }

                    parent = parent.getParent();
                    Log.i(TAG," 找到一个可以点击的节点");
                }



            }

        }
    }

}