Commit a6a9b16e by jeffrey

把master分支的合并到newUI分支

parent 3d4647e1
......@@ -22,8 +22,8 @@ android {
applicationId "com.xf.weixinclick"
minSdkVersion 21
targetSdkVersion 25
versionCode 4
versionName "1.3"
versionCode 5
versionName "1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
......
......@@ -140,14 +140,14 @@ public class MainActivity extends BaseActivity {
@Override
public void onClick(View v) {
// WeChatStatus.receiverMsg();
// Intent intent = new Intent();
// //// 报名该有activity
// ComponentName cmp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI");
// intent.setAction(Intent.ACTION_MAIN);
// intent.addCategory(Intent.CATEGORY_LAUNCHER);
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// intent.setComponent(cmp);
// startActivity(intent);
Intent intent = new Intent();
//// 报名该有activity
ComponentName cmp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI");
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.setComponent(cmp);
startActivity(intent);
new Thread(new Runnable() {
......@@ -163,8 +163,8 @@ public class MainActivity extends BaseActivity {
// msg.setQr_addr("https://weapp-dev.wangjia.com/qr.jpg?dd=1");
msg.setUnique_id("1111111111111");
msg.setTime_config(new Gson().fromJson("{\"qrcode_timeout\":60,\"after_open_weixin_index_delay\":2000,\"after_open_weixin_file_helper_delay\":6000,\"after_paste_message_delay\":2000,\"after_send_message_delay\":2000,\"after_click_message_delay\":5000,\"long_press_qrcode_delay\":4000,\"after_click_decode_button_delay\":5000,\"after_click_confirm_button_delay\":3000}", DelayBean.class));
// EventBus.getDefault().post(msg);
startWorkService(MainActivity.this,msg);
EventBus.getDefault().post(msg);
// startWorkService(MainActivity.this,msg);
}
}).start();
......@@ -230,6 +230,11 @@ public class MainActivity extends BaseActivity {
ensureListenerStatus();
}
@Override
public void onBackPressed() {
// super.onBackPressed();
}
private void ensureListenerStatus(){
String enable = (String) SP.getParam("enable","1");
if (enable.equals("1")){
......
......@@ -65,63 +65,53 @@ public class NewService extends AccessibilityService {
int isFalse = 0;
// private String Url = "https://weapp-dev.wangjia.com/qr.jpg?dd=1";
// private String message_id = "123";
// 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;
private int step = -1;
long times = 0;
boolean clickDone = false;
long lastShowToastTime = 0;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d("fei", "onStartCommand start");
// NotificationUtils.foreground(getApplicationContext(),this);
// //todo 当多任务过来的时候,没处理
// if (intent != null && intent.getSerializableExtra(PARAMS_MSG) != null){
// //先设置变量 然后唤起微信,微信唤起后会通知onAccessibilityEvent
// //然后一步步走流程
// ReceiverMsg msg = (ReceiverMsg) intent.getSerializableExtra(PARAMS_MSG);
// taskMsg = msg;
// delayBean = msg.getTime_config();
// step=0;
//
// awakeWechat(getApplicationContext());
// }else {
// if (BuildConfig.DEBUG){
// showToast(getApplicationContext(),"后台服务启动了,但是没有具体消息内容");
// }
// }
//当service因为低内存被杀掉后,等内存足够时可以重启
return START_STICKY;
}
// @Override
// public int onStartCommand(Intent intent, int flags, int startId) {
//
// Log.d("fei", "onStartCommand start");
//// NotificationUtils.foreground(getApplicationContext(),this);
////
//// //todo 当多任务过来的时候,没处理
//// if (intent != null && intent.getSerializableExtra(PARAMS_MSG) != null){
//// //先设置变量 然后唤起微信,微信唤起后会通知onAccessibilityEvent
//// //然后一步步走流程
//// ReceiverMsg msg = (ReceiverMsg) intent.getSerializableExtra(PARAMS_MSG);
//// taskMsg = msg;
//// delayBean = msg.getTime_config();
//// step=0;
////
//// awakeWechat(getApplicationContext());
//// }
//
// //当service因为低内存被杀掉后,等内存足够时可以重启
// return START_STICKY;
// }
@Subscribe
public void receiverMsg(final ReceiverMsg msg) {
Log.d("fei ", "receiverMsg");
if (!findNodeByTexts(this,"微信","通讯录","发现","我")){
Log.d("fei ", "当前页不是首页");
showToast(getApplicationContext(),"当前页不是首页");
turnBack(isFalse,2);
return;
}
Log.d(TAG, "receiverMsg");
//收到消息后 打开文件传输助手
Log.d("fei ", "点击文件传输助手");
// Log.d(TAG, "点击文件传输助手");
delayBean = msg.getTime_config();
if (delayBean == null){
Log.d("fei ", "delayBean 是空");
Log.d(TAG, "delayBean 是空");
}
// execShellCmd("input tap 220 200");
......@@ -130,23 +120,24 @@ public class NewService extends AccessibilityService {
//发送触发的消息给service,难道微信没有触发?
delayDeal(delayBean.getAfter_open_weixin_file_helper_delay(), new IDelayMethord() {
@Override
public void delayMethord() {
@Override
public void delayMethord() {
clickDone = true;
clickDone = true;
// showToast(getApplicationContext(),"消息的 unique_id 是 " + msg.getUnique_id());
Log.d("fei ", "receiverMsg里面触发下页面消息 unique_id " + msg.getUnique_id());
WeChatStatus.receiverMsg();
String Url = msg.getQr_addr();
Log.d("fei ", "receiverMsg里面触发下页面消息 Url " + Url);
String message_id = msg.getUnique_id();
taskMsg = msg;
AccessibilityEvent accessibilityEvent = AccessibilityEvent.obtain(32);
accessibilityEvent.setClassName(WeChatUi);
onAccessibilityEvent(accessibilityEvent);
}
});
Log.d(TAG, "receiverMsg里面触发下页面消息 unique_id " + msg.getUnique_id());
WeChatStatus.receiverMsg();
String Url = msg.getQr_addr();
Log.d(TAG, "receiverMsg里面触发下页面消息 Url " + Url);
message_id = msg.getUnique_id();
taskMsg = msg;
step = 0;
AccessibilityEvent accessibilityEvent = AccessibilityEvent.obtain(32);
accessibilityEvent.setClassName(WeChatUi);
onAccessibilityEvent(accessibilityEvent);
}
});
}
......@@ -154,17 +145,10 @@ public class NewService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
Log.d("fei", "NewService onAccessibilityEvent");
if (System.currentTimeMillis() - lastShowToastTime > 10 * 1000){
showToast(getApplicationContext(),"收到了无障碍的通知,无障碍服务正常");
lastShowToastTime = System.currentTimeMillis();
}
Log.d(TAG, "NewService onAccessibilityEvent");
if (!EventBus.getDefault().isRegistered(this)){
EventBus.getDefault().register(this);
}
int eventType = event.getEventType();
String className = event.getClassName().toString();
Log.d(TAG, "get event = " + eventType + " class " + className + " step " + step);
......@@ -178,33 +162,54 @@ public class NewService extends AccessibilityService {
Log.d(TAG, "NewService but taskMsg is null");
return;
}
if (step == 0 && !findNodeByTexts(this,"微信","通讯录","发现","我")){
Log.d(TAG, "当前页不是首页");
showToast(getApplicationContext(),"当前页不是首页");
turnBack(isFalse,1);
resetAll();
return;
}
// if (eventType == 32 && className.contains("WebviewScanImageActivity")) {
// return;
// }
// if (WeChatStatus.isClose()) {
// return;
// }
if (step == 0&& !findNodeByTexts(this,"微信","通讯录","发现","我")){
Log.d(TAG, "是在第一步,但不是在首页,重新进入再来");
resetAll();
showToast(getApplicationContext(),"当前页不是首页");
turnBack(isFalse,2);
}
// if (step == 0&& !findNodeByTexts(this,"微信","通讯录","发现","我")){
// Log.d(TAG, "是在第一步,但不是在首页,重新进入再来");
// resetAll();
// showToast(getApplicationContext(),"当前页不是首页");
// turnBack(isFalse,2);
// }
if (step == 0 && findNodeByTexts(this,"微信","通讯录","发现","我")){
step++;
//点击文件传输助手的位置
//最好还是找到文字然后点击位置
//没办法 首页打印出来的是通讯录的布局,所以坐标是错误的
step++;
Log.d(TAG, "准备点击首页的文件传输助手");
delayDeal(delayBean.getAfter_open_weixin_index_delay(), new IDelayMethord() {
@Override
public void delayMethord() {
AccessibilityNodeInfo rootNode = getRootInActiveWindow();
if (rootNode == null){
return;
}
if (!findNodeByTexts(NewService.this,"微信","通讯录","发现","我")){
Log.d(TAG, "不在首页,不点击");
showToast(myApplication.getInstence(),"没有发现文件传输助手,不点击");
return;
}
Log.d(TAG, "开始点击首页的文件传输助手");
printAllNode();
execShellCmd("input tap 220 200");
step++;
}
});
// clickHomeWJCSZS();
}
// if (step == 1 ){
......@@ -212,7 +217,14 @@ public class NewService extends AccessibilityService {
// }
// && findNodeByTexts(this,"文件传输助手")
if (step == 2 ){
if (step == 2 && !findNodeByTexts(this,"文件传输助手")){
resetAll();
showToast(getApplicationContext(),"当前页不是文件传输助手页");
turnBack(isFalse,1);
return;
}
if (step == 2 && findNodeByTexts(this,"文件传输助手")){
step++;
Log.d(TAG, "文件传输详情页面_填充_准备");
delayDeal(5000, new IDelayMethord() {
......@@ -253,7 +265,7 @@ public class NewService extends AccessibilityService {
// clickMsg(getRootInActiveWindow());
// step++;
// }
if (step == 4 && className.equals(WeChatWebView)){
step ++;
// 二维码长点击
......@@ -265,7 +277,7 @@ public class NewService extends AccessibilityService {
}
});
}
if (step == 6 && className.equals(WeChatAlert)){
Log.d(TAG, "开始点击确认二维码");
step++;
......@@ -279,9 +291,10 @@ public class NewService extends AccessibilityService {
}
if (step == 8 && className.equals(WeChatWebView)){
step ++;
Log.d(TAG, "开始点击确认登录");
pressSure();
step++;
// resetAll();
}
// switch (eventType) {
......@@ -375,21 +388,21 @@ public class NewService extends AccessibilityService {
// break;
// }
}
}
@Override
public void onInterrupt () {
Log.d("fei", "NewService onInterrupt");
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
@Override
public void onInterrupt () {
Log.d(TAG, "NewService onInterrupt");
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
}
/**
* 二维码长点击
*
*/
/**
* 二维码长点击
*
*/
private void longPress() {
delayDeal(delayBean.getAfter_click_message_delay(), new IDelayMethord() {
......@@ -415,7 +428,7 @@ public class NewService extends AccessibilityService {
Rect rect = new Rect();
temp.getBoundsInScreen(rect);
final float x = rect.left + dip2px(5), y = rect.top + dip2px(5);
Log.d("fei ", String.format("click %f %f ", x, y));
Log.d(TAG, String.format("click %f %f ", x, y));
execShellCmd("input tap " + x + " " + y);
WeChatStatus.clickCodeFinish();
......@@ -446,13 +459,13 @@ public class NewService extends AccessibilityService {
}
if (findNode == null) {
Log.d("fei ", String.format("没有根据文字找到确认"));
Log.d(TAG, String.format("没有根据文字找到确认"));
int delayTime = delayBean.getAfter_click_decode_button_delay();
delayDeal(delayTime, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", String.format("确认页的第一个点击"));
Log.d(TAG, String.format("确认页的第一个点击"));
execShellCmd("input tap " + dip2px(40) + " " + dip2px(315));
}
......@@ -461,14 +474,14 @@ public class NewService extends AccessibilityService {
delayDeal(delayTime+1000, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", String.format("确认页的第2个点击"));
Log.d(TAG, String.format("确认页的第2个点击"));
execShellCmd("input tap " + dip2px(40) + " " + dip2px(375));
}
});
delayDeal(delayTime+1500, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", String.format("确认页的第3个点击"));
Log.d(TAG, String.format("确认页的第3个点击"));
execShellCmd("input tap " + dip2px(40) + " " + dip2px(430));
}
});
......@@ -476,13 +489,13 @@ public class NewService extends AccessibilityService {
delayDeal(delayTime+delayBean.getAfter_click_confirm_button_delay(), new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", String.format("确认页的最终超时确认"));
Log.d(TAG, String.format("确认页的最终超时确认"));
isPassTime();
}
});
} else {
Log.d("fei ", String.format("根据文字找到确认了"));
Log.d(TAG, String.format("根据文字找到确认了"));
final AccessibilityNodeInfo finalFindNode = findNode;
delayDeal(5000, new IDelayMethord() {
......@@ -550,18 +563,18 @@ public class NewService extends AccessibilityService {
List<AccessibilityNodeInfo> allData = getRootInActiveWindow()
.findAccessibilityNodeInfosByText(needBack2);
if (allData.isEmpty()) {
Log.d("fei ", String.format("回头了成功 没有确定按钮"));
Log.d(TAG, String.format("回头了成功 没有确定按钮"));
turnBack(isSuccess, 2);
} else {
for (AccessibilityNodeInfo temp : allData) {
Log.d("fei ", String.format("回头了 有确定按钮 再点击下"));
Log.d(TAG, String.format("回头了 有确定按钮 再点击下"));
Rect rect = new Rect();
temp.getBoundsInScreen(rect);
final float x = rect.left + dip2px(5), y = rect.top + dip2px(5);
execShellCmd("input tap " + x + " " + y);
}
Log.d("fei ", String.format("回头了 失败"));
Log.d(TAG, String.format("回头了 失败"));
delayDeal(800, new IDelayMethord() {
@Override
public void delayMethord() {
......@@ -570,6 +583,7 @@ public class NewService extends AccessibilityService {
});
}
} catch (Exception ignored) {
Log.d(TAG, "异常 " + ignored.getMessage());
}
}
......@@ -578,52 +592,53 @@ public class NewService extends AccessibilityService {
* 返回
*/
private void turnBack(int code, int size) {
Log.d("fei ", "执行返回" + code + " size " + size);
Log.d(TAG, "执行返回" + code + " size " + size);
//需要返回
execShellCmd("input keyevent 4");
delayDeal(500, new IDelayMethord() {
delayDeal(1000, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", "执行返回 step 1");
Log.d(TAG, "执行返回 step 1");
execShellCmd("input keyevent 4");
}
});
delayDeal(1500, new IDelayMethord() {
delayDeal(2000, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", "执行返回 step 2");
Log.d(TAG, "执行返回 step 2");
execShellCmd("input keyevent 4");
}
});
delayDeal(2500, new IDelayMethord() {
delayDeal(3000, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", "执行返回 step 3");
Log.d(TAG, "执行返回 step 3");
execShellCmd("input keyevent 4");
}
});
delayDeal(3500, new IDelayMethord() {
delayDeal(4000, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", "执行返回 step 4");
execShellCmd("input keyevent 4");
}
});
if (size > 1) {
delayDeal(4500, new IDelayMethord() {
@Override
public void delayMethord() {
Log.d("fei ", "执行返回 step 5");
execShellCmd("input keyevent 4");
}
});
}
// if (size > 1) {
// delayDeal(4500, new IDelayMethord() {
// @Override
// public void delayMethord() {
// Log.d("fei ", "执行返回 step 5");
// execShellCmd("input keyevent 4");
// }
// });
// }
WeChatStatus.finishAll();
// WeChatStatus.finishAll();
clickDone = false;
upResult(code,taskMsg.getUnique_id());
// String uniqueID = taskMsg.getUnique_id();
upResult(code,message_id);
resetAll();
}
......@@ -633,6 +648,10 @@ public class NewService extends AccessibilityService {
* @param code
*/
private void upResult(final int code, final String id) {
if (TextUtils.isEmpty(id)){
return;
}
Log.d(TAG,"开始上报结果 " + code + " " + id);
HttpClientApi.devicesScan(PushServiceFactory.getCloudPushService().getDeviceId(),
code,
id,
......@@ -644,6 +663,7 @@ public class NewService extends AccessibilityService {
@Override
public void onNext(String responseBase) {
Log.d(TAG,"上报结果 " + responseBase);
showToast(getApplicationContext(), String.format("code %d message_id %s 上报结果 %s",code,id,responseBase));
}
});
......@@ -682,11 +702,11 @@ public class NewService extends AccessibilityService {
Rect rect = new Rect();
n.getBoundsInScreen(rect);
final float x = rect.left + dip2px(40), y = rect.top + dip2px(20);
Log.d("fei ", String.format("click %f %f ", x, y));
Log.d(TAG, String.format("click %f %f ", x, y));
execShellCmd("input tap " + x + " " + y);
} else {
Log.d("fei ", "找不到消息 消息url" + taskMsg.getQr_addr());
Log.d(TAG, "找不到消息 消息url" + taskMsg.getQr_addr());
execShellCmd("input tap " + dip2px(80) + " " + dip2px(540));
}
......@@ -698,7 +718,7 @@ public class NewService extends AccessibilityService {
* @param cmd
*/
private void execShellCmd(String cmd) {
Log.d("fei ", "execShellCmd " + cmd);
Log.d(TAG, "execShellCmd " + cmd);
try {
// 申请获取root权限,这一步很重要,不然会没有作用
......@@ -775,7 +795,7 @@ public class NewService extends AccessibilityService {
}
if ("android.widget.EditText".equals(nodeInfo.getClassName())) {
Log.d("fei","填充的内容 " + content);
Log.d(TAG,"填充的内容 " + content);
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
......@@ -824,18 +844,18 @@ public class NewService extends AccessibilityService {
private void printInfos(){
String currentClassName = (String) getRootInActiveWindow().getClassName();
Log.d("fei ", "currentClassName " + currentClassName);
Log.d(TAG, "currentClassName " + currentClassName);
int count = getRootInActiveWindow().getChildCount();
for (int i = 0 ; i < count ; i++){
AccessibilityNodeInfo nodeInfo = getRootInActiveWindow().getChild(i);
recycle(nodeInfo,"teststt");
// Log.d("fei ", "child i " + i + " classname " + nodeInfo.getClassName());
// Log.d(TAG, "child i " + i + " classname " + nodeInfo.getClassName());
}
}
// public boolean isHome(){
// public boolean isHome(){
// int count = getRootInActiveWindow().getChildCount();
// for (int i = 0 ; i < count ; i++){
// AccessibilityNodeInfo nodeInfo = getRootInActiveWindow().getChild(i);
......@@ -848,10 +868,10 @@ public class NewService extends AccessibilityService {
// }
public AccessibilityNodeInfo recycle(AccessibilityNodeInfo info,String searchText) {
if (info.getChildCount() == 0) {
// Log.i("fei ", "child widget----------------------------" + info.getClassName());
// Log.i("fei ", "showDialog:" + info.canOpenPopup());
// Log.i("fei ", "Text:" + info.getText());
// Log.i("fei ", "windowId:" + info.getWindowId());
// Log.i(TAG, "child widget----------------------------" + info.getClassName());
// Log.i(TAG, "showDialog:" + info.canOpenPopup());
// Log.i(TAG, "Text:" + info.getText());
// Log.i(TAG, "windowId:" + info.getWindowId());
if (!TextUtils.isEmpty(info.getText()) && searchText.equals(info.getText())){
return info;
}
......@@ -891,6 +911,7 @@ public class NewService extends AccessibilityService {
Log.i(TAG, "child widget----------------------------" + info.getClassName());
Log.i(TAG, "Text:" + info.getText());
Log.i(TAG, "windowId:" + info.getWindowId());
Log.i(TAG, "contentDescription:" + info.getContentDescription());
} else {
for (int i = 0; i < info.getChildCount(); i++) {
......
......@@ -57,7 +57,7 @@ public class MyMessageReceiver extends MessageReceiver {
ComponentName cmp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI");// 报名该有activity
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.setComponent(cmp);
myApplication.getInstence().startActivity(intent);
new Thread(new Runnable() {
......@@ -68,7 +68,7 @@ public class MyMessageReceiver extends MessageReceiver {
long second = System.currentTimeMillis()/1000 - msg.getPushed_at() ;
if (second < 15*60){
try {
Thread.sleep(2000);
Thread.sleep(msg.getTime_config().getAfter_open_weixin_index_delay());
} catch (InterruptedException e) {
e.printStackTrace();
}
......
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