Search in sources :

Example 16 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.

the class UiObject method getContentDescription.

/**
     * Reads the <code>content_desc</code> property of the UI element
     *
     * @return value of node attribute "content_desc"
     * @throws UiObjectNotFoundException
     * @since API Level 16
     */
public String getContentDescription() throws UiObjectNotFoundException {
    Tracer.trace();
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
    if (node == null) {
        throw new UiObjectNotFoundException(getSelector().toString());
    }
    return safeStringReturn(node.getContentDescription());
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 17 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.

the class UiObject method getVisibleBounds.

/**
     * Finds the visible bounds of a partially visible UI element
     *
     * @param node
     * @return null if node is null, else a Rect containing visible bounds
     */
private Rect getVisibleBounds(AccessibilityNodeInfo node) {
    if (node == null) {
        return null;
    }
    // targeted node's bounds
    int w = UiDevice.getInstance().getDisplayWidth();
    int h = UiDevice.getInstance().getDisplayHeight();
    Rect nodeRect = AccessibilityNodeInfoHelper.getVisibleBoundsInScreen(node, w, h);
    // is the targeted node within a scrollable container?
    AccessibilityNodeInfo scrollableParentNode = getScrollableParent(node);
    if (scrollableParentNode == null) {
        // nothing to adjust for so return the node's Rect as is
        return nodeRect;
    }
    // Scrollable parent's visible bounds
    Rect parentRect = AccessibilityNodeInfoHelper.getVisibleBoundsInScreen(scrollableParentNode, w, h);
    // adjust for partial clipping of targeted by parent node if required
    if (nodeRect.intersect(parentRect)) {
        return nodeRect;
    } else {
        // Node rect has no intersection with parent Rect
        return new Rect();
    }
}
Also used : Rect(android.graphics.Rect) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Point(android.graphics.Point)

Example 18 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project qianghongbao by lendylongli.

the class WechatAccessbilityJob method handleChatListHongBao.

/**
     * 收到聊天里的红包
     * */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void handleChatListHongBao() {
    int mode = getConfig().getWechatMode();
    if (mode == Config.WX_MODE_3) {
        //只通知模式
        return;
    }
    AccessibilityNodeInfo nodeInfo = getService().getRootInActiveWindow();
    if (nodeInfo == null) {
        Log.w(TAG, "rootWindow为空");
        return;
    }
    if (mode != Config.WX_MODE_0) {
        boolean isMember = isMemberChatUi(nodeInfo);
        if (mode == Config.WX_MODE_1 && isMember) {
            //过滤群聊
            return;
        } else if (mode == Config.WX_MODE_2 && !isMember) {
            //过滤单聊
            return;
        }
    }
    List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText("领取红包");
    if (list != null && list.isEmpty()) {
        // 从消息列表查找红包
        AccessibilityNodeInfo node = AccessibilityHelper.findNodeInfosByText(nodeInfo, "[微信红包]");
        if (node != null) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "-->微信红包:" + node);
            }
            isReceivingHongbao = true;
            AccessibilityHelper.performClick(nodeInfo);
        }
    } else if (list != null) {
        if (isReceivingHongbao) {
            //最新的红包领起
            AccessibilityNodeInfo node = list.get(list.size() - 1);
            AccessibilityHelper.performClick(node);
            isReceivingHongbao = false;
        }
    }
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) TargetApi(android.annotation.TargetApi)

Example 19 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project WeChatLuckyMoney by geeeeeeeeek.

the class HongbaoService method checkNodeInfo.

private void checkNodeInfo(int eventType) {
    if (this.rootNodeInfo == null)
        return;
    if (signature.commentString != null) {
        sendComment();
        signature.commentString = null;
    }
    /* 聊天会话窗口,遍历节点匹配“领取红包”和"查看红包" */
    AccessibilityNodeInfo node1 = (sharedPreferences.getBoolean("pref_watch_self", false)) ? this.getTheLastNode(WECHAT_VIEW_OTHERS_CH, WECHAT_VIEW_SELF_CH) : this.getTheLastNode(WECHAT_VIEW_OTHERS_CH);
    if (node1 != null && (currentActivityName.contains(WECHAT_LUCKMONEY_CHATTING_ACTIVITY) || currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY))) {
        String excludeWords = sharedPreferences.getString("pref_watch_exclude_words", "");
        if (this.signature.generateSignature(node1, excludeWords)) {
            mLuckyMoneyReceived = true;
            mReceiveNode = node1;
            Log.d("sig", this.signature.toString());
        }
        return;
    }
    /* 戳开红包,红包还没抢完,遍历节点匹配“拆红包” */
    AccessibilityNodeInfo node2 = findOpenButton(this.rootNodeInfo);
    if (node2 != null && "android.widget.Button".equals(node2.getClassName()) && currentActivityName.contains(WECHAT_LUCKMONEY_RECEIVE_ACTIVITY)) {
        mUnpackNode = node2;
        mUnpackCount += 1;
        return;
    }
    /* 戳开红包,红包已被抢完,遍历节点匹配“红包详情”和“手慢了” */
    boolean hasNodes = this.hasOneOfThoseNodes(WECHAT_BETTER_LUCK_CH, WECHAT_DETAILS_CH, WECHAT_BETTER_LUCK_EN, WECHAT_DETAILS_EN, WECHAT_EXPIRES_CH);
    if (mMutex && eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && hasNodes && (currentActivityName.contains(WECHAT_LUCKMONEY_DETAIL_ACTIVITY) || currentActivityName.contains(WECHAT_LUCKMONEY_RECEIVE_ACTIVITY))) {
        mMutex = false;
        mLuckyMoneyPicked = false;
        mUnpackCount = 0;
        performGlobalAction(GLOBAL_ACTION_BACK);
        signature.commentString = generateCommentString();
    }
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 20 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project WeChatLuckyMoney by geeeeeeeeek.

the class HongbaoService method sendComment.

private void sendComment() {
    try {
        AccessibilityNodeInfo outNode = getRootInActiveWindow().getChild(0).getChild(0);
        AccessibilityNodeInfo nodeToInput = outNode.getChild(outNode.getChildCount() - 1).getChild(0).getChild(1);
        if ("android.widget.EditText".equals(nodeToInput.getClassName())) {
            Bundle arguments = new Bundle();
            arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, signature.commentString);
            nodeToInput.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
        }
    } catch (Exception e) {
    // Not supported
    }
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Bundle(android.os.Bundle)

Aggregations

AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)310 Point (android.graphics.Point)84 Rect (android.graphics.Rect)84 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)45 RemoteException (android.os.RemoteException)30 IAccessibilityInteractionConnectionCallback (android.view.accessibility.IAccessibilityInteractionConnectionCallback)30 SomeArgs (com.android.internal.os.SomeArgs)30 Region (android.graphics.Region)25 Paint (android.graphics.Paint)19 View (android.view.View)12 ViewRootImpl (android.view.ViewRootImpl)11 RemoteView (android.widget.RemoteViews.RemoteView)11 Display (android.view.Display)10 File (java.io.File)10 LinkedList (java.util.LinkedList)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 UiAutomation (android.app.UiAutomation)5 InputFilter (android.text.InputFilter)5 TextPaint (android.text.TextPaint)5