本文整理汇总了Java中android.accessibilityservice.AccessibilityService.getRootInActiveWindow方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityService.getRootInActiveWindow方法的具体用法?Java AccessibilityService.getRootInActiveWindow怎么用?Java AccessibilityService.getRootInActiveWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.accessibilityservice.AccessibilityService
的用法示例。
在下文中一共展示了AccessibilityService.getRootInActiveWindow方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performBack
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
/**
* 返回事件
*/
public static void performBack(final AccessibilityService service, AccessibilityNodeInfo nodeInfo) {
CharSequence packageName = nodeInfo.getPackageName();
if (!(packageName+"").equals(WECHAT_PACKAGE_NAME)) {
L.d("不是微信,不能后退 " + packageName);
return;
}
if (service == null) {
L.e("performBackWithDelay service is null");
return;
}
if (service.getRootInActiveWindow() == null) {
L.e("performBackWithDelay rootNode is null");
return;
}
L.d("performBack Reboot ");
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
}
示例2: findTextAndClick
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
/**
* 在当前页面查找文字内容并点击
*
* @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;
}
}
}
}
示例3: findViewIdAndClick
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
/**
* 检查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;
}
}
}
}
示例4: findDialogAndClick
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
/**
* 在当前页面查找对话框文字内容并点击
*
* @param text1 默认点击text1
* @param text2
*/
public static void findDialogAndClick(AccessibilityService accessibilityService, String text1, String text2) {
AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
if (accessibilityNodeInfo == null) {
return;
}
List<AccessibilityNodeInfo> dialogWait = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text1);
List<AccessibilityNodeInfo> dialogConfirm = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text2);
if (!dialogWait.isEmpty() && !dialogConfirm.isEmpty()) {
for (AccessibilityNodeInfo nodeInfo : dialogWait) {
if (nodeInfo != null && text1.equals(nodeInfo.getText())) {
performClick(nodeInfo);
break;
}
}
}
}
示例5: fineNodeByIdAndTextCheck
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
public static AccessibilityNodeInfo fineNodeByIdAndTextCheck(AccessibilityNodeInfo node,String id,String text,
AccessibilityService context,Map<String,String> record, String recordAction){
AccessibilityNodeInfo result = null;
int count=0;
while (count<6){
node = context.getRootInActiveWindow();
if(text==null){
result = findNodeInfosById(node,id);
}else if(id==null){
result = findNodeInfosByText(node,text);
}else{
result = fineNodeByIdAndText(node,id,text);
}
if(result!=null)
break;
count = count +1;
sleep(500*count);
}
if(result==null)
recordAndLog(record,recordAction);
return result;
}
示例6: click
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
@Override
public void click(AccessibilityService context, AccessibilityEvent event, WeChatLuckMoney money) {
System.out.println("StateMoneyReceived");
money.sleep();
AccessibilityNodeInfo info = context.getRootInActiveWindow();
if (info == null) {
System.out.println("StateMoneyReceived is null");
back(context, money);
return;
}
List<AccessibilityNodeInfo> node3 = info.findAccessibilityNodeInfosByText("红包详情");
List<AccessibilityNodeInfo> node4 = info.findAccessibilityNodeInfosByText("手慢了");
if (!node3.isEmpty() || !node4.isEmpty()) {
System.out.println("StateMoneyReceived has 红包详情");
back(context, money);
}
money.setState(money.messageComing);
}
示例7: performHome
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
/**
* 返回事件
*/
public static void performHome(final AccessibilityService service) {
if (service == null) {
L.e("performBackWithDelay service is null");
return;
}
if (service.getRootInActiveWindow() == null) {
L.e("performBackWithDelay rootNode is null");
return;
}
L.d("performHome");
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
}
示例8: performClickAndExpect
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
public static void performClickAndExpect(AccessibilityNodeInfo nodeInfo,Map<String,String> record, String recordAction
,AccessibilityService context,AccessibilityNodeInfo rootNode,String id,String text) {
performClick(nodeInfo,record,recordAction);
if(rootNode==null) return;
rootNode = context.getRootInActiveWindow();
if(id!=null&&text!=null){
}
}
示例9: getFocusedNode
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
public static AccessibilityNodeInfoCompat getFocusedNode(
AccessibilityService service, boolean fallbackOnRoot) {
AccessibilityNodeInfo root =
service.getRootInActiveWindow();
AccessibilityNodeInfo focused = null;
try {
AccessibilityNodeInfo ret = null;
if (root != null) {
focused = root.findFocus(
AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
if (focused != null && focused.isVisibleToUser()) {
ret = focused;
focused = null;
} else if (fallbackOnRoot) {
ret = root;
root = null;
}
} else {
LogUtils.log(service, Log.ERROR, "No current window root");
}
if (ret != null) {
return new AccessibilityNodeInfoCompat(ret);
}
} finally {
if (root != null) {
root.recycle();
}
if (focused != null) {
focused.recycle();
}
}
return null;
}
示例10: getRootInActiveWindow
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
/**
* @return root node of the Application window
*/
public static AccessibilityNodeInfoCompat getRootInActiveWindow(AccessibilityService service) {
if(service == null) return null;
AccessibilityNodeInfo root = service.getRootInActiveWindow();
if (root == null) return null;
return new AccessibilityNodeInfoCompat(root);
}
示例11: getRootInAccessibilityFocusedWindow
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
/**
* @return root node of the window that currently has accessibility focus
*/
public static AccessibilityNodeInfoCompat getRootInAccessibilityFocusedWindow(
AccessibilityService service) {
if (service == null) {
return null;
}
AccessibilityNodeInfo focusedRoot = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
List<AccessibilityWindowInfo> windows = service.getWindows();
// Create window manager with fake value of isInRTL = false. This is okay here since
// isInRTL will not change the result of getCurrentWindow.
WindowManager manager = new WindowManager(false /* isInRTL */);
manager.setWindows(windows);
AccessibilityWindowInfo accessibilityFocusedWindow =
manager.getCurrentWindow(false /* useInputFocus */);
if (accessibilityFocusedWindow != null) {
focusedRoot = accessibilityFocusedWindow.getRoot();
}
}
if (focusedRoot == null) {
focusedRoot = service.getRootInActiveWindow();
}
if (focusedRoot == null) {
return null;
}
return new AccessibilityNodeInfoCompat(focusedRoot);
}
示例12: getFocusedNode
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
public static AccessibilityNodeInfoCompat getFocusedNode(AccessibilityService service,
boolean fallbackOnRoot) {
AccessibilityNodeInfo root = service.getRootInActiveWindow();
AccessibilityNodeInfo focused = null;
try {
AccessibilityNodeInfo ret = null;
if (root != null) {
focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
if (focused != null && focused.isVisibleToUser()) {
ret = focused;
focused = null;
} else if (fallbackOnRoot) {
ret = root;
root = null;
}
} else {
LogUtils.log(service, Log.ERROR, "No current window root");
}
if (ret != null) {
return new AccessibilityNodeInfoCompat(ret);
}
} finally {
if (root != null) {
root.recycle();
}
if (focused != null) {
focused.recycle();
}
}
return null;
}
示例13: click
import android.accessibilityservice.AccessibilityService; //导入方法依赖的package包/类
@Override
public void click(AccessibilityService context, AccessibilityEvent event, WeChatLuckMoney money) {
System.out.println("StateMoneyOpen");
money.sleep();
AccessibilityNodeInfo info = context.getRootInActiveWindow();
if (info == null) {
System.out.println("StateMoneyOpen info is null");
back(context, money);
return;
}
List<AccessibilityNodeInfo> node = info.findAccessibilityNodeInfosByText("拆红包");
final int size = node.size();
System.out.println("StateMoneyOpen size:" + size);
if (size > 0) {
System.out.println("StateMoneyOpen open money");
AccessibilityNodeInfo cellNode = node.get(size - 1);
money.sleep();
cellNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
cellNode.recycle();
money.setState(money.moneyReceived);
} else {
System.out.println("StateMoneyOpen no open money");
List<AccessibilityNodeInfo> node3 = info.findAccessibilityNodeInfosByText("红包详情");
List<AccessibilityNodeInfo> node4 = info.findAccessibilityNodeInfosByText("手慢了");
if (!node3.isEmpty() || !node4.isEmpty()) {
System.out.println("StateMoneyOpen has 红包详情");
back(context, money);
} else {
System.out.println("StateMoneyOpen not has 红包详情");
money.setState(money.messageComing);
}
// back (context, money);
}
}