Java Code Examples for android.view.accessibility.AccessibilityNodeInfo

The following are top voted examples for showing how to use android.view.accessibility.AccessibilityNodeInfo. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: adb-install-robot   File: AutoInstallAccessibilityService.java   Source Code and License 8 votes vote down vote up
@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;
    }
}
 
Example 2
Project: QiangHongBao   File: WeChatAccessibilityJob.java   Source Code and License 7 votes vote down vote up
/** 是否为群聊天 */
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;
}
 
Example 3
Project: DateTimePicker   File: NumberPicker.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 4
Project: keepass2android   File: AutoFillService.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 5
Project: https-github.com-hyb1996-NoRootScriptDroid   File: ActionFactory.java   Source Code and License 6 votes vote down vote up
@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);
        }
    };
}
 
Example 6
Project: ReplyMessage   File: PerformClickUtils.java   Source Code and License 6 votes vote down vote up
/**
 * 在当前页面查找文字内容并点击
 *
 * @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;
            }
        }
    }
}
 
Example 7
Project: miser-utils   File: ComeOnMoneyService.java   Source Code and License 6 votes vote down vote up
@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);
    }
}
 
Example 8
Project: Accessibility   File: BaseAccessibility.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 9
Project: PreviewSeekBar-master   File: CustomTimeBar.java   Source Code and License 6 votes vote down vote up
@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);
    }
}
 
Example 10
Project: stynico   File: AnimatedEditText.java   Source Code and License 6 votes vote down vote up
/**
    * 爬遍所有节点查找可点的按钮,用于解决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);
    }

}
   }
 
Example 11
Project: DateTimePicker   File: RadialTimePickerView.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 12
Project: AutoInteraction-Library   File: UiTree.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 13
Project: Auto.js   File: AccessibilityNodeInfoHelper.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 14
Project: QiangHongBao   File: QQAccessibilityJob.java   Source Code and License 6 votes vote down vote up
/** 查看领取详情或者返回 */
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();
    }
}
 
Example 15
Project: ReplyMessage   File: PerformClickUtils.java   Source Code and License 6 votes vote down vote up
/**
 * 检查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;
            }
        }
    }
}
 
Example 16
Project: weixin_auto   File: ParseRootUtil.java   Source Code and License 6 votes vote down vote up
/**
 * 封装节点属性
 * @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;
}
 
Example 17
Project: Auto.js   File: AccessibilityActionConverter.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 18
Project: https-github.com-hyb1996-NoRootScriptDroid   File: LayoutInspector.java   Source Code and License 5 votes vote down vote up
@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));
    }
}
 
Example 19
Project: TPlayer   File: AceHelper.java   Source Code and License 5 votes vote down vote up
/**
 * 通过文本查找节点(注: 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);
}
 
Example 20
Project: letv   File: AbsHListView.java   Source Code and License 5 votes vote down vote up
@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);
        }
    }
}
 
Example 21
Project: stynico   File: dex_smali.java   Source Code and License 5 votes vote down vote up
/**
    * 获取一个可以点击的节点
    */
   private AccessibilityNodeInfo getClickableNode(AccessibilityNodeInfo node)
   {
AccessibilityNodeInfo parent=node;
while (parent != null)
{
    if (parent.isClickable())
    {
	break;
    }
    parent = parent.getParent();
}
return parent;
   }
 
Example 22
Project: PrivacyStreams   File: AccessibilityUtils.java   Source Code and License 5 votes vote down vote up
/**
 *
 * @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<>();
}
 
Example 23
Project: AutoInteraction-Library   File: UiTree.java   Source Code and License 5 votes vote down vote up
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();
}
 
Example 24
Project: android_ui   File: ViewPagerWidget.java   Source Code and License 5 votes vote down vote up
/**
 */
@Override
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void onInitializeAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo info) {
	super.onInitializeAccessibilityNodeInfo(info);
	info.setClassName(ViewPagerWidget.class.getName());
}
 
Example 25
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityNodeInfoAllocator.java   Source Code and License 5 votes vote down vote up
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();
        }
    }
}
 
Example 26
Project: CSipSimple   File: IcsAdapterView.java   Source Code and License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setScrollable(isScrollableForAccessibility());
    View selectedView = getSelectedView();
    if (selectedView != null) {
        info.setEnabled(selectedView.isEnabled());
    }
}
 
Example 27
Project: espresso-support   File: AccessibilityViewMatchers.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 28
Project: pc-android-controller-android   File: AccessUtil.java   Source Code and License 5 votes vote down vote up
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();
}
 
Example 29
Project: PrivacyStreams   File: AccessibilityUtils.java   Source Code and License 5 votes vote down vote up
/**
 *
 * @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;
}
 
Example 30
Project: WeChatLuckyMoney   File: HongbaoSignature.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 31
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityActionConverter.java   Source Code and License 5 votes vote down vote up
@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();
}
 
Example 32
Project: RNLearn_Project1   File: AccessibilityHelper.java   Source Code and License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
  super.onInitializeAccessibilityNodeInfo(host, info);
  info.setClassName(RadioButton.class.getName());
  info.setCheckable(true);
  info.setChecked(false);
}
 
Example 33
Project: QiangYixia   File: HelpService.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 34
Project: UIAutomatorWD   File: MUiDevice.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 35
Project: stynico   File: AppCompatDlalog.java   Source Code and License 5 votes vote down vote up
@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;
   }
 
Example 36
Project: boohee_v5.6   File: SurfaceRenderView.java   Source Code and License 5 votes vote down vote up
@TargetApi(14)
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (VERSION.SDK_INT >= 14) {
        info.setClassName(SurfaceRenderView.class.getName());
    }
}
 
Example 37
Project: PrivacyStreams   File: AccessibilityUtils.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
}
 
Example 38
Project: android_ui   File: ButtonWidget.java   Source Code and License 5 votes vote down vote up
/**
 */
@Override
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void onInitializeAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo info) {
	super.onInitializeAccessibilityNodeInfo(info);
	info.setClassName(ButtonWidget.class.getName());
}
 
Example 39
Project: PrivacyStreams   File: AccessibilityUtils.java   Source Code and License 5 votes vote down vote up
/**
 *
 * @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;
}
 
Example 40
Project: GetRedPackets   File: GetRedPacketService.java   Source Code and License 5 votes vote down vote up
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," 找到一个可以点击的节点");
                }



            }

        }
    }

}