Commit e94744a9 by jeffrey

把拉取金额,跑金额,然后提交金额跑通了

parent aa7df233
...@@ -22,8 +22,8 @@ android { ...@@ -22,8 +22,8 @@ android {
applicationId "com.yuqirong.listenwechatnotification" applicationId "com.yuqirong.listenwechatnotification"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 26 targetSdkVersion 26
versionCode 200002 versionCode 200003
versionName "2.0.02" versionName "2.0.03"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
......
...@@ -5,23 +5,31 @@ import android.app.AlarmManager; ...@@ -5,23 +5,31 @@ import android.app.AlarmManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Environment; import android.os.Environment;
import android.provider.Settings; import android.provider.Settings;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.gson.Gson;
import com.yuqirong.listenwechatnotification.askhttp.ActivePullCashList;
import com.yuqirong.listenwechatnotification.askhttp.UpdateApk; import com.yuqirong.listenwechatnotification.askhttp.UpdateApk;
import com.yuqirong.listenwechatnotification.bean.BaseResult;
import com.yuqirong.listenwechatnotification.bean.ImageBean;
import com.yuqirong.listenwechatnotification.bean.OneBatchResult;
import com.yuqirong.listenwechatnotification.bean.WorkAction; import com.yuqirong.listenwechatnotification.bean.WorkAction;
import com.yuqirong.listenwechatnotification.broadcastReceiver.MyCashReceiver; import com.yuqirong.listenwechatnotification.broadcastReceiver.MyCashReceiver;
import com.yuqirong.listenwechatnotification.http.HttpService;
import com.yuqirong.listenwechatnotification.http.PayHttp; import com.yuqirong.listenwechatnotification.http.PayHttp;
import com.yuqirong.listenwechatnotification.service.MyAccessibilityService;
import com.yuqirong.listenwechatnotification.service.WeChatNotificationListenerService; import com.yuqirong.listenwechatnotification.service.WeChatNotificationListenerService;
import com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences; import com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences;
import com.yuqirong.listenwechatnotification.uitl.Utils; import com.yuqirong.listenwechatnotification.uitl.Utils;
...@@ -32,6 +40,12 @@ import java.io.BufferedWriter; ...@@ -32,6 +40,12 @@ import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
public class MainActivity extends ParentActivity { public class MainActivity extends ParentActivity {
...@@ -113,7 +127,7 @@ public class MainActivity extends ParentActivity { ...@@ -113,7 +127,7 @@ public class MainActivity extends ParentActivity {
Intent intent = new Intent("CashPull"); Intent intent = new Intent("CashPull");
sendBroadcast(intent); sendBroadcast(intent);
// TODO: 2018/3/6 0006 正式测试数据的时候开放这个方法 // TODO: 2018/3/6 0006 正式测试数据的时候开放这个方法
//timingRequest(); // timingRequest();
} }
}); });
...@@ -139,11 +153,11 @@ public class MainActivity extends ParentActivity { ...@@ -139,11 +153,11 @@ public class MainActivity extends ParentActivity {
findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() { findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// String userName = Save2SharedPreferences.read(ALIPAYNAME,MainActivity.this); String userName = Save2SharedPreferences.read(ALIPAYNAME,MainActivity.this);
// ActivePullCashList pullCashList = new ActivePullCashList(); ActivePullCashList pullCashList = new ActivePullCashList();
// pullCashList.pullList(Utils.payChannelZFB,userName); pullCashList.pullListAndRun(Utils.payChannelZFB,userName);
WeChatNotificationListenerService.sendRequestWithOkHttp("hello","1111",Utils.payChannelZFB, HttpService.token); // WeChatNotificationListenerService.sendRequestWithOkHttp("hello","1111",Utils.payChannelZFB, HttpService.token);
} }
}); });
...@@ -152,9 +166,11 @@ public class MainActivity extends ParentActivity { ...@@ -152,9 +166,11 @@ public class MainActivity extends ParentActivity {
public void onClick(View v) { public void onClick(View v) {
// String userName = Save2SharedPreferences.read(ALIPAYNAME,MainActivity.this); // String userName = Save2SharedPreferences.read(ALIPAYNAME,MainActivity.this);
// ActivePullCashList pullCashList = new ActivePullCashList(); // ActivePullCashList pullCashList = new ActivePullCashList();
// pullCashList.pullList(Utils.payChannelZFB,userName); // pullCashList.pullListAndRun(Utils.payChannelZFB,userName);
// EventBus.getDefault().post(new WorkAction(WorkAction.ACTION_TYPE_BILL));
MyAccessibilityService.testQRcodeResult();
EventBus.getDefault().post(new WorkAction(WorkAction.ACTION_TYPE_BILL));
} }
}); });
checkWritePermission(); checkWritePermission();
......
...@@ -28,41 +28,41 @@ public class ActivePushCashList { ...@@ -28,41 +28,41 @@ public class ActivePushCashList {
public ActivePushCashList() { public ActivePushCashList() {
} }
public void pushCashList(ArrayList<ImageBean> list){ // public void pushCashList(ArrayList<ImageBean> list){
Retrofit retrofit = new Retrofit.Builder().baseUrl(HttpService.base_url) // Retrofit retrofit = new Retrofit.Builder().baseUrl(HttpService.base_url)
//添加返回字符串的支持--不知道返回的是什么,添加字符串支持 // //添加返回字符串的支持--不知道返回的是什么,添加字符串支持
.addConverterFactory(ScalarsConverterFactory.create()) // .addConverterFactory(ScalarsConverterFactory.create())
//添加GSON转换支持 // //添加GSON转换支持
.addConverterFactory(GsonConverterFactory.create()) // .addConverterFactory(GsonConverterFactory.create())
.build(); // .build();
//
//获取接口 // //获取接口
HttpService service = retrofit.create(HttpService.class); // HttpService service = retrofit.create(HttpService.class);
//
Call<String> call =service.pushZFBCashList(PayTypeSingleTon.newInstance().getPayType(),list); // Call<String> call =service.pushZFBCashList(PayTypeSingleTon.newInstance().getPayType(),list);
//
call.enqueue(new Callback<String>() { // call.enqueue(new Callback<String>() {
@Override // @Override
public void onResponse(Call<String> call, Response<String> response) { // public void onResponse(Call<String> call, Response<String> response) {
//
//数据发送成功的话,这边修改下次请求参数类型 // //数据发送成功的话,这边修改下次请求参数类型
//还需要删除当前类型文件夹下所有图片 // //还需要删除当前类型文件夹下所有图片
if (PayTypeSingleTon.newInstance().getPayType().equals(Utils.payTypeZFB)){ // if (PayTypeSingleTon.newInstance().getPayType().equals(Utils.payTypeZFB)){
PayTypeSingleTon.newInstance().setPayType(Utils.payTypeWeiXin); // PayTypeSingleTon.newInstance().setPayType(Utils.payTypeWeiXin);
FileUtils.deleteFiles(Utils.ZFBImgPath); // FileUtils.deleteFiles(Utils.ZFBImgPath);
}else{ // }else{
PayTypeSingleTon.newInstance().setPayType(Utils.payTypeZFB); // PayTypeSingleTon.newInstance().setPayType(Utils.payTypeZFB);
FileUtils.deleteFiles(Utils.WeiXinImgPath); // FileUtils.deleteFiles(Utils.WeiXinImgPath);
} // }
} // }
//
@Override // @Override
public void onFailure(Call<String> call, Throwable t) { // public void onFailure(Call<String> call, Throwable t) {
//
} // }
}); // });
//
} // }
} }
package com.yuqirong.listenwechatnotification.bean; package com.yuqirong.listenwechatnotification.bean;
import com.google.gson.annotations.SerializedName;
/** /**
* Created by yanqi on 2018/2/27 0027. * Created by yanqi on 2018/2/27 0027.
*/ */
public class ImageBean { public class ImageBean {
String url; String code;
String description; String amount;
public String getUrl() { public String getCode() {
return url; return code;
} }
public void setUrl(String url) { public String getAmount() {
this.url = url; return amount;
} }
public String getDescription() { public void setCode(String code) {
return description; this.code = code;
} }
public void setDescription(String description) { public void setAmount(String amount) {
this.description = description; this.amount = amount;
} }
} }
package com.yuqirong.listenwechatnotification.bean; package com.yuqirong.listenwechatnotification.bean;
import com.yuqirong.listenwechatnotification.uitl.Utils;
import java.util.ArrayList;
/** /**
* 创建日期:2018/3/19 on 14:50 * 创建日期:2018/3/19 on 14:50
* 描述: * 描述:
...@@ -8,11 +12,39 @@ package com.yuqirong.listenwechatnotification.bean; ...@@ -8,11 +12,39 @@ package com.yuqirong.listenwechatnotification.bean;
public class WorkAction { public class WorkAction {
public static final int ACTION_TYPE_NONE = 0; public static final int ACTION_TYPE_NONE = 0;
/**
* 生成二维码
*/
public static final int ACTION_TYPE_MONEY = 1; public static final int ACTION_TYPE_MONEY = 1;
/**
* 识别账单
*/
public static final int ACTION_TYPE_BILL = 2; public static final int ACTION_TYPE_BILL = 2;
/**
* 动作类型
*/
private int type = ACTION_TYPE_NONE; private int type = ACTION_TYPE_NONE;
/**
* 如果是生成二维码的话 需要这个
*/
private ArrayList<String> moneys;
/**
* 目标app就下面这两种类型
* @see com.yuqirong.listenwechatnotification.uitl.Utils#payTypeWeiXin
* @see com.yuqirong.listenwechatnotification.uitl.Utils#payTypeZFB
*/
private String targetAppType = Utils.payTypeZFB ;
public ArrayList<String> getMoneys() {
return moneys;
}
public void setMoneys(ArrayList<String> moneys) {
this.moneys = moneys;
}
public WorkAction(int type) { public WorkAction(int type) {
this.type = type; this.type = type;
...@@ -25,4 +57,12 @@ public class WorkAction { ...@@ -25,4 +57,12 @@ public class WorkAction {
public void setType(int type) { public void setType(int type) {
this.type = type; this.type = type;
} }
public String getTargetAppType() {
return targetAppType;
}
public void setTargetAppType(String targetAppType) {
this.targetAppType = targetAppType;
}
} }
...@@ -9,6 +9,9 @@ import com.yuqirong.listenwechatnotification.askhttp.ActivePullCashList; ...@@ -9,6 +9,9 @@ import com.yuqirong.listenwechatnotification.askhttp.ActivePullCashList;
import com.yuqirong.listenwechatnotification.uitl.PayTypeSingleTon; import com.yuqirong.listenwechatnotification.uitl.PayTypeSingleTon;
import com.yuqirong.listenwechatnotification.uitl.Utils; import com.yuqirong.listenwechatnotification.uitl.Utils;
import static com.yuqirong.listenwechatnotification.askhttp.ActivePullCashList.generateMoneys;
import static com.yuqirong.listenwechatnotification.askhttp.ActivePullCashList.moneyWithFilter;
/** /**
* Created by yanqi on 2018/3/2 0002. * Created by yanqi on 2018/3/2 0002.
*/ */
......
...@@ -27,6 +27,7 @@ import java.util.Collections; ...@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
...@@ -39,15 +40,16 @@ import static android.graphics.BitmapFactory.decodeFile; ...@@ -39,15 +40,16 @@ import static android.graphics.BitmapFactory.decodeFile;
*/ */
public class ParseImageFunc { public class ParseImageFunc {
private final int MAX_COUNT = 3;
private final String TAG = ParseImageFunc.class.getSimpleName(); private final String TAG = ParseImageFunc.class.getSimpleName();
private List<ImageBean> imageBeanList = new ArrayList<>() ; private List<ImageBean> imageBeanList = new ArrayList<>() ;
private ConcurrentLinkedQueue<File> queue = new ConcurrentLinkedQueue<File>(); private ConcurrentLinkedQueue<File> queue = new ConcurrentLinkedQueue<File>();
private CountDownLatch countDownLatch = new CountDownLatch(MAX_COUNT);
public void start(String filePath){ public void start(String filePath, final ParseListener parseListener){
parseListener.onStartWork();
final List<File> imageFiles = foundImageFile(filePath); final List<File> imageFiles = foundImageFile(filePath);
if (imageFiles == null || imageFiles.size() == 0){ if (imageFiles == null || imageFiles.size() == 0){
return; return;
...@@ -56,8 +58,8 @@ public class ParseImageFunc { ...@@ -56,8 +58,8 @@ public class ParseImageFunc {
queue.add(file); queue.add(file);
} }
ExecutorService service = Executors.newFixedThreadPool(3); ExecutorService service = Executors.newFixedThreadPool(MAX_COUNT);
for (int i = 0 ; i < 3 ;i ++){ for (int i = 0 ; i < MAX_COUNT ;i ++){
service.submit(new Runnable() { service.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -69,30 +71,47 @@ public class ParseImageFunc { ...@@ -69,30 +71,47 @@ public class ParseImageFunc {
imageBeanList.add(result); imageBeanList.add(result);
} }
} }
countDownLatch.countDown();
}
});
}
Collections.sort(imageBeanList,new Comparator<ImageBean>() { new Thread(new Runnable() {
@Override @Override
public int compare(ImageBean o1, ImageBean o2) { public void run() {
try { try {
float left = Float.valueOf(o1.getDescription().replace(".jpg","")); Log.d(TAG,"等待执行任务");
float right = Float.valueOf(o2.getDescription().replace(".jpg","")); countDownLatch.await();
return left < right ? -1 : 1; } catch (InterruptedException e) {
}catch (Exception e){ Log.d(TAG,"执行任务异常" + e.getMessage());
Log.d("fei","parse err " + e.getMessage());
return 0;
}
e.printStackTrace();
}
Log.d(TAG,"执行任务完成");
Collections.sort(imageBeanList,new Comparator<ImageBean>() {
@Override
public int compare(ImageBean o1, ImageBean o2) {
try {
float left = Float.valueOf(o1.getCode().replace(".jpg",""));
float right = Float.valueOf(o2.getCode().replace(".jpg",""));
return left < right ? -1 : 1;
}catch (Exception e){
Log.d("fei","parse err " + e.getMessage());
return 0;
} }
});
OneBatchResult result = new OneBatchResult(new ArrayList<ImageBean>(imageBeanList)); }
String stringResult = new Gson().toJson(result); });
SharedPreferences sp = MyApplication.get().getSharedPreferences("result", Context.MODE_PRIVATE);
sp.edit().putString("result",stringResult).apply(); OneBatchResult result = new OneBatchResult(new ArrayList<ImageBean>(imageBeanList));
Log.d("fei","parse done " + stringResult); String stringResult = new Gson().toJson(result);
} SharedPreferences sp = MyApplication.get().getSharedPreferences("result", Context.MODE_PRIVATE);
}); sp.edit().putString("result",stringResult).apply();
} Log.d(TAG,"parse done " + stringResult);
parseListener.onWorkDone(imageBeanList);
}
}).start();
} }
/** /**
...@@ -139,9 +158,9 @@ public class ParseImageFunc { ...@@ -139,9 +158,9 @@ public class ParseImageFunc {
try { try {
re = reader.decode(bitmap1); re = reader.decode(bitmap1);
ImageBean bean = new ImageBean(); ImageBean bean = new ImageBean();
bean.setUrl(re.getText()); bean.setCode(re.getText());
bean.setDescription(file.getName()); bean.setAmount(file.getName().replace(".jpg",""));
Log.d(TAG, "parseCode: "+bean.getUrl()); Log.d(TAG, "parseCode: "+bean.getCode());
return bean; return bean;
...@@ -160,4 +179,10 @@ public class ParseImageFunc { ...@@ -160,4 +179,10 @@ public class ParseImageFunc {
return null; return null;
} }
public interface ParseListener{
void onStartWork();
void onWorkDone(List<ImageBean> list);
}
} }
...@@ -182,9 +182,9 @@ public class QRCodeFunction extends Thread{ ...@@ -182,9 +182,9 @@ public class QRCodeFunction extends Thread{
try { try {
re = reader.decode(bitmap1); re = reader.decode(bitmap1);
ImageBean bean = new ImageBean(); ImageBean bean = new ImageBean();
bean.setUrl(re.getText()); bean.setCode(re.getText());
bean.setDescription(file.getName()); bean.setAmount(file.getName());
Log.d(TAG, "parseCode: "+bean.getUrl()); Log.d(TAG, "parseCode: "+bean.getCode());
return bean; return bean;
......
...@@ -7,10 +7,12 @@ import com.yuqirong.listenwechatnotification.bean.UpdateBean; ...@@ -7,10 +7,12 @@ import com.yuqirong.listenwechatnotification.bean.UpdateBean;
import com.yuqirong.listenwechatnotification.bean.UpgradeResult; import com.yuqirong.listenwechatnotification.bean.UpgradeResult;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import io.reactivex.Observable; import io.reactivex.Observable;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field; import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded; import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET; import retrofit2.http.GET;
...@@ -54,9 +56,12 @@ public interface HttpService { ...@@ -54,9 +56,12 @@ public interface HttpService {
@Headers({ @Headers({
"Accept: application/json" "Accept: application/json"
}) })
Call<PullMoneyResp> pullZFBCashList(@Field("channel") String channel, @Field("username") String username, @Field("token") String token); Observable<BaseResult<ArrayList<Double>>> pullZFBCashList(@Field("gateway") String channel, @Field("username") String username, @Field("token") String token);
@POST("/app-api/amounts/submit") @POST("/app-api/amounts/submit")
Call<String> pushZFBCashList(@Field("channel") String channel,@Field("list") ArrayList<ImageBean> imageBeans); @Headers({
"Accept: application/json"
})
Observable<BaseResult> pushZFBCashList(@Body HashMap<String,Object> params);
} }
...@@ -3,21 +3,33 @@ package com.yuqirong.listenwechatnotification.service; ...@@ -3,21 +3,33 @@ package com.yuqirong.listenwechatnotification.service;
import android.accessibilityservice.AccessibilityService; import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo; import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Toast;
import com.google.gson.Gson;
import com.yuqirong.listenwechatnotification.MainActivity;
import com.yuqirong.listenwechatnotification.MyApplication;
import com.yuqirong.listenwechatnotification.bean.BaseResult;
import com.yuqirong.listenwechatnotification.bean.ImageBean;
import com.yuqirong.listenwechatnotification.bean.OneBatchResult;
import com.yuqirong.listenwechatnotification.bean.WorkAction; import com.yuqirong.listenwechatnotification.bean.WorkAction;
import com.yuqirong.listenwechatnotification.function.AlipayBill; import com.yuqirong.listenwechatnotification.function.AlipayBill;
import com.yuqirong.listenwechatnotification.function.AlipayFunction; import com.yuqirong.listenwechatnotification.function.AlipayFunction;
import com.yuqirong.listenwechatnotification.function.AlipaySimulation; import com.yuqirong.listenwechatnotification.function.AlipaySimulation;
import com.yuqirong.listenwechatnotification.function.JobAwaken; import com.yuqirong.listenwechatnotification.function.JobAwaken;
import com.yuqirong.listenwechatnotification.function.ParseImageFunc;
import com.yuqirong.listenwechatnotification.function.QRCodeFunction; import com.yuqirong.listenwechatnotification.function.QRCodeFunction;
import com.yuqirong.listenwechatnotification.function.WeChatFunction; import com.yuqirong.listenwechatnotification.function.WeChatFunction;
import com.yuqirong.listenwechatnotification.function.WeChatSimulation; import com.yuqirong.listenwechatnotification.function.WeChatSimulation;
import com.yuqirong.listenwechatnotification.http.PayHttp;
import com.yuqirong.listenwechatnotification.uitl.PayTypeSingleTon; import com.yuqirong.listenwechatnotification.uitl.PayTypeSingleTon;
import com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences;
import com.yuqirong.listenwechatnotification.uitl.Utils; import com.yuqirong.listenwechatnotification.uitl.Utils;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
...@@ -25,8 +37,14 @@ import org.greenrobot.eventbus.Subscribe; ...@@ -25,8 +37,14 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import static com.yuqirong.listenwechatnotification.bean.WorkAction.ACTION_TYPE_NONE; import static com.yuqirong.listenwechatnotification.bean.WorkAction.ACTION_TYPE_NONE;
/** /**
...@@ -52,6 +70,7 @@ public class MyAccessibilityService extends AccessibilityService { ...@@ -52,6 +70,7 @@ public class MyAccessibilityService extends AccessibilityService {
private ArrayList<String> moneylist = new ArrayList<>(); private ArrayList<String> moneylist = new ArrayList<>();
private int ACTION_TYPE = ACTION_TYPE_NONE; private int ACTION_TYPE = ACTION_TYPE_NONE;
private String TARGET_APP_TYPE = Utils.payTypeZFB;
// @Override // @Override
// public void onCreate() { // public void onCreate() {
// android.os.Debug.waitForDebugger(); // android.os.Debug.waitForDebugger();
...@@ -119,13 +138,54 @@ public class MyAccessibilityService extends AccessibilityService { ...@@ -119,13 +138,54 @@ public class MyAccessibilityService extends AccessibilityService {
if (moneylist.size() == indexCount){ if (moneylist.size() == indexCount){
Log.d(TAG, "这次任务已经完成!"); Log.d(TAG, "这次任务已经完成!");
if (PayTypeSingleTon.newInstance().getPayType().equals(Utils.payTypeZFB)){ if (this.TARGET_APP_TYPE.equals(Utils.payTypeZFB)){
QRCodeFunction qrThread = new QRCodeFunction("QRCodeFunction---ZFB", Utils.ZFBImgPath); ParseImageFunc parseImageFunc = new ParseImageFunc();
qrThread.start(); parseImageFunc.start(Utils.ZFBImgPath, new ParseImageFunc.ParseListener() {
@Override
public void onStartWork() {
Observable.just("图片保存完毕,准备解析")
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<String>() {
@Override
public void accept(String s) throws Exception {
Toast.makeText(MyApplication.get(),s,Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onWorkDone(List<ImageBean> list) {
String username = Save2SharedPreferences.read(MainActivity.ALIPAYNAME,MyApplication.get());
postQRcodeResult(username,Utils.payChannelZFB);
}
});
// QRCodeFunction qrThread = new QRCodeFunction("QRCodeFunction---ZFB", Utils.ZFBImgPath);
// qrThread.start();
}else{ }else{
QRCodeFunction qrThread = new QRCodeFunction("QRCodeFunction---WEIXIN", Utils.WeiXinImgPath); ParseImageFunc parseImageFunc = new ParseImageFunc();
qrThread.start(); parseImageFunc.start(Utils.WeiXinImgPath, new ParseImageFunc.ParseListener() {
@Override
public void onStartWork() {
Observable.just("图片保存完毕,准备解析")
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<String>() {
@Override
public void accept(String s) throws Exception {
Toast.makeText(MyApplication.get(),s,Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onWorkDone(List<ImageBean> list) {
String username = Save2SharedPreferences.read(MainActivity.WECHATPAYNAME,MyApplication.get());
postQRcodeResult(username,Utils.payChannelWX);
}
});
} }
moneylist.clear(); moneylist.clear();
...@@ -150,6 +210,10 @@ public class MyAccessibilityService extends AccessibilityService { ...@@ -150,6 +210,10 @@ public class MyAccessibilityService extends AccessibilityService {
} }
} }
/**
* 二维码识别入口
* @param moneylist
*/
@Subscribe(threadMode = ThreadMode.ASYNC) @Subscribe(threadMode = ThreadMode.ASYNC)
public void Event(ArrayList<String> moneylist){ public void Event(ArrayList<String> moneylist){
for (String s:moneylist for (String s:moneylist
...@@ -189,22 +253,25 @@ public class MyAccessibilityService extends AccessibilityService { ...@@ -189,22 +253,25 @@ public class MyAccessibilityService extends AccessibilityService {
} }
} }
/**
* 这个是用来拉取账单的 跑二维码识别还是上面的
* @param action
*/
@Subscribe(threadMode = ThreadMode.ASYNC) @Subscribe(threadMode = ThreadMode.ASYNC)
public void OnBillEvent(WorkAction action){ public void OnBillEvent(WorkAction action){
this.ACTION_TYPE = action.getType();
this.TARGET_APP_TYPE = action.getTargetAppType();
if (action.getType() == WorkAction.ACTION_TYPE_BILL){ if (action.getType() == WorkAction.ACTION_TYPE_BILL){
alipayBill = new AlipayBill(); alipayBill = new AlipayBill();
this.ACTION_TYPE = action.getType();
JobAwaken awaken = new JobAwaken(); JobAwaken awaken = new JobAwaken();
awaken.awakenAPliay(getApplicationContext()); awaken.awakenAPliay(getApplicationContext());
}else { }else if (action.getType() == WorkAction.ACTION_TYPE_MONEY){
for (String s:moneylist this.moneylist = action.getMoneys();
) { for (String s:moneylist) {
Log.d(TAG, "Event: "+s); Log.d(TAG, "Event: "+s);
} }
this.moneylist = moneylist;
if (PayTypeSingleTon.newInstance().getPayType().equals(Utils.payTypeZFB)) { if (action.getTargetAppType().equals(Utils.payTypeZFB)) {
alipaySimulation = new AlipaySimulation(moneylist, getApplicationContext()) { alipaySimulation = new AlipaySimulation(moneylist, getApplicationContext()) {
@Override @Override
public void jump2Menu(AlipayFunction function) { public void jump2Menu(AlipayFunction function) {
...@@ -290,6 +357,40 @@ public class MyAccessibilityService extends AccessibilityService { ...@@ -290,6 +357,40 @@ public class MyAccessibilityService extends AccessibilityService {
} }
} }
public static void testQRcodeResult(){
String username = Save2SharedPreferences.read(MainActivity.ALIPAYNAME,MyApplication.get());
postQRcodeResult(username,Utils.payChannelZFB);
}
public static void postQRcodeResult(String userName,String channel){
SharedPreferences sp = MyApplication.get().getSharedPreferences("result", Context.MODE_PRIVATE);
String parseResult = sp.getString("result","");
if (TextUtils.isEmpty(parseResult)){
return;
}
ArrayList<ImageBean> imageBeans = new Gson().fromJson(parseResult, OneBatchResult.class).getList();
String token = Save2SharedPreferences.read(MainActivity.TOKEN, MyApplication.get());
HashMap<String,Object> params = new HashMap<>();
params.put("gateway",channel);
params.put("token",token);
params.put("data",imageBeans);
params.put("username",userName);
PayHttp.get().pushZFBCashList(params)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<BaseResult>() {
@Override
public void accept(BaseResult baseResult) throws Exception {
Toast.makeText(MyApplication.get(), "上报结果"+baseResult.getMessage(), Toast.LENGTH_SHORT).show();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Toast.makeText(MyApplication.get(), throwable.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
public static boolean findNodeByText(String text,AccessibilityService service){ public static boolean findNodeByText(String text,AccessibilityService service){
......
...@@ -133,6 +133,7 @@ ...@@ -133,6 +133,7 @@
<Button <Button
android:id="@+id/bt_jianting" android:id="@+id/bt_jianting"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp" android:layout_height="50dp"
android:text="监听" /> android:text="监听" />
...@@ -145,10 +146,11 @@ ...@@ -145,10 +146,11 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="50dp" android:layout_height="50dp"
android:text="测试" /> android:text="生成上报二维码" />
<Button <Button
android:id="@+id/btn_test_bill" android:id="@+id/btn_test_bill"
android:layout_weight="1" android:layout_weight="1"
android:visibility="gone"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="50dp" android:layout_height="50dp"
android:text="测试账单" /> android:text="测试账单" />
......
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