Commit 9dc3c589 by jeffrey

v1.5.7

parent 5720b9bd
...@@ -22,8 +22,8 @@ android { ...@@ -22,8 +22,8 @@ android {
applicationId versions.applicationId applicationId versions.applicationId
minSdkVersion versions.minSdkVersion minSdkVersion versions.minSdkVersion
targetSdkVersion versions.targetSdkVersion targetSdkVersion versions.targetSdkVersion
versionCode 8 versionCode 9
versionName "1.5.5" versionName "1.5.7"
multiDexEnabled true multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// externalNativeBuild { // externalNativeBuild {
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<service <service
android:name=".WXCService" android:name=".NewService"
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
android:label="@string/app_name" android:label="@string/app_name"
......
...@@ -56,27 +56,13 @@ import static com.xf.weixinclick.receiver.WeChatStatus.needClick4; ...@@ -56,27 +56,13 @@ import static com.xf.weixinclick.receiver.WeChatStatus.needClick4;
public class NewService extends AccessibilityService { public class NewService extends AccessibilityService {
private static final String TAG = NewService.class.getSimpleName(); private static final String TAG = NewService.class.getSimpleName();
private final String WeChatUi = "com.tencent.mm.ui.LauncherUI";
private final String WeChatWebView = "com.tencent.mm.plugin.webview.ui.tools.WebViewUI";
private final String WeChatAlert = "com.tencent.mm.ui.base.m";
private final static String MM_PNAME = "com.tencent.mm";
public static final String PARAMS_MSG = "msg";
public static final String PARAMS_MSG = "msg";
// private String Url = "https://weapp-dev.wangjia.com/qr.jpg?dd=1";
private String message_id = "123";
private DelayBean delayBean;
// private ReceiverMsg taskMsg;
/**
* 当前任务的步骤,完成一步+1
*/
private int step = 0;
long times = 0;
long lastShowToastTime ;
/** /**
* 因为首次进来的时候检测到不是首页的时候也会返回,所以用step的话不准确,要单独弄个变量出来 * 因为首次进来的时候检测到不是首页的时候也会返回,所以用step的话不准确,要单独弄个变量出来
...@@ -98,15 +84,6 @@ public class NewService extends AccessibilityService { ...@@ -98,15 +84,6 @@ public class NewService extends AccessibilityService {
public void onAccessibilityEvent(AccessibilityEvent event) { public void onAccessibilityEvent(AccessibilityEvent event) {
Log.d(TAG, "NewService onAccessibilityEvent"); Log.d(TAG, "NewService onAccessibilityEvent");
// long currentTime = System.currentTimeMillis();
// if (currentTime - lastShowToastTime > 10 *1000){
// boolean taskMsgExist = taskMsg == null ;
// String taskMsgPrompt = taskMsgExist ? "消息是空":"消息存在";
// logToastAndUpload(TAG,"辅助service还活着 step = " + step + " " + taskMsgPrompt);
// lastShowToastTime = currentTime;
// }
if (mWorker == null){ if (mWorker == null){
mWorker = Worker2.getInstance(); mWorker = Worker2.getInstance();
} }
...@@ -124,260 +101,94 @@ public class NewService extends AccessibilityService { ...@@ -124,260 +101,94 @@ public class NewService extends AccessibilityService {
/** // /**
* 点击确认执行关注 // * 点击确认执行关注
*/ // */
void pressSure() { // void pressSure() {
List<AccessibilityNodeInfo> data1 = getRootInActiveWindow() // List<AccessibilityNodeInfo> data1 = getRootInActiveWindow()
.findAccessibilityNodeInfosByText(needClick2); // .findAccessibilityNodeInfosByText(needClick2);
List<AccessibilityNodeInfo> data2 = getRootInActiveWindow() // List<AccessibilityNodeInfo> data2 = getRootInActiveWindow()
.findAccessibilityNodeInfosByText(needClick3); // .findAccessibilityNodeInfosByText(needClick3);
List<AccessibilityNodeInfo> data3 = getRootInActiveWindow() // List<AccessibilityNodeInfo> data3 = getRootInActiveWindow()
.findAccessibilityNodeInfosByText(needClick4); // .findAccessibilityNodeInfosByText(needClick4);
AccessibilityNodeInfo findNode = null; // AccessibilityNodeInfo findNode = null;
if (data1 != null && data1.size() > 0) { // if (data1 != null && data1.size() > 0) {
findNode = data1.get(0); // findNode = data1.get(0);
} else if (data2 != null && data2.size() > 0) { // } else if (data2 != null && data2.size() > 0) {
findNode = data1.get(0); // findNode = data1.get(0);
} else if (data3 != null && data3.size() > 0) {
findNode = data1.get(0);
}
if (findNode == null) {
logToastAndUpload(TAG, String.format("没有根据文字找到确认"));
int delayTime = delayBean.getAfter_click_decode_button_delay();
delayDeal(delayTime, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d(TAG, String.format("确认页的第一个点击"));
execShellCmd("input tap " + dip2px(40) + " " + dip2px(315));
}
});
delayDeal(delayTime+1000, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d(TAG, String.format("确认页的第2个点击"));
execShellCmd("input tap " + dip2px(40) + " " + dip2px(375));
}
});
delayDeal(delayTime+1500, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d(TAG, String.format("确认页的第3个点击"));
execShellCmd("input tap " + dip2px(40) + " " + dip2px(430));
}
});
delayDeal(delayTime+delayBean.getAfter_click_confirm_button_delay(), new IDelayMethord() {
@Override
public void delayMethord() {
Log.d(TAG, String.format("确认页的最终超时确认"));
}
});
} else {
logToastAndUpload(TAG, String.format("根据文字找到确认了"));
final AccessibilityNodeInfo finalFindNode = findNode;
delayDeal(2000, new IDelayMethord() {
@Override
public void delayMethord() {
Rect rect = new Rect();
finalFindNode.getBoundsInScreen(rect);
final float x = rect.left + dip2px(5), y = rect.top + dip2px(5);
execShellCmd("input tap " + x + " " + y);
}
});
delayDeal(3000, new IDelayMethord() {
@Override
public void delayMethord() {
}
});
}
}
/**
* 点击消息
*
* @param rootNode
*/
// @SuppressLint("NewApi")
// private void clickMsg(AccessibilityNodeInfo rootNode) {
// long temp = System.currentTimeMillis();
// if (temp - times < 2000) {
// times = temp;
// return;
// }
// if (rootNode == null) {
// return;
// }
// //
// List<AccessibilityNodeInfo> ac2 = rootNode.findAccessibilityNodeInfosByText(taskMsg.getQr_addr()); // } else if (data3 != null && data3.size() > 0) {
//// List<AccessibilityNodeInfo> ac = rootNode.findAccessibilityNodeInfosByViewId("@id/ji"); // findNode = data1.get(0);
// List<AccessibilityNodeInfo> ac = rootNode.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/ji");
// AccessibilityNodeInfo n = null;
// if (ac.size() > 0) {
// n = ac.get(ac.size() - 1);
// }
// if (ac2.size() > 0) {
// n = ac2.get(ac2.size() - 1);
// } // }
// //
// if (n != null) { // if (findNode == null) {
//// final AccessibilityNodeInfo n = ac.get(ac.size() - 1); // logToastAndUpload(TAG, String.format("没有根据文字找到确认"));
// int delayTime = delayBean.getAfter_click_decode_button_delay();
//
// delayDeal(delayTime, new IDelayMethord() {
// @Override
// public void delayMethord() {
// Log.d(TAG, String.format("确认页的第一个点击"));
//
// execShellCmd("input tap " + dip2px(40) + " " + dip2px(315));
// }
// });
// //
// Rect rect = new Rect(); // delayDeal(delayTime+1000, new IDelayMethord() {
// n.getBoundsInScreen(rect); // @Override
// final float x = rect.left + dip2px(40), y = rect.top + dip2px(20); // public void delayMethord() {
// Log.d(TAG, String.format("click %f %f ", x, y)); // Log.d(TAG, String.format("确认页的第2个点击"));
// execShellCmd("input tap " + dip2px(40) + " " + dip2px(375));
// }
// });
// delayDeal(delayTime+1500, new IDelayMethord() {
// @Override
// public void delayMethord() {
// Log.d(TAG, String.format("确认页的第3个点击"));
// execShellCmd("input tap " + dip2px(40) + " " + dip2px(430));
// }
// });
// //
// execShellCmd("input tap " + x + " " + y); // delayDeal(delayTime+delayBean.getAfter_click_confirm_button_delay(), new IDelayMethord() {
// @Override
// public void delayMethord() {
// Log.d(TAG, String.format("确认页的最终超时确认"));
//
// }
// });
// } else { // } else {
// Log.d(TAG, "找不到消息 消息url" + taskMsg.getQr_addr()); // logToastAndUpload(TAG, String.format("根据文字找到确认了"));
// execShellCmd("input tap " + dip2px(100) + " " + dip2px(540)); //
// final AccessibilityNodeInfo finalFindNode = findNode;
// delayDeal(2000, new IDelayMethord() {
// @Override
// public void delayMethord() {
// Rect rect = new Rect();
// finalFindNode.getBoundsInScreen(rect);
// final float x = rect.left + dip2px(5), y = rect.top + dip2px(5);
// execShellCmd("input tap " + x + " " + y);
// }
// });
//
// delayDeal(3000, new IDelayMethord() {
// @Override
// public void delayMethord() {
//
// }
// });
// //
// } // }
//
// } // }
//
//
//
//
/**
* 执行shell命令
*
* @param cmd
*/
private void execShellCmd(String cmd) {
Log.d(TAG, "execShellCmd " + cmd);
try {
// 申请获取root权限,这一步很重要,不然会没有作用
Process process = Runtime.getRuntime().exec("su");
// 获取输出流
OutputStream outputStream = process.getOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream(
outputStream);
dataOutputStream.writeBytes(cmd);
dataOutputStream.flush();
dataOutputStream.close();
outputStream.close();
} catch (Throwable t) {
t.printStackTrace();
//报错说明权限没有
logToastAndUpload(TAG,"没有root权限,点击失败");
}
}
/**
* 寻找窗体中的“发送”按钮,并且点击。
*/
@SuppressLint("NewApi")
private void send() {
AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
if (nodeInfo != null) {
List<AccessibilityNodeInfo> list = nodeInfo
.findAccessibilityNodeInfosByText("发送");
if (list != null && list.size() > 0) {
for (AccessibilityNodeInfo n : list) {
n.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
} else {
List<AccessibilityNodeInfo> liste = nodeInfo
.findAccessibilityNodeInfosByText("Send");
if (liste != null && liste.size() > 0) {
for (AccessibilityNodeInfo n : liste) {
n.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
}
// pressBackButton();
}
}
/**
* 模拟back按键
*/
private void pressBackButton() {
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("input keyevent " + KeyEvent.KEYCODE_BACK);
} catch (IOException e) {
e.printStackTrace();
}
}
// @SuppressLint("NewApi")
// private boolean fill() {
// AccessibilityNodeInfo rootNode = getRootInActiveWindow();
// if (rootNode != null && taskMsg != null) {
// return findEditText(rootNode, taskMsg.getQr_addr());
// }
// return false;
// }
private boolean findEditText(AccessibilityNodeInfo rootNode, String content) {
int count = rootNode.getChildCount();
for (int i = 0; i < count; i++) {
AccessibilityNodeInfo nodeInfo = rootNode.getChild(i);
if (nodeInfo == null) {
continue;
}
if ("android.widget.EditText".equals(nodeInfo.getClassName())) {
Log.d(TAG,"填充的内容 " + content);
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
true);
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
arguments);
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
ClipData clip = ClipData.newPlainText("label", content);
ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboardManager.setPrimaryClip(clip);
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_PASTE);
return true;
}
if (findEditText(nodeInfo, content)) {
return true;
}
}
return false;
}
private void delayDeal(long time, final IDelayMethord iDelayMethord) {
Observable.timer(time, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.map(new Func1<Long, Object>() {
@Override
public Object call(Long aLong) {
iDelayMethord.delayMethord();
return null;
}
})
.subscribe();
}
public static int dip2px(float dpValue) {
float scale = myApplication.getInstence().getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5F);
}
interface IDelayMethord { interface IDelayMethord {
void delayMethord(); void delayMethord();
...@@ -397,17 +208,7 @@ public class NewService extends AccessibilityService { ...@@ -397,17 +208,7 @@ public class NewService extends AccessibilityService {
} }
} }
// public boolean isHome(){
// int count = getRootInActiveWindow().getChildCount();
// for (int i = 0 ; i < count ; i++){
// AccessibilityNodeInfo nodeInfo = getRootInActiveWindow().getChild(i);
// boolean isFind = recycle(nodeInfo,"通讯录");
// if (isFind){
// return true;
// }
// }
// return false;
// }
public AccessibilityNodeInfo recycle(AccessibilityNodeInfo info,String searchText) { public AccessibilityNodeInfo recycle(AccessibilityNodeInfo info,String searchText) {
if (info.getChildCount() == 0) { if (info.getChildCount() == 0) {
// Log.i(TAG, "child widget----------------------------" + info.getClassName()); // Log.i(TAG, "child widget----------------------------" + info.getClassName());
...@@ -463,34 +264,8 @@ public class NewService extends AccessibilityService { ...@@ -463,34 +264,8 @@ public class NewService extends AccessibilityService {
} }
public static boolean findNodeByTexts(AccessibilityService service,String ... text){
boolean isFind = true;
for (String oneText : text){
boolean oneFind = findNodeByText(service,oneText);
if (!oneFind){
isFind = false;
Log.d(TAG,"findNodeByTexts not find " + oneText );
break;
}
}
return isFind;
}
public static boolean findNodeByText(AccessibilityService service,String text){
AccessibilityNodeInfo nodeInfo = service.getRootInActiveWindow();
if (service == null || nodeInfo == null){
return false;
}
List<AccessibilityNodeInfo> node = nodeInfo.findAccessibilityNodeInfosByText(text);
if (node == null || node.size() == 0){
return false;
}
return true;
}
public static void showToast(final Context context, final String msg){ public static void showToast(final Context context, final String msg){
// "消息的 unique_id 是 " + msg.getUnique_id()
Observable.create(new Observable.OnSubscribe<String>() { Observable.create(new Observable.OnSubscribe<String>() {
@Override @Override
public void call(Subscriber<? super String> subscriber) { public void call(Subscriber<? super String> subscriber) {
...@@ -516,8 +291,13 @@ public class NewService extends AccessibilityService { ...@@ -516,8 +291,13 @@ public class NewService extends AccessibilityService {
if (TextUtils.isEmpty(name)){ if (TextUtils.isEmpty(name)){
return; return;
} }
String device_code = PushServiceFactory.getCloudPushService().getDeviceId();
if (TextUtils.isEmpty(device_code)){
return;
}
//不管成功还是失败 //不管成功还是失败
HttpClientApi.uploadDeviceLog(name, tag, msg, new Subscriber<String>() { HttpClientApi.uploadDeviceLog(device_code,name, tag, msg, new Subscriber<String>() {
@Override @Override
public void onCompleted() { public void onCompleted() {
......
package com.xf.weixinclick;
import android.accessibilityservice.AccessibilityService;
import android.graphics.Rect;
import android.text.TextUtils;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import java.util.List;
/**
* 创建日期:2018/4/16 on 11:43
* 描述:
* 作者:Li
*/
public class TestService extends AccessibilityService {
String TAG = TestService.class.getSimpleName();
@Override
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
Log.d(TAG,"包名 " + accessibilityEvent.getPackageName());
Log.d(TAG,"类名 " + accessibilityEvent.getClassName());
Log.d(TAG,"动作 " + accessibilityEvent.getAction());
if (accessibilityEvent.getClassName().toString().contains("ListView")){
// printAllNode();
}
AccessibilityNodeInfo nodeInfo = findByIdAndText(getRootInActiveWindow(),"com.tencent.mm:id/apv","文件传输助手");
if (nodeInfo == null){
Log.d(TAG,"没有找到");
}else {
Rect rect = new Rect();
nodeInfo.getBoundsInScreen(rect);
Log.d(TAG,"位置 = " + rect.left + " " + rect.top);
}
}
@Override
public void onInterrupt() {
}
private AccessibilityNodeInfo findByIdAndText(AccessibilityNodeInfo rootInActiveWindow, String id, String text){
List<AccessibilityNodeInfo> nodeInfos = rootInActiveWindow
.findAccessibilityNodeInfosByViewId(id);
if(isEmptyNodes(nodeInfos)){
return null;
}
for (AccessibilityNodeInfo nodeInfo : nodeInfos) {
if(TextUtils.equals(text,nodeInfo.getText())){
return nodeInfo;
}
}
return null;
}
private boolean isEmptyNodes(List<AccessibilityNodeInfo> nodeInfos){
return nodeInfos == null || nodeInfos.isEmpty();
}
public void printAllNode(){
AccessibilityNodeInfo root = getRootInActiveWindow();
if (root == null){
return;
}
int count = root.getChildCount();
for (int i = 0 ; i < count ; i++){
AccessibilityNodeInfo nodeInfo = root.getChild(i);
// recycle(nodeInfo);
}
}
}
...@@ -48,25 +48,13 @@ public class EnableAccessibility implements Callable<Boolean> { ...@@ -48,25 +48,13 @@ public class EnableAccessibility implements Callable<Boolean> {
Cmder.scrollDown(400); Cmder.scrollDown(400);
SystemClock.sleep(1000); SystemClock.sleep(1000);
Cmder.scrollDown(400); Cmder.scrollDown(400);
SystemClock.sleep(5000); SystemClock.sleep(6000);
// MotionRunner.get().scrollDown(800); // MotionRunner.get().scrollDown(800);
// SystemClock.sleep(1000); // SystemClock.sleep(1000);
Log.e(TAG, "exec --> 滑动 结束,搜索[无障碍]"); Log.e(TAG, "exec --> 滑动 结束,搜索[无障碍]");
int maxTry = 2; List<UiNode> nodes = findTextWithRetry("无障碍");
int currentTry = 0;
UiHierarchyFinder finder = null;
List<UiNode> nodes = null;
while (currentTry < maxTry && (nodes == null|| nodes.isEmpty())){
finder = new UiHierarchyFinder();
nodes = finder.dumpAndFindByName("无障碍");
Log.e(TAG, "第" + currentTry +"次,找到"+nodes.size()+"个节点");
currentTry ++;
}
if(nodes.isEmpty()){ if(nodes.isEmpty()){
DebugTools.log("没有在[设置]-[辅助功能]中找到 [无障碍]选项 !"); DebugTools.log("没有在[设置]-[辅助功能]中找到 [无障碍]选项 !");
...@@ -79,14 +67,12 @@ public class EnableAccessibility implements Callable<Boolean> { ...@@ -79,14 +67,12 @@ public class EnableAccessibility implements Callable<Boolean> {
Log.e(TAG, "点击第0个节点的位置"+bounds); Log.e(TAG, "点击第0个节点的位置"+bounds);
Cmder.clickPX(bounds.centerX(),bounds.centerY()); Cmder.clickPX(bounds.centerX(),bounds.centerY());
SystemClock.sleep(4000); SystemClock.sleep(5000);
//打开了无障碍页面 //打开了无障碍页面
//搜索家粉 //搜索家粉
Log.e(TAG, "跳转到无障碍服务列表页面,开始搜索[家粉]"); Log.e(TAG, "跳转到无障碍服务列表页面,开始搜索[家粉]");
finder = new UiHierarchyFinder(); nodes = findTextWithRetry("家粉");
SystemClock.sleep(4000);
nodes = finder.dumpAndFindByName("家粉");
if(nodes.isEmpty()){ if(nodes.isEmpty()){
Log.e(TAG, "没有在[无障碍]页面找到[家粉] 的辅助服务!"); Log.e(TAG, "没有在[无障碍]页面找到[家粉] 的辅助服务!");
...@@ -99,21 +85,21 @@ public class EnableAccessibility implements Callable<Boolean> { ...@@ -99,21 +85,21 @@ public class EnableAccessibility implements Callable<Boolean> {
bounds = nodes.get(0).getBounds(); bounds = nodes.get(0).getBounds();
Cmder.clickPX(bounds.centerX(),bounds.centerY()); Cmder.clickPX(bounds.centerX(),bounds.centerY());
SystemClock.sleep(4000); SystemClock.sleep(6000);
//如果正常 进入家粉辅助服务详情页面 //如果正常 进入家粉辅助服务详情页面
//判断是否跳转成功了,搜索辅助服务的描述 //判断是否跳转成功了,搜索辅助服务的描述
finder = new UiHierarchyFinder();
SystemClock.sleep(2000); SystemClock.sleep(2000);
nodes = finder.dumpAndFindByName("微信点击辅助服务");
nodes = findTextWithRetry("微信点击辅助服务");
if(nodes.isEmpty()){ if(nodes.isEmpty()){
Log.e(TAG, "没有正常打开 辅助服务详情 界面 !"); Log.e(TAG, "没有正常打开 辅助服务详情 界面 !");
throw new RuntimeException(" 没有正常打开 辅助服务详情 界面 !"); throw new RuntimeException(" 没有正常打开 辅助服务详情 界面 !");
}else { }else {
nodes = finder.findNodeByText("家粉"); nodes = findTextWithRetry("家粉");
if(nodes.isEmpty() || nodes.size() <= 1){ if(nodes.isEmpty() || nodes.size() <= 1){
throw new RuntimeException(" 没有正常打开 [辅助服务详情] 界面 !"); throw new RuntimeException(" 没有正常打开 [辅助服务详情] 界面 !");
...@@ -163,6 +149,20 @@ public class EnableAccessibility implements Callable<Boolean> { ...@@ -163,6 +149,20 @@ public class EnableAccessibility implements Callable<Boolean> {
} }
List<UiNode> findTextWithRetry(String text){
final int MAX_TRY = 3;
int currentTry = 0;
UiHierarchyFinder finder = null;
List<UiNode> nodes = null;
while (currentTry < MAX_TRY && (nodes == null|| nodes.isEmpty())){
finder = new UiHierarchyFinder();
nodes = finder.dumpAndFindByName(text);
Log.e(TAG, "第" + currentTry +"次查找"+text+",找到"+nodes.size()+"个节点");
currentTry ++;
SystemClock.sleep(2000);
}
return nodes;
}
private void startAct(){ private void startAct(){
Intent intent2 = new Intent( Intent intent2 = new Intent(
......
...@@ -44,8 +44,8 @@ public class Cmder { ...@@ -44,8 +44,8 @@ public class Cmder {
public static void clickNode(AccessibilityNodeInfo node){ public static void clickNode(AccessibilityNodeInfo node){
Rect rect = new Rect(); Rect rect = new Rect();
node.getBoundsInScreen(rect); node.getBoundsInScreen(rect);
int x = rect.left +Common.dip2px(10); int x = rect.left +Common.dip2px(15);
int y = rect.top +Common.dip2px(10); int y = rect.top +Common.dip2px(20);
execShellCmd(TAP_EVENT_CMD + x + " " + y); execShellCmd(TAP_EVENT_CMD + x + " " + y);
} }
......
...@@ -24,17 +24,17 @@ public class MsgSender { ...@@ -24,17 +24,17 @@ public class MsgSender {
@Override @Override
public void onSuccess(Boolean aBoolean) { public void onSuccess(Boolean aBoolean) {
if(aBoolean){ if(aBoolean){
Log.d(TAG,"开启无障碍成功"); NewService.logToastAndUpload(TAG,"开启无障碍成功 等待新任务");
EventBus.getDefault().post(msg); // EventBus.getDefault().post(msg);
}else { }else {
NewService.logToastAndUpload(TAG, "auto open AccessibilityService fail?"); NewService.logToastAndUpload(TAG, "开启无障碍失败");
} }
} }
@Override @Override
public void onError(Throwable error) { public void onError(Throwable error) {
NewService.logToastAndUpload(TAG, "auto open AccessibilityService error:"+error.getMessage()); NewService.logToastAndUpload(TAG, "开启无障碍失败 error:"+error.getMessage());
} }
}); });
......
...@@ -15,10 +15,9 @@ import com.xf.weixinclick.NewService; ...@@ -15,10 +15,9 @@ import com.xf.weixinclick.NewService;
import com.xf.weixinclick.bean.msg.ReceiverMsg; import com.xf.weixinclick.bean.msg.ReceiverMsg;
import com.xf.weixinclick.receiver.WeChatStatus; import com.xf.weixinclick.receiver.WeChatStatus;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.xf.weixinclick.NewService.findNodeByTexts;
import static com.xf.weixinclick.receiver.WeChatStatus.needClick;
/** /**
* 创建日期:2018/4/17 on 11:36 * 创建日期:2018/4/17 on 11:36
...@@ -29,7 +28,7 @@ import static com.xf.weixinclick.receiver.WeChatStatus.needClick; ...@@ -29,7 +28,7 @@ import static com.xf.weixinclick.receiver.WeChatStatus.needClick;
public class TaskSession2 { public class TaskSession2 {
private final int MSG_TIME_OUT = -100; private final int MSG_TIME_OUT = -100;
private final int TIME_OUT = 40 *1000; private final int TIME_OUT = 50 *1000;
ReceiverMsg mMsg; ReceiverMsg mMsg;
int mStep; int mStep;
final String TAG = TaskSession2.class.getSimpleName(); final String TAG = TaskSession2.class.getSimpleName();
...@@ -50,7 +49,7 @@ public class TaskSession2 { ...@@ -50,7 +49,7 @@ public class TaskSession2 {
@Override @Override
public boolean handleMessage(Message msg) { public boolean handleMessage(Message msg) {
if (msg.what == MSG_TIME_OUT){ if (msg.what == MSG_TIME_OUT){
Log(TAG, "超时返回"); NewService.logToastAndUpload(TAG, "超时返回");
turnBack(); turnBack();
taskFinish(); taskFinish();
} }
...@@ -151,11 +150,19 @@ public class TaskSession2 { ...@@ -151,11 +150,19 @@ public class TaskSession2 {
if(fill(rootInActiveWindow,mMsg.getQr_addr())){ if(fill(rootInActiveWindow,mMsg.getQr_addr())){
mStep++;
Log(TAG, "文件传输详情页面_填充_完成"); Log(TAG, "文件传输详情页面_填充_完成");
send(rootInActiveWindow); send(rootInActiveWindow);
clickMsg(rootInActiveWindow,mMsg.getQr_addr()); handler.postDelayed(new Runnable() {
@Override
public void run() {
mStep++;
mStep++; Log(TAG, "开始点击");
clickMsg(rootInActiveWindow,mMsg.getQr_addr());
}
},2000);
}else{ }else{
Log(TAG, "文件传输详情页面_填充_失败"); Log(TAG, "文件传输详情页面_填充_失败");
} }
...@@ -164,7 +171,9 @@ public class TaskSession2 { ...@@ -164,7 +171,9 @@ public class TaskSession2 {
} }
if (mStep == 4 && className.equals(WXIdsConfig2.WeChatWebView)){
if (mStep == 5 && className.equals(WXIdsConfig2.WeChatWebView)){
mStep ++; mStep ++;
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
...@@ -176,7 +185,7 @@ public class TaskSession2 { ...@@ -176,7 +185,7 @@ public class TaskSession2 {
},mMsg.getTime_config().getAfter_click_message_delay()); },mMsg.getTime_config().getAfter_click_message_delay());
} }
if (mStep == 6 && className.equals(WXIdsConfig2.WeChatAlert)){ if (mStep == 7 && className.equals(WXIdsConfig2.WeChatAlert)){
Log(TAG, "开始点击确认二维码"); Log(TAG, "开始点击确认二维码");
mStep++; mStep++;
...@@ -190,13 +199,13 @@ public class TaskSession2 { ...@@ -190,13 +199,13 @@ public class TaskSession2 {
} }
if (mStep == 8 && className.equals(WXIdsConfig2.WeChatWebView)){ if (mStep == 9 && className.equals(WXIdsConfig2.WeChatWebView)){
Log(TAG, "开始点击确认登录"); Log(TAG, "开始点击确认登录");
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
Cmder.click(40,315); Cmder.click(40,315);
Cmder.click(40,375); Cmder.click(40,335);
mSuccess = true; mSuccess = true;
turnBack(); turnBack();
} }
...@@ -230,17 +239,22 @@ public class TaskSession2 { ...@@ -230,17 +239,22 @@ public class TaskSession2 {
return; return;
} }
List<AccessibilityNodeInfo> ac = rootNode.findAccessibilityNodeInfosByViewId(WXIdsConfig2.ITEM_MSG_CARD); List<AccessibilityNodeInfo> ac = new ArrayList<>();
List<AccessibilityNodeInfo> ac2 = rootNode.findAccessibilityNodeInfosByText(msg); for (int i = 0 ;i < WXIdsConfig2.ITEM_MSG_CARD.length ; i ++){
String id = WXIdsConfig2.ITEM_MSG_CARD[i];
ac = rootNode.findAccessibilityNodeInfosByViewId(id);
if (ac.size() >0){
Log.d(TAG, "通过id " + id + "找到了消息url");
break;
}
}
AccessibilityNodeInfo n = null; AccessibilityNodeInfo n = null;
if (ac.size() > 0) { if (ac.size() > 0) {
Log.d(TAG, "通过id找到了消息url"); Log.d(TAG, "通过id找到了消息url");
n = ac.get(ac.size() - 1); n = ac.get(ac.size() - 1);
} }
if (ac2.size() > 0) {
Log.d(TAG, "通过文字找到了消息url");
n = ac2.get(ac2.size() - 1);
}
if (n != null) { if (n != null) {
Cmder.clickNode(n); Cmder.clickNode(n);
......
...@@ -21,7 +21,7 @@ final class WXIdsConfig2 { ...@@ -21,7 +21,7 @@ final class WXIdsConfig2 {
public static final String BTN_SEND_MSG = ID_PREFIX+"aai"; //聊天页面发送按钮 public static final String BTN_SEND_MSG = ID_PREFIX+"aai"; //聊天页面发送按钮
public static final String ITEM_MSG_CARD = ID_PREFIX+"jj"; //聊天页面消息卡片 public static final String[] ITEM_MSG_CARD = new String[]{ID_PREFIX+"jj",ID_PREFIX+"jz"}; //聊天页面消息卡片
public static final String BTN_SCAN_QR = ID_PREFIX+"ga"; //识别二维码 public static final String BTN_SCAN_QR = ID_PREFIX+"ga"; //识别二维码
......
...@@ -8,6 +8,7 @@ import android.view.accessibility.AccessibilityEvent; ...@@ -8,6 +8,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory; import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.xf.weixinclick.NewService;
import com.xf.weixinclick.bean.msg.ReceiverMsg; import com.xf.weixinclick.bean.msg.ReceiverMsg;
import com.xf.weixinclick.http.HttpClientApi; import com.xf.weixinclick.http.HttpClientApi;
import com.xf.weixinclick.http.HttpSubscriber; import com.xf.weixinclick.http.HttpSubscriber;
...@@ -65,23 +66,24 @@ public class Worker2 { ...@@ -65,23 +66,24 @@ public class Worker2 {
//有的话就开始执行任务 直到成功或者失败 //有的话就开始执行任务 直到成功或者失败
try { try {
//take会一直等待到有新的任务 //take会一直等待到有新的任务
Log.d(TAG," 准备拿任务"); NewService.logToastAndUpload(TAG," 准备拿任务");
final ReceiverMsg msg = mTasks.take(); ReceiverMsg msg = mTasks.take();
Log.d(TAG," 拿到任务了 " + msg.getUnique_id() + " 剩余 " + mTasks.size()); final String msgOriginId = msg.getUnique_id();
NewService.logToastAndUpload(TAG," 拿到任务了 " + msg.getUnique_id() + " 剩余 " + mTasks.size());
mCurrentTaskSession = new TaskSession2(msg, new TaskSession2.TaskCallback() { mCurrentTaskSession = new TaskSession2(msg, new TaskSession2.TaskCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
Log.d(TAG," 任务成功"); NewService.logToastAndUpload(TAG," 任务成功" + msgOriginId);
taskCanStart(); taskCanStart();
upResult(ACTION_SUCCESS,msg.getOrigin_id()); upResult(ACTION_SUCCESS,msgOriginId);
} }
@Override @Override
public void onError(String errMsg) { public void onError(String errMsg) {
Log.d(TAG," 任务失败"); NewService.logToastAndUpload(TAG," 任务失败"+ msgOriginId);
taskCanStart(); taskCanStart();
upResult(ACTION_FAIL,msg.getOrigin_id()); upResult(ACTION_FAIL,msgOriginId);
} }
}); });
startWechat(); startWechat();
...@@ -141,7 +143,7 @@ public class Worker2 { ...@@ -141,7 +143,7 @@ public class Worker2 {
@Override @Override
public void onNext(String responseBase) { public void onNext(String responseBase) {
Log.d(TAG,"上报结果 " + responseBase); NewService.logToastAndUpload(TAG,"上报结果 " + responseBase);
} }
}); });
} }
......
...@@ -186,11 +186,11 @@ public class HttpClientApi { ...@@ -186,11 +186,11 @@ public class HttpClientApi {
} }
public static void uploadDeviceLog(String device_code, String tag, String message, Subscriber<String> subscriber) { public static void uploadDeviceLog(String device_code, String name,String tag,String message, Subscriber<String> subscriber) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("code", device_code); map.put("code", device_code);
map.put("name", tag); map.put("name", name);
map.put("msg", message); map.put("msg", tag +" " + message);
getInstance().devicesLog(map) getInstance().devicesLog(map)
.subscribeOn(io) .subscribeOn(io)
.observeOn(io) .observeOn(io)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment