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());
}
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();
}
}
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;
}
}
}
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();
}
}
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
}
}
Aggregations