/**
* @param info 當前節點
* @param matchFlag 需要匹配的文字
* @param type 操作的類型
*/
public void recycle(AccessibilityNodeInfo info, String matchFlag, int type) {
if (info != null) {
if (info.getChildCount() == 0) {
CharSequence desrc = info.getContentDescription();
switch (type) {
case ENVELOPE_RETURN://返回
if (desrc != null && matchFlag.equals(info.getContentDescription().toString().trim())) {
if (info.isCheckable()) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
} else {
performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
}
}
break;
}
} else {
int size = info.getChildCount();
for (int i = 0; i < size; i++) {
AccessibilityNodeInfo childInfo = info.getChild(i);
if (childInfo != null) {
Log.e(TAG, "index: " + i + " info" + childInfo.getClassName() + " : " + childInfo.getContentDescription()+" : "+info.getText());
recycle(childInfo, matchFlag, type);
}
}
}
}
}