Commit b4a6fdf9 by jeffrey

v1.3差不多了

parent 471e53ed
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".MainActivity"/> <activity android:name=".MainActivity"
android:windowSoftInputMode="adjustPan"/>
<!-- 消息接收监听器 (用户可自主扩展) --> <!-- 消息接收监听器 (用户可自主扩展) -->
<receiver <receiver
...@@ -65,7 +66,6 @@ ...@@ -65,7 +66,6 @@
android:name=".NewService" android:name=".NewService"
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
android:process=":remote"
android:label="@string/app_name" android:label="@string/app_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter> <intent-filter>
......
...@@ -19,9 +19,14 @@ import android.view.View; ...@@ -19,9 +19,14 @@ import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import com.alibaba.sdk.android.push.CloudPushService;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory; import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xf.weixinclick.bean.DelayBean; import com.xf.weixinclick.bean.DelayBean;
import com.xf.weixinclick.bean.EnableResult;
import com.xf.weixinclick.bean.LoginBean;
import com.xf.weixinclick.bean.ResponseBase;
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;
...@@ -32,6 +37,7 @@ import com.xf.weixinclick.view.WaveView; ...@@ -32,6 +37,7 @@ import com.xf.weixinclick.view.WaveView;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Locale; import java.util.Locale;
...@@ -59,6 +65,9 @@ public class MainActivity extends BaseActivity { ...@@ -59,6 +65,9 @@ public class MainActivity extends BaseActivity {
@BindView(R.id.tv_version_name) @BindView(R.id.tv_version_name)
TextView tv_version_name; TextView tv_version_name;
@BindView(R.id.tv_enable_listener)
TextView tv_enable_listener;
@BindView(R.id.waveView) @BindView(R.id.waveView)
WaveView mWaveView; WaveView mWaveView;
WaveHelper mWaveHelper; WaveHelper mWaveHelper;
...@@ -163,6 +172,71 @@ public class MainActivity extends BaseActivity { ...@@ -163,6 +172,71 @@ public class MainActivity extends BaseActivity {
} }
}); });
tv_enable_listener.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// String device = (String) SP.getParam("divice", "");
// if (TextUtils.isEmpty(device)){
// NewService.showToast(MainActivity.this,"要先点击绑定设置id");
// return ;
// }
CloudPushService pushService = PushServiceFactory.getCloudPushService();
String deviceId = pushService.getDeviceId();
if (TextUtils.isEmpty(deviceId)){
NewService.showToast(MainActivity.this,"推送注册失败 请重新打开App再试");
return ;
}
String enable = (String) SP.getParam("enable","1");
int enableCode = 1;
if (enable.equals("1")){
enableCode = 0;
}else {
enableCode =1;
}
showProgress("请求中");
HttpClientApi.enableListener(deviceId,
enableCode,
new HttpSubscriber<String>() {
@Override
public void onCompleted() {
dismissProgress();
System.out.println("res onCompleted");
}
@Override
public void onError(Throwable e) {
super.onError(e);
NewService.showToast(MainActivity.this,"请求失败 " + e.getMessage());
}
@Override
public void onNext(String responseBase) {
// SP.setParam("divice", d_name);
Log.d("fei",responseBase);
Type type = new TypeToken<ResponseBase<EnableResult>>(){}.getType();
ResponseBase<EnableResult> result = new Gson().fromJson(responseBase,type);
if (result == null){
NewService.showToast(MainActivity.this,"失败:解析失败");
}else {
SP.setParam("enable",result.getData().getEnable());
ensureListenerStatus();
}
}
});
}
});
ensureListenerStatus();
}
private void ensureListenerStatus(){
String enable = (String) SP.getParam("enable","1");
if (enable.equals("1")){
tv_enable_listener.setText("接收消息中\n 点击暂停");
}else {
tv_enable_listener.setText("不收消息中\n 点击开启");
}
} }
......
...@@ -75,14 +75,14 @@ public class NewService extends AccessibilityService { ...@@ -75,14 +75,14 @@ public class NewService extends AccessibilityService {
boolean clickDone = false; boolean clickDone = false;
long lastShowToastTime = 0;
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
Log.d("fei", "onStartCommand start"); Log.d("fei", "onStartCommand start");
NotificationUtils.foreground(getApplicationContext(),this); // NotificationUtils.foreground(getApplicationContext(),this);
//todo 当多任务过来的时候,没处理 //todo 当多任务过来的时候,没处理
if (intent != null && intent.getSerializableExtra(PARAMS_MSG) != null){ if (intent != null && intent.getSerializableExtra(PARAMS_MSG) != null){
...@@ -94,6 +94,10 @@ public class NewService extends AccessibilityService { ...@@ -94,6 +94,10 @@ public class NewService extends AccessibilityService {
step=0; step=0;
awakeWechat(getApplicationContext()); awakeWechat(getApplicationContext());
}else {
if (BuildConfig.DEBUG){
showToast(getApplicationContext(),"后台服务启动了,但是没有具体消息内容");
}
} }
//当service因为低内存被杀掉后,等内存足够时可以重启 //当service因为低内存被杀掉后,等内存足够时可以重启
...@@ -146,6 +150,14 @@ public class NewService extends AccessibilityService { ...@@ -146,6 +150,14 @@ public class NewService extends AccessibilityService {
@Override @Override
public void onAccessibilityEvent(AccessibilityEvent event) { public void onAccessibilityEvent(AccessibilityEvent event) {
Log.d("fei", "NewService onAccessibilityEvent"); Log.d("fei", "NewService onAccessibilityEvent");
// if (BuildConfig.DEBUG){
if (System.currentTimeMillis() - lastShowToastTime > 10 * 1000){
showToast(getApplicationContext(),"收到了无障碍的通知,无障碍服务正常");
lastShowToastTime = System.currentTimeMillis();
}
// }
int eventType = event.getEventType(); int eventType = event.getEventType();
String className = event.getClassName().toString(); String className = event.getClassName().toString();
Log.d(TAG, "get event = " + eventType + " class " + className + " step " + step); Log.d(TAG, "get event = " + eventType + " class " + className + " step " + step);
...@@ -173,20 +185,27 @@ public class NewService extends AccessibilityService { ...@@ -173,20 +185,27 @@ public class NewService extends AccessibilityService {
} }
if (step == 0 && findNodeByTexts(this,"微信","通讯录","发现","我")){ if (step == 0 && findNodeByTexts(this,"微信","通讯录","发现","我")){
step++;
//点击文件传输助手的位置 //点击文件传输助手的位置
//最好还是找到文字然后点击位置 //最好还是找到文字然后点击位置
//没办法 首页打印出来的是通讯录的布局,所以坐标是错误的 //没办法 首页打印出来的是通讯录的布局,所以坐标是错误的
execShellCmd("input tap 220 200"); delayDeal(delayBean.getAfter_open_weixin_index_delay(), new IDelayMethord() {
// clickHomeWJCSZS(); @Override
step++; public void delayMethord() {
} execShellCmd("input tap 220 200");
step++;
}
});
if (step == 1 ){
printAllNode();
} }
// if (step == 1 ){
// printAllNode();
// }
// && findNodeByTexts(this,"文件传输助手") // && findNodeByTexts(this,"文件传输助手")
if (step == 1 ){ if (step == 2 ){
step++; step++;
Log.d(TAG, "文件传输详情页面_填充_准备"); Log.d(TAG, "文件传输详情页面_填充_准备");
delayDeal(5000, new IDelayMethord() { delayDeal(5000, new IDelayMethord() {
...@@ -228,7 +247,7 @@ public class NewService extends AccessibilityService { ...@@ -228,7 +247,7 @@ public class NewService extends AccessibilityService {
// step++; // step++;
// } // }
if (step == 3 && className.equals(WeChatWebView)){ if (step == 4 && className.equals(WeChatWebView)){
step ++; step ++;
// 二维码长点击 // 二维码长点击
delayDeal(delayBean.getAfter_click_message_delay(), new IDelayMethord() { delayDeal(delayBean.getAfter_click_message_delay(), new IDelayMethord() {
...@@ -240,7 +259,7 @@ public class NewService extends AccessibilityService { ...@@ -240,7 +259,7 @@ public class NewService extends AccessibilityService {
}); });
} }
if (step == 5 && className.equals(WeChatAlert)){ if (step == 6 && className.equals(WeChatAlert)){
Log.d(TAG, "开始点击确认二维码"); Log.d(TAG, "开始点击确认二维码");
step++; step++;
delayDeal(delayBean.getLong_press_qrcode_delay(), new IDelayMethord() { delayDeal(delayBean.getLong_press_qrcode_delay(), new IDelayMethord() {
...@@ -252,7 +271,7 @@ public class NewService extends AccessibilityService { ...@@ -252,7 +271,7 @@ public class NewService extends AccessibilityService {
}); });
} }
if (step == 7 && className.equals(WeChatWebView)){ if (step == 8 && className.equals(WeChatWebView)){
step ++; step ++;
Log.d(TAG, "开始点击确认登录"); Log.d(TAG, "开始点击确认登录");
pressSure(); pressSure();
......
package com.xf.weixinclick.bean;
/**
* 创建日期:2018/3/29 on 10:26
* 描述:
* 作者:Li
*/
public class EnableResult {
/**
* id : 3
* name : a030
* code : a3eb1a52cdf6421fbd15ca8f647e70f4
* x : 0
* y : 0
* status : 1
* enable : 0
* battery : 100
* synced_at : 2018-03-29 10:22:42
* created_at : 2018-03-21 09:36:00
* updated_at : 2018-03-29 10:22:42
* deleted_at : null
* statusText : 正常
* batteryText : 100%
*/
private int id;
private String name;
private String code;
private int x;
private int y;
private int status;
private String enable;
private int battery;
private String synced_at;
private String created_at;
private String updated_at;
private Object deleted_at;
private String statusText;
private String batteryText;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getEnable() {
return enable;
}
public void setEnable(String enable) {
this.enable = enable;
}
public int getBattery() {
return battery;
}
public void setBattery(int battery) {
this.battery = battery;
}
public String getSynced_at() {
return synced_at;
}
public void setSynced_at(String synced_at) {
this.synced_at = synced_at;
}
public String getCreated_at() {
return created_at;
}
public void setCreated_at(String created_at) {
this.created_at = created_at;
}
public String getUpdated_at() {
return updated_at;
}
public void setUpdated_at(String updated_at) {
this.updated_at = updated_at;
}
public Object getDeleted_at() {
return deleted_at;
}
public void setDeleted_at(Object deleted_at) {
this.deleted_at = deleted_at;
}
public String getStatusText() {
return statusText;
}
public void setStatusText(String statusText) {
this.statusText = statusText;
}
public String getBatteryText() {
return batteryText;
}
public void setBatteryText(String batteryText) {
this.batteryText = batteryText;
}
}
...@@ -19,4 +19,6 @@ public interface ClientApi{ ...@@ -19,4 +19,6 @@ public interface ClientApi{
Observable<String> devices(@Body Map<String, String> params); Observable<String> devices(@Body Map<String, String> params);
@POST("devices/scan") @POST("devices/scan")
Observable<String> devicesScan(@Body Map<String, String> params); Observable<String> devicesScan(@Body Map<String, String> params);
@POST("devices/enable")
Observable<String> devicesEnable(@Body Map<String, String> params);
} }
...@@ -158,6 +158,22 @@ public class HttpClientApi { ...@@ -158,6 +158,22 @@ public class HttpClientApi {
}); });
} }
/**
*
* @param device_code
* @param isEnable 0表示关闭设备,不接收请求 1表示接收任务
* @param subscriber
*/
public static void enableListener(String device_code, int isEnable,Subscriber subscriber) {
Map<String, String> map = new HashMap<>();
map.put("code", device_code);
map.put("status", isEnable + "");
getInstance().devicesEnable(map)
.subscribeOn(io)
.observeOn(main)
.subscribe(subscriber);
}
public static void devicesScan(String device_code, int is_success, String message_id, Subscriber subscriber) { public static void devicesScan(String device_code, int is_success, String message_id, Subscriber subscriber) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("device_code", device_code); map.put("device_code", device_code);
......
...@@ -67,64 +67,91 @@ ...@@ -67,64 +67,91 @@
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<RelativeLayout <ScrollView
android:layout_marginTop="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_work_action"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp"> android:layout_height="match_parent">
<TextView <LinearLayout
android:id="@+id/chat_view" android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_marginTop="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_work_action"
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/chat_view"
android:text="开启监听" android:text="开启系统辅助"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="11sp"
android:textColor="#fd7f5f" android:textColor="#fd7f5f"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/bg_btn_wok_action"/> android:background="@drawable/bg_btn_wok_action"/>
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" android:layout_marginRight="15dp"
android:background="@drawable/bg_work_action" android:background="@drawable/bg_work_action"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp"> android:layout_height="100dp">
<TextView <TextView
android:id="@+id/chat_view_show" android:id="@+id/chat_view_show"
android:text="设置事件" android:text="测试"
android:gravity="center" android:gravity="center"
android:textSize="14sp" android:textSize="14sp"
android:textColor="#fd7f5f" android:textColor="#fd7f5f"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/bg_btn_wok_action"/> android:background="@drawable/bg_btn_wok_action"/>
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:layout_marginTop="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_work_action"
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/tv_enable_listener"
android:text="接收消息中\n 点击暂停"
android:gravity="center"
android:textSize="12sp"
android:textColor="#fd7f5f"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_btn_wok_action"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_version_name"
android:layout_marginBottom="15dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:textSize="16sp"
android:textColor="#c9c9ca"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="版本号" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_version_name"
android:layout_marginBottom="15dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:textSize="16sp"
android:textColor="#c9c9ca"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="版本号" />
</RelativeLayout>
</LinearLayout> </LinearLayout>
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