Commit 00e1b484 by 严琪

保存部分开发功能

parent fe95833b
......@@ -24,7 +24,7 @@
<application
android:exported="false"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/logo"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
......@@ -48,39 +48,43 @@
</intent-filter>
</service>
<service
android:exported="false"
android:name="com.yuqirong.listenwechatnotification.service.WeChatAccessibilityService"
android:label="@string/app_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessible_service_config" />
</service>
<!--<service android:name=".service.MyAccessibilityService"-->
<!--android:enabled="true"-->
<!--android:label="@string/accessibility_service_label"-->
<!--android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" >-->
<!--<service-->
<!--android:exported="false"-->
<!--android:name="com.yuqirong.listenwechatnotification.service.WeChatAccessibilityService"-->
<!--android:label="@string/app_name"-->
<!--android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">-->
<!--<intent-filter>-->
<!--<action android:name="android.accessibilityservice.AccessibilityService" />-->
<!--</intent-filter>-->
<!--<meta-data-->
<!--android:name="android.accessibilityservice"-->
<!--android:resource="@xml/accessibility_service_config" />-->
<!--android:resource="@xml/accessible_service_config" />-->
<!--</service>-->
<receiver android:name=".broadcastReceiver.MyAwakenReceiver"
>
<service
android:exported="false"
android:name=".service.MyAccessibilityService"
android:enabled="true"
android:label="@string/accessibility_service_label"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" >
<intent-filter>
<action android:name="APliayAwaken" />
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
<receiver
android:exported="false"
android:name=".broadcastReceiver.MyAwakenReceiver"
>
<intent-filter>
<action android:name="APliayAwaken" />
</intent-filter>
</receiver>
</application>
</manifest>
\ No newline at end of file
......@@ -6,9 +6,11 @@ import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
......@@ -18,20 +20,21 @@ import android.widget.Toast;
import com.yuqirong.listenwechatnotification.askhttp.UpdateApk;
import com.yuqirong.listenwechatnotification.bean.ImageBean;
import com.yuqirong.listenwechatnotification.broadcastReceiver.MyCashReceiver;
import com.yuqirong.listenwechatnotification.function.BuildUrlsFunction;
import com.yuqirong.listenwechatnotification.service.WeChatNotificationListenerService;
import com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences;
import com.yuqirong.listenwechatnotification.uitl.Utils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public class MainActivity extends ParentActivity {
private TextView versionCode;
private TextView button2;
private Button buttonUpDate;
private Button buttonMoNi;
private String stringAliPay;
private String stringWeChatPay;
......@@ -43,10 +46,11 @@ public class MainActivity extends ParentActivity {
public static String API = "key2";
String TAG = "MainActivity";
private BuildUrlsFunction functionUrls;
private Save2SharedPreferences save2SharedPreferences;
private AlarmManager am;
private PendingIntent pi;
private MyCashReceiver my;
@Override
public void setOnContentLayoutId(int id) {
......@@ -55,7 +59,7 @@ public class MainActivity extends ParentActivity {
@Override
public void initView() {
functionUrls = new BuildUrlsFunction();
save2SharedPreferences = new Save2SharedPreferences();
final EditText etText1 = (EditText) findViewById(R.id.et_text1);
......@@ -84,18 +88,34 @@ public class MainActivity extends ParentActivity {
}
});
button2 = (Button) findViewById(R.id.bt_button2);
button2.setOnClickListener(new View.OnClickListener() {
buttonUpDate = (Button) findViewById(R.id.bt_button2);
buttonUpDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
checkPermission();
}
});
EventBus.getDefault().register(this);
buttonMoNi= (Button) findViewById(R.id.bt_jianting);
buttonMoNi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// TODO: 2018/3/2 0002 测试开始
Intent intent = new Intent("CashPull");
sendBroadcast(intent);
}
});
String code = "当前版本号:"+Utils.getLocalVersionName(this)+"";
versionCode.setText(code);
checkNotificationPermission();
awakenUpFucntion();
IntentFilter filter = new IntentFilter();
filter.addAction("CashPull");
my = new MyCashReceiver();
registerReceiver(my,filter);
// timingRequest();
}
......@@ -179,6 +199,29 @@ private void checkNotificationPermission() {
am.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(),5000*60*60,pi);
}
/**
* 呼叫支付宝
*/
private void timingRequest (){
//创建Intent对象,action为APliayAwaken,附加信息为字符串“支付宝起来吧”
Intent intent = new Intent("CashPull");
intent.putExtra("msg","你该打酱油了");
// ComponentName cn = new ComponentName(getPackageName(), MyAwakenReceiver.class.get());
// intent.setComponent(cn);
//定义一个PendingIntent对象,PendingIntent.getBroadcast包含了sendBroadcast的动作。
//也就是发送了action 为"ELITOR_CLOCK"的intent
pi = PendingIntent.getBroadcast(this,0,intent,0);
//AlarmManager对象,注意这里并不是new一个对象,Alarmmanager为系统级服务
am = (AlarmManager)getSystemService(ALARM_SERVICE);
//设置闹钟从当前时间开始,每隔5s执行一次PendingIntent对象pi,注意第一个参数与第二个参数的关系
// 5秒后通过PendingIntent pi对象发送广播
am.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(),5000,pi);
}
@Override
protected void onResume() {
super.onResume();
......@@ -190,19 +233,11 @@ private void checkNotificationPermission() {
protected void onPause() {
super.onPause();
if (isFinishing()){
EventBus.getDefault().unregister(this);
unregisterReceiver(my);
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void Event(ImageBean bean){
functionUrls.getBeans().add(bean);
Log.d(TAG, "Event: "+bean.getUrl());
}
@Override
protected void onDestroy() {
super.onDestroy();
......
package com.yuqirong.listenwechatnotification.askhttp;
import android.content.Context;
import android.util.Log;
import com.yuqirong.listenwechatnotification.function.BuildNotification;
import com.yuqirong.listenwechatnotification.http.HttpPresent;
import com.yuqirong.listenwechatnotification.http.HttpService;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
......@@ -15,19 +14,34 @@ import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;
import static android.content.ContentValues.TAG;
/**
* Created by yanqi on 2018/2/22 0022.
* 获取金额数据
* Created by yanqi on 2018/3/2 0002.
*/
public class GetMoney implements HttpPresent {
public class ActivePullCashList implements HttpPresent {
public ActivePullCashList() {
public GetMoney() {
}
public void doGetMoney(String notify_text, String pay_to, String type, final Context context){
//建立retrofit对象
// TODO: 2018/2/27 0027 测试生成数据
public void testPullList(){
ArrayList<String> moneylist = new ArrayList<>();
moneylist.add("0.01");
moneylist.add("1.01");
moneylist.add("2.01");
EventBus.getDefault().post(moneylist);
}
public void pullList(String channel,String username){
Retrofit retrofit = new Retrofit.Builder().baseUrl(HttpService.base_url)
//添加返回字符串的支持--不知道返回的是什么,添加字符串支持
.addConverterFactory(ScalarsConverterFactory.create())
......@@ -35,32 +49,26 @@ public class GetMoney implements HttpPresent {
.addConverterFactory(GsonConverterFactory.create())
.build();
//获取接口
HttpService service = retrofit.create(HttpService.class);
//调用方法-返回 回调更换为对象
Call<String> call = service.postClientMoney(notify_text,pay_to,type);
//异步调用
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
;
BuildNotification mBuildNotification = new BuildNotification(context);
if(response.body()!="") {
mBuildNotification.postSuccessOrFaild(response.body());
}
Log.d(TAG, "onResponse: "+response.body());
success();
}
@Override
public void onFailure(Call<String> call, Throwable t) {
failed();
}
});
}
Call<ArrayList<String>> call = service.pullZFBCashList(channel,username);
call.enqueue(new Callback<ArrayList<String>>() {
@Override
public void onResponse(Call<ArrayList<String>> call, Response<ArrayList<String>> response) {
ArrayList<String> object = response.body();
EventBus.getDefault().post(object);
}
@Override
public void onFailure(Call<ArrayList<String>> call, Throwable t) {
}
});
}
@Override
public String success() {
......
package com.yuqirong.listenwechatnotification.askhttp;
import com.yuqirong.listenwechatnotification.bean.ImageBean;
import com.yuqirong.listenwechatnotification.http.HttpPresent;
import com.yuqirong.listenwechatnotification.http.HttpService;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;
/**
* 发送金额数据
*
* Created by yanqi on 2018/3/2 0002.
*/
public class ActivePushCashList implements HttpPresent {
public ActivePushCashList() {
}
public void pushCashList(ArrayList<ImageBean> list){
Retrofit retrofit = new Retrofit.Builder().baseUrl(HttpService.base_url)
//添加返回字符串的支持--不知道返回的是什么,添加字符串支持
.addConverterFactory(ScalarsConverterFactory.create())
//添加GSON转换支持
.addConverterFactory(GsonConverterFactory.create())
.build();
//获取接口
HttpService service = retrofit.create(HttpService.class);
}
@Override
public String success() {
return null;
}
@Override
public String failed() {
return null;
}
}
package com.yuqirong.listenwechatnotification.broadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.yuqirong.listenwechatnotification.askhttp.ActivePullCashList;
/**
* Created by yanqi on 2018/3/2 0002.
*/
public class MyCashReceiver extends BroadcastReceiver {
private String TAG = "MyCashReceiver";
ActivePullCashList activePull;
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive: 开始运行");
activePull = new ActivePullCashList();
// activePull.testPullList();
Log.d(TAG, "onReceive: 结束运行");
}
}
......@@ -134,11 +134,11 @@ public class AlipayFunction {
/**
* 点击保存图片按钮
*/
public void functionSavePicButton(List<AccessibilityNodeInfo> infos,String filename){
public void functionSavePicButton(List<AccessibilityNodeInfo> infos){
for (int i = 0;i<infos.size();i++) {
AccessibilityNodeInfo node = infos.get(0);
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
reNameImageFile(filename);
// reNameImageFile(filename);
Log.d(TAG, "functionStartClick: "+SixthStep);
zhiFuBaoStatus.setSixthStepStatus(true);
}
......
......@@ -19,10 +19,14 @@ import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Result;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.QRCodeReader;
import com.yuqirong.listenwechatnotification.askhttp.ActivePullCashList;
import com.yuqirong.listenwechatnotification.askhttp.ActivePushCashList;
import com.yuqirong.listenwechatnotification.bean.ImageBean;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.HashMap;
......@@ -38,6 +42,7 @@ import static android.graphics.BitmapFactory.decodeFile;
public class QRCodeFunction extends Thread{
private static String TAG = "QRCodeFunction";
private BuildUrlsFunction functionUrls;
public QRCodeFunction(String name) {
super(name);
......@@ -46,7 +51,7 @@ public class QRCodeFunction extends Thread{
@Override
public void run() {
super.run();
functionUrls = new BuildUrlsFunction();
functionFoundImageFile();
......@@ -85,6 +90,9 @@ public class QRCodeFunction extends Thread{
) {
parseCode(f);
}
ActivePushCashList activePushCashList = new ActivePushCashList();
activePushCashList.pushCashList(this.functionUrls.getBeans());
interrupt();
}
......@@ -107,13 +115,19 @@ public class QRCodeFunction extends Thread{
} catch (FormatException e) {
e.printStackTrace();
}
// Log.d(TAG, "parseCode: "+re.getText());
// file.delete();
ImageBean bean = new ImageBean();
bean.setUrl(re.getText());
bean.setDescription("");
EventBus.getDefault().post(bean);
}
bean.setDescription(file.getName());
this.functionUrls.getBeans().add(bean);
Log.d(TAG, "parseCode: "+bean.getUrl());
}
@Override
public void interrupt() {
super.interrupt();
Log.d(TAG, "parseCode: 线程结束");
}
}
package com.yuqirong.listenwechatnotification.http;
import com.yuqirong.listenwechatnotification.bean.ImageBean;
import com.yuqirong.listenwechatnotification.bean.UpdateBean;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.GET;
......@@ -17,9 +21,16 @@ public interface HttpService {
public String base_url = "http://test.haoyiwangluo.com/";
@POST("index/pay/notify/person_app")
Call<String> postClientMoney(@Field("notify_text") String notify_text, @Field("pay_to") String pay_to, @Field("type") String type);
public String test_base_url = "http://test.fourth-pay.checheng.net/app-api/";
@GET("app/status")
Call<UpdateBean> postSoftVersion(@Query("version") String version);
@POST("amounts")
Call<ArrayList<String>> pullZFBCashList(@Field("channel") String channel,@Field("username") String username);
@POST("amounts/submit")
Call<String> pushZFBCashList(@Field("channel") String channel,@Field("username") String username);
}
......@@ -7,7 +7,14 @@ import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import com.yuqirong.listenwechatnotification.bean.ImageBean;
import com.yuqirong.listenwechatnotification.function.AlipayFunction;
import com.yuqirong.listenwechatnotification.function.JobAwaken;
import com.yuqirong.listenwechatnotification.function.QRCodeFunction;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
......@@ -22,7 +29,9 @@ public class MyAccessibilityService extends AccessibilityService {
private static String TAG = "MyAccessibilityService";
private static String PACKAGENAME = "com.eg.android.AlipayGphone";
//获取到列表先从 -1开始
private static int indexCount = -1;
private static boolean beginRun = false;
AccessibilityServiceInfo mInfo;
AlipayFunction function;
......@@ -46,18 +55,12 @@ public class MyAccessibilityService extends AccessibilityService {
// super.onCreate();
// }
// TODO: 2018/2/27 0027 测试生成数据
private void buildTestMoney(){
indexCount = 0;
moneylist.add("0.01");
moneylist.add("1.01");
moneylist.add("2.01");
}
@Override
protected void onServiceConnected() {
super.onServiceConnected();
buildTestMoney();
EventBus.getDefault().register(this);
Log.v(TAG, "服务连接了,开始初始化工作...");
mInfo = new AccessibilityServiceInfo();
......@@ -76,6 +79,10 @@ public class MyAccessibilityService extends AccessibilityService {
Log.v(TAG, className);
Log.v(TAG, packageName);
if (moneylist.size() == 0){
Log.d(TAG, "无效任务!没有金额数据");
return;
}
//最后要多一步
if (moneylist.size() == indexCount){
Log.d(TAG, "这次任务已经完成!");
......@@ -94,18 +101,19 @@ public class MyAccessibilityService extends AccessibilityService {
return ;
}
if (className.equals(secondClassName)){
if (className.equals(secondClassName) && function.getZhiFuBaoStatus().isFirstStepStatus()){
function.functionMoneyClick();
return ;
}
if (className.equals(thirdClassName)&&!function.getZhiFuBaoStatus().isThirdStepStatus()){
if (className.equals(thirdClassName)){
List<AccessibilityNodeInfo> nodes = getRootInActiveWindow().findAccessibilityNodeInfosByText(AlipayFunction.ThirdStep);
function.functionSetMoneyText(nodes);
return ;
}
if (className.equals(fourthClassName)){
//这边多加一个判断,防止任务结束之后出现问题,第四步一定在第三步成功前提下运行
if (className.equals(fourthClassName) && function.getZhiFuBaoStatus().isThirdStepStatus()){
function.functionSetMoneyInputView();
return ;
}
......@@ -122,18 +130,46 @@ public class MyAccessibilityService extends AccessibilityService {
if (className.equals(fifthClassName)){
List<AccessibilityNodeInfo> nodes = getRootInActiveWindow().findAccessibilityNodeInfosByText(AlipayFunction.SixthStep);;
function.functionSavePicButton(nodes,moneylist.get(indexCount)+"");
function.functionSavePicButton(nodes);
return ;
}
if (className.equals(sixthClassName)&&eventType == AccessibilityNodeInfo.ACTION_FOCUS && function.getZhiFuBaoStatus().isSixthStepStatus()){
function.reNameImageFile(moneylist.get(indexCount)+"");
indexCount++;
performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
function.resetStatus();
if (moneylist.size() == indexCount){
Log.d(TAG, "这次任务已经完成!");
moneylist.clear();
QRCodeFunction qrThread = new QRCodeFunction("QRCodeFunction");
qrThread.run();
}
return ;
}
}
@Subscribe(threadMode = ThreadMode.ASYNC)
public void Event(ArrayList<String> moneylist){
for (String s:moneylist
) {
Log.d(TAG, "Event: "+s);
}
this.moneylist = moneylist;
indexCount = 0;
function.resetStatus();
JobAwaken awaken = new JobAwaken();
awaken.awakenAPliay(getApplicationContext());
}
@Override
public void onInterrupt() {
Log.v(TAG, "服务关闭了...");
......@@ -142,6 +178,7 @@ public class MyAccessibilityService extends AccessibilityService {
@Override
public boolean onUnbind(Intent intent) {
Log.v(TAG, "服务解绑了,释放资源操作...");
EventBus.getDefault().unregister(this);
return super.onUnbind(intent);
}
......
......@@ -16,7 +16,6 @@ import android.widget.RemoteViews;
import com.yuqirong.listenwechatnotification.function.BuildNotification;
import com.yuqirong.listenwechatnotification.MainActivity;
import com.yuqirong.listenwechatnotification.askhttp.GetMoney;
import com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences;
import java.io.IOException;
......
......@@ -107,6 +107,13 @@
android:text="升级"
/>
<Button
android:id="@+id/bt_jianting"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="监听"
/>
<TextView
android:id="@+id/versiontext"
......
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