Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhengli
/
wechat_click
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
972d8d8b
authored
Mar 28, 2018
by
jeffrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.3 逻辑优化
parent
09ff24fa
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
482 additions
and
226 deletions
+482
-226
app/build.gradle
+2
-2
app/src/main/AndroidManifest.xml
+1
-0
app/src/main/java/com/xf/weixinclick/MainActivity.java
+19
-10
app/src/main/java/com/xf/weixinclick/NewService.java
+392
-181
app/src/main/java/com/xf/weixinclick/bean/DelayBean.java
+3
-1
app/src/main/java/com/xf/weixinclick/receiver/MyMessageReceiver.java
+28
-32
app/src/main/java/com/xf/weixinclick/utils/NotificationUtils.java
+37
-0
No files found.
app/build.gradle
View file @
972d8d8b
...
...
@@ -22,8 +22,8 @@ android {
applicationId
"com.xf.weixinclick"
minSdkVersion
16
targetSdkVersion
25
versionCode
3
versionName
"1.
2
"
versionCode
4
versionName
"1.
3
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild
{
cmake
{
...
...
app/src/main/AndroidManifest.xml
View file @
972d8d8b
...
...
@@ -66,6 +66,7 @@
android:name=
".NewService"
android:enabled=
"true"
android:exported=
"true"
android:process=
":remote"
android:label=
"@string/app_name"
android:permission=
"android.permission.BIND_ACCESSIBILITY_SERVICE"
>
<intent-filter>
...
...
app/src/main/java/com/xf/weixinclick/MainActivity.java
View file @
972d8d8b
...
...
@@ -61,7 +61,7 @@ public class MainActivity extends BaseActivity {
@Override
void
initAction
()
{
Log
.
d
(
"fei"
,
"测试下魅族log"
);
HeartBeatAction
.
get
().
start
();
...
...
@@ -119,14 +119,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.setComponent(cmp);
//
startActivity(intent);
new
Thread
(
new
Runnable
()
{
...
...
@@ -142,7 +142,9 @@ 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
);
// EventBus.getDefault().post(msg);
startWorkService
(
MainActivity
.
this
,
msg
);
}
}).
start
();
...
...
@@ -151,6 +153,13 @@ public class MainActivity extends BaseActivity {
}
public
static
void
startWorkService
(
Context
context
,
ReceiverMsg
msg
){
Intent
intent
=
new
Intent
(
context
,
NewService
.
class
);
intent
.
putExtra
(
NewService
.
PARAMS_MSG
,
msg
);
context
.
startService
(
intent
);
}
public
static
String
getLocalVersionName
(
Context
ctx
)
{
String
localVersion
=
""
;
try
{
...
...
app/src/main/java/com/xf/weixinclick/NewService.java
View file @
972d8d8b
...
...
@@ -2,10 +2,12 @@ package com.xf.weixinclick;
import
android.accessibilityservice.AccessibilityService
;
import
android.annotation.SuppressLint
;
import
android.app.KeyguardManager
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.graphics.Rect
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
...
...
@@ -21,9 +23,7 @@ import com.xf.weixinclick.bean.msg.ReceiverMsg;
import
com.xf.weixinclick.http.HttpClientApi
;
import
com.xf.weixinclick.http.HttpSubscriber
;
import
com.xf.weixinclick.receiver.WeChatStatus
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
import
com.xf.weixinclick.utils.NotificationUtils
;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
...
...
@@ -42,7 +42,6 @@ import static com.xf.weixinclick.receiver.WeChatStatus.needClick;
import
static
com
.
xf
.
weixinclick
.
receiver
.
WeChatStatus
.
needClick2
;
import
static
com
.
xf
.
weixinclick
.
receiver
.
WeChatStatus
.
needClick3
;
import
static
com
.
xf
.
weixinclick
.
receiver
.
WeChatStatus
.
needClick4
;
import
static
com
.
xf
.
weixinclick
.
receiver
.
WeChatStatus
.
status
;
/**
* 创建日期:2018/2/24 on 15:44
...
...
@@ -51,207 +50,313 @@ import static com.xf.weixinclick.receiver.WeChatStatus.status;
*/
public
class
NewService
extends
AccessibilityService
{
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"
;
int
isSuccess
=
1
;
int
isFalse
=
0
;
boolean
locked
=
false
;
private
KeyguardManager
.
KeyguardLock
kl
;
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
;
long
times
=
0
;
int
tempX
=
50
;
int
tempY
=
50
;
boolean
clickDone
=
false
;
@Subscribe
public
void
receiverMsg
(
final
ReceiverMsg
msg
)
{
Log
.
d
(
"fei "
,
"receiverMsg"
);
if
(!
isHome
()){
Log
.
d
(
"fei "
,
"当前页不是首页"
);
showToast
(
getApplicationContext
(),
"当前页不是首页"
);
turnBack
(
isFalse
,
2
);
return
;
}
//收到消息后 打开文件传输助手
Log
.
d
(
"fei "
,
"点击文件传输助手"
);
delayBean
=
msg
.
getTime_config
();
if
(
delayBean
==
null
){
Log
.
d
(
"fei "
,
"delayBean 是空"
);
}
execShellCmd
(
"input tap 220 200"
);
//发送触发的消息给service,难道微信没有触发?
delayDeal
(
delayBean
.
getAfter_open_weixin_file_helper_delay
(),
new
IDelayMethord
()
{
@Override
public
void
delayMethord
()
{
clickDone
=
true
;
// showToast(getApplicationContext(),"消息的 unique_id 是 " + msg.getUnique_id());
Log
.
d
(
"fei "
,
"receiverMsg里面触发下页面消息 unique_id "
+
msg
.
getUnique_id
());
WeChatStatus
.
receiverMsg
();
Url
=
msg
.
getQr_addr
();
Log
.
d
(
"fei "
,
"receiverMsg里面触发下页面消息 Url "
+
Url
);
message_id
=
msg
.
getUnique_id
();
AccessibilityEvent
accessibilityEvent
=
AccessibilityEvent
.
obtain
(
32
);
accessibilityEvent
.
setClassName
(
WeChatUi
);
onAccessibilityEvent
(
accessibilityEvent
);
}
});
@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
;
// delayDeal(500, new MyAccessibilityService.IDelayMethord() {
// @Override
// public void delayMethord() {
// execShellCmd("input tap 150 200");
// }
// });
// delayDeal(2000, new MyAccessibilityService.IDelayMethord() {
// @Override
// public void delayMethord() {
// WeChatStatus.receiverMsg();
// Url = msg.getQr_addr();
// message_id = msg.getUnique_id();
// AccessibilityEvent accessibilityEvent = AccessibilityEvent.obtain(32);
// accessibilityEvent.setClassName(WeChatUi);
// onAccessibilityEvent(accessibilityEvent);
// }
// });
awakeWechat
(
getApplicationContext
());
}
//当service因为低内存被杀掉后,等内存足够时可以重启
return
START_STICKY
;
}
// @Subscribe
// public void receiverMsg(final ReceiverMsg msg) {
// Log.d("fei ", "receiverMsg");
// if (!isHome()){
// Log.d("fei ", "当前页不是首页");
// showToast(getApplicationContext(),"当前页不是首页");
// turnBack(isFalse,2);
// return;
// }
// //收到消息后 打开文件传输助手
// Log.d("fei ", "点击文件传输助手");
// delayBean = msg.getTime_config();
// if (delayBean == null){
// Log.d("fei ", "delayBean 是空");
// }
//
// execShellCmd("input tap 220 200");
//
//
//
// //发送触发的消息给service,难道微信没有触发?
// delayDeal(delayBean.getAfter_open_weixin_file_helper_delay(), new IDelayMethord() {
// @Override
// public void delayMethord() {
//
// clickDone = true;
//// showToast(getApplicationContext(),"消息的 unique_id 是 " + msg.getUnique_id());
//
// Log.d("fei ", "receiverMsg里面触发下页面消息 unique_id " + msg.getUnique_id());
// WeChatStatus.receiverMsg();
// Url = msg.getQr_addr();
// Log.d("fei ", "receiverMsg里面触发下页面消息 Url " + Url);
// message_id = msg.getUnique_id();
// AccessibilityEvent accessibilityEvent = AccessibilityEvent.obtain(32);
// accessibilityEvent.setClassName(WeChatUi);
// onAccessibilityEvent(accessibilityEvent);
// }
// });
//
//
// }
@Override
public
void
onAccessibilityEvent
(
AccessibilityEvent
event
)
{
Log
.
d
(
"fei"
,
"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
);
if
(!
className
.
contains
(
MM_PNAME
))
{
return
;
}
Log
.
d
(
"maptrix "
,
"get event = "
+
eventType
+
" class "
+
className
);
Log
.
d
(
" maptrix"
,
"status "
+
status
[
0
]
+
status
[
1
]
+
status
[
2
]
+
status
[
3
]);
if
(
eventType
==
32
&&
className
.
contains
(
"WebviewScanImageActivity"
))
{
if
(
taskMsg
==
null
){
Log
.
d
(
TAG
,
"NewService but taskMsg is null"
);
return
;
}
if
(
WeChatStatus
.
isClose
())
{
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
);
}
switch
(
eventType
)
{
//点击事件
case
32
:
switch
(
className
)
{
case
WeChatUi:
if
(
clickDone
){
Log
.
d
(
"fei "
,
"点击过了文件传输助手 ,准备下一步"
);
delayDeal
(
1000
,
new
IDelayMethord
()
{
@Override
public
void
delayMethord
()
{
if
(
WeChatStatus
.
status
[
0
]
)
{
Log
.
d
(
"fei "
,
"进入文件传输详情页面"
);
if
(
fill
())
{
//填充完了 有时候发送不出现,那就再点击下文字 ,点完了要变下空白区域 让输入框消失
execShellCmd
(
"input tap "
+
dip2px
(
130
)
+
" "
+
dip2px
(
600
));
execShellCmd
(
"input tap "
+
dip2px
(
10
)
+
" "
+
dip2px
(
200
));
Log
.
d
(
"fei "
,
"文件传输详情页面_填充成功准备发送"
);
delayDeal
(
delayBean
.
getAfter_paste_message_delay
(),
new
IDelayMethord
()
{
@Override
public
void
delayMethord
()
{
Log
.
d
(
"fei "
,
"文件传输详情页面_发送"
);
send
();
}
});
delayDeal
(
delayBean
.
getAfter_paste_message_delay
()+
delayBean
.
getAfter_send_message_delay
()+
2000
,
new
IDelayMethord
()
{
@Override
public
void
delayMethord
()
{
Log
.
d
(
"fei"
,
"文件传输详情页面_点击发送的文字"
);
clickMsg
(
getRootInActiveWindow
());
}
});
WeChatStatus
.
finishClick
();
}
else
{
Log
.
d
(
"fei"
,
"文件传输详情页面_填充失败"
);
}
}
}
});
}
else
{
Log
.
d
(
"fei "
,
"没有点击过了文件传输助手什么都不干"
);
}
break
;
case
WeChatWebView:
if
(
WeChatStatus
.
status
[
1
])
{
WeChatStatus
.
longPressCodeFinish
();
Log
.
d
(
"fei"
,
"长按二维码"
);
longPress
();
}
else
if
(
WeChatStatus
.
status
[
3
]&&!
WeChatStatus
.
status
[
2
])
{
//这里加一句 第二步已经完成
WeChatStatus
.
pressSureFinish
();
Log
.
d
(
"fei"
,
"点击确认关注"
);
pressSure
();
}
break
;
case
WeChatAlert:
if
(
WeChatStatus
.
status
[
2
])
{
delayDeal
(
delayBean
.
getLong_press_qrcode_delay
(),
new
IDelayMethord
()
{
@Override
public
void
delayMethord
()
{
Log
.
d
(
"fei"
,
"点击识别二维码"
);
pressImg
();
}
});
}
break
;
default
:
break
;
}
break
;
default
:
break
;
if
(
step
==
0
&&
findNodeByTexts
(
this
,
"微信"
,
"通讯录"
,
"发现"
,
"我"
)){
//点击文件传输助手的位置
//最好还是找到文字然后点击位置
//没办法 首页打印出来的是通讯录的布局,所以坐标是错误的
execShellCmd
(
"input tap 220 200"
);
// clickHomeWJCSZS();
step
++;
}
if
(
step
==
1
){
printAllNode
();
}
// && findNodeByTexts(this,"文件传输助手")
if
(
step
==
1
){
step
++;
Log
.
d
(
TAG
,
"文件传输详情页面_填充_准备"
);
delayDeal
(
5000
,
new
IDelayMethord
()
{
@Override
public
void
delayMethord
()
{
Log
.
d
(
TAG
,
"文件传输详情页面_填充"
);
printAllNode
();
if
(
fill
()){
Log
.
d
(
TAG
,
"文件传输详情页面_填充_完成"
);
send
();
clickMsg
(
getRootInActiveWindow
());
step
++;
}
else
{
Log
.
d
(
TAG
,
"文件传输详情页面_填充_失败"
);
}
}
});
}
// if (step == 4 && findNodeByTexts(this,"文件传输助手")){
// //填充完了 有时候发送不出现,那就再点击下文字 ,点完了要变下空白区域 让输入框消失
// execShellCmd("input tap " + dip2px(130) + " " + dip2px(600));
// execShellCmd("input tap " + dip2px(10) + " " + dip2px(200));
// Log.d(TAG, "文件传输详情页面_发送");
// send();
// step++;
//
// }
// if (step == 4 && findNodeByTexts(this,"文件传输助手")){
// //填充完了 有时候发送不出现,那就再点击下文字 ,点完了要变下空白区域 让输入框消失
// execShellCmd("input tap " + dip2px(130) + " " + dip2px(600));
// execShellCmd("input tap " + dip2px(10) + " " + dip2px(200));
// Log.d(TAG, "文件传输详情页面_点击发送的文字");
// clickMsg(getRootInActiveWindow());
// step++;
// }
if
(
step
==
3
&&
className
.
equals
(
WeChatWebView
)){
step
++;
// 二维码长点击
delayDeal
(
delayBean
.
getAfter_click_message_delay
(),
new
IDelayMethord
()
{
@Override
public
void
delayMethord
()
{
execShellCmd
(
"input swipe 300 600 300 600 4000"
);
step
++;
}
});
}
if
(
step
==
5
&&
className
.
equals
(
WeChatAlert
)){
Log
.
d
(
TAG
,
"开始点击确认二维码"
);
step
++;
delayDeal
(
delayBean
.
getLong_press_qrcode_delay
(),
new
IDelayMethord
()
{
@Override
public
void
delayMethord
()
{
pressRecognitionImg
();
step
++;
}
});
}
if
(
step
==
7
&&
className
.
equals
(
WeChatWebView
)){
Log
.
d
(
TAG
,
"开始点击确认登录"
);
pressSure
();
resetAll
();
}
// switch (eventType) {
// //点击事件
// case 32:
// switch (className) {
// case WeChatUi:
// if (clickDone){
// Log.d("fei ", "点击过了文件传输助手 ,准备下一步");
//
// delayDeal(1000, new IDelayMethord() {
// @Override
// public void delayMethord() {
// if (WeChatStatus.status[0] ) {
//
// Log.d("fei ", "进入文件传输详情页面");
// if (fill()) {
//
// //填充完了 有时候发送不出现,那就再点击下文字 ,点完了要变下空白区域 让输入框消失
// execShellCmd("input tap " + dip2px(130) + " " + dip2px(600));
// execShellCmd("input tap " + dip2px(10) + " " + dip2px(200));
// Log.d("fei ", "文件传输详情页面_填充成功准备发送");
// delayDeal(delayBean.getAfter_paste_message_delay(), new IDelayMethord() {
// @Override
// public void delayMethord() {
// Log.d("fei ", "文件传输详情页面_发送");
//
// send();
// }
// });
// delayDeal(delayBean.getAfter_paste_message_delay()+delayBean.getAfter_send_message_delay()+2000, new IDelayMethord() {
// @Override
// public void delayMethord() {
// Log.d("fei", "文件传输详情页面_点击发送的文字");
// clickMsg(getRootInActiveWindow());
// }
// });
// WeChatStatus.finishClick();
//
// } else {
// Log.d("fei", "文件传输详情页面_填充失败");
//
// }
// }
//
// }
// });
// }else {
// Log.d("fei ", "没有点击过了文件传输助手什么都不干");
//
// }
//
//
// break;
// case WeChatWebView:
// if(WeChatStatus.status[1])
//
// {
// WeChatStatus.longPressCodeFinish();
// Log.d("fei", "长按二维码");
//
// longPress();
// } else if(WeChatStatus.status[3]&&!WeChatStatus.status[2])
//
// {
// //这里加一句 第二步已经完成
// WeChatStatus.pressSureFinish();
// Log.d("fei", "点击确认关注");
//
// pressSure();
// }
// break;
// case WeChatAlert:
// if(WeChatStatus.status[2])
//
// {
// delayDeal(delayBean.getLong_press_qrcode_delay(), new IDelayMethord() {
// @Override
// public void delayMethord() {
// Log.d("fei", "点击识别二维码");
// pressRecognitionImg();
// }
// });
// }
// break;
// default:
// break;
// }
// break;
// default:
// break;
// }
}
@Override
public
void
onInterrupt
()
{
Log
.
d
(
"fei"
,
"NewService onInterrupt"
);
if
(
EventBus
.
getDefault
().
isRegistered
(
this
))
{
EventBus
.
getDefault
().
unregister
(
this
);
}
//
if (EventBus.getDefault().isRegistered(this)) {
//
EventBus.getDefault().unregister(this);
//
}
}
...
...
@@ -273,7 +378,7 @@ public class NewService extends AccessibilityService {
/**
* 点击识别图中二维码
*/
void
pressImg
()
{
void
press
Recognition
Img
()
{
List
<
AccessibilityNodeInfo
>
allData
=
getRootInActiveWindow
()
.
findAccessibilityNodeInfosByText
(
needClick
);
...
...
@@ -377,6 +482,41 @@ public class NewService extends AccessibilityService {
}
/**
* 点击首页的文件传输助手
*/
void
clickHomeWJCSZS
(){
AccessibilityNodeInfo
root
=
getRootInActiveWindow
();
if
(
root
==
null
){
return
;
}
int
count
=
root
.
getChildCount
();
for
(
int
i
=
0
;
i
<
count
;
i
++){
AccessibilityNodeInfo
nodeInfo
=
root
.
getChild
(
i
);
AccessibilityNodeInfo
findNode
=
recycle
(
nodeInfo
,
"文件传输助手"
);
if
(
findNode
!=
null
){
Rect
rect
=
new
Rect
();
findNode
.
getBoundsInScreen
(
rect
);
execShellCmd
(
"input tap "
+
rect
.
left
+
" "
+
rect
.
top
);
Log
.
d
(
TAG
,
String
.
format
(
"找到了文件传输助手 %d %d"
,
rect
.
left
,
rect
.
top
));
Log
.
i
(
TAG
,
"child widget----------------------------"
+
findNode
.
getClassName
());
Log
.
i
(
TAG
,
"Text:"
+
findNode
.
getText
());
Log
.
i
(
TAG
,
"windowId:"
+
findNode
.
getWindowId
());
Log
.
i
(
TAG
,
"rect:"
+
rect
.
toString
());
findNode
.
getBoundsInParent
(
rect
);
Log
.
i
(
TAG
,
"rect:"
+
rect
.
toString
());
return
;
}
}
Log
.
d
(
TAG
,
String
.
format
(
"没有找到了文件传输助手"
));
}
void
resetAll
(){
taskMsg
=
null
;
step
=
0
;
}
/**
* 是否过期
*/
void
isPassTime
()
{
...
...
@@ -668,38 +808,95 @@ 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
boolean
recycle
(
AccessibilityNodeInfo
info
,
String
searchText
)
{
//
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
)
{
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());
if
(!
TextUtils
.
isEmpty
(
info
.
getText
())
&&
searchText
.
equals
(
info
.
getText
())){
return
true
;
return
info
;
}
}
else
{
for
(
int
i
=
0
;
i
<
info
.
getChildCount
();
i
++)
{
if
(
info
.
getChild
(
i
)!=
null
){
boolean
result
=
recycle
(
info
.
getChild
(
i
),
searchText
);
if
(
result
){
return
tru
e
;
AccessibilityNodeInfo
node
=
recycle
(
info
.
getChild
(
i
),
searchText
);
if
(
node
!=
null
){
return
nod
e
;
}
}
}
}
return
false
;
return
null
;
}
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
);
}
}
public
void
recycle
(
AccessibilityNodeInfo
info
)
{
if
(
info
==
null
){
return
;
}
if
(
info
.
getChildCount
()
==
0
)
{
Log
.
i
(
TAG
,
"child widget----------------------------"
+
info
.
getClassName
());
Log
.
i
(
TAG
,
"Text:"
+
info
.
getText
());
Log
.
i
(
TAG
,
"windowId:"
+
info
.
getWindowId
());
}
else
{
for
(
int
i
=
0
;
i
<
info
.
getChildCount
();
i
++)
{
recycle
(
info
.
getChild
(
i
));
}
}
}
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
){
...
...
@@ -718,4 +915,18 @@ public class NewService extends AccessibilityService {
}
});
}
public
static
void
awakeWechat
(
Context
context
){
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MAIN
);
//启动第三方重点是加这个
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
);
ComponentName
cn
=
new
ComponentName
(
"com.tencent.mm"
,
"com.tencent.mm.ui.LauncherUI"
);
intent
.
setComponent
(
cn
);
if
(
context
.
getPackageManager
().
resolveActivity
(
intent
,
PackageManager
.
MATCH_ALL
)==
null
){
showToast
(
context
,
"未安装微信"
);
}
else
{
context
.
startActivity
(
intent
);
}
}
}
app/src/main/java/com/xf/weixinclick/bean/DelayBean.java
View file @
972d8d8b
package
com
.
xf
.
weixinclick
.
bean
;
import
java.io.Serializable
;
/**
* 创建日期:2018/3/6 on 15:20
* 描述:
...
...
@@ -25,7 +27,7 @@ package com.xf.weixinclick.bean;
//// 点击确定登录按钮延迟,单位毫秒,备注:等待加载公众号登录成功界面,此时发送回调通知公众号登录成功
// 'after_click_confirm_button_delay' => 3000,
public
class
DelayBean
{
public
class
DelayBean
implements
Serializable
{
int
qrcode_timeout
;
int
after_open_weixin_index_delay
;
int
after_open_weixin_file_helper_delay
;
...
...
app/src/main/java/com/xf/weixinclick/receiver/MyMessageReceiver.java
View file @
972d8d8b
...
...
@@ -11,6 +11,7 @@ import android.util.Log;
import
com.alibaba.sdk.android.push.MessageReceiver
;
import
com.alibaba.sdk.android.push.notification.CPushMessage
;
import
com.google.gson.Gson
;
import
com.xf.weixinclick.MainActivity
;
import
com.xf.weixinclick.NewService
;
import
com.xf.weixinclick.R
;
import
com.xf.weixinclick.bean.msg.ReceiverMsg
;
...
...
@@ -47,39 +48,34 @@ public class MyMessageReceiver extends MessageReceiver {
@Override
public
void
onMessage
(
final
Context
context
,
final
CPushMessage
cPushMessage
)
{
Log
.
e
(
"MyMessageReceiver"
,
"onMessageaaa "
+
cPushMessage
.
getAppId
());
Log
.
e
(
"MyMessageReceiver"
,
"onMessageaaa "
+
cPushMessage
.
getTraceInfo
().
toString
());
Log
.
e
(
"MyMessageReceiver"
,
"onMessageaaa "
+
cPushMessage
.
getAppId
());
Log
.
e
(
"MyMessageReceiver"
,
"onMessageaaa "
+
cPushMessage
.
getTraceInfo
().
toString
());
Log
.
e
(
"MyMessageReceiver"
,
"onMessage, messageId: "
+
cPushMessage
.
getMessageId
()
+
", title: "
+
cPushMessage
.
getTitle
()
+
", content:"
+
cPushMessage
.
getContent
());
Intent
intent
=
new
Intent
();
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
.
setComponent
(
cmp
);
myApplication
.
getInstence
().
startActivity
(
intent
);
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
ReceiverMsg
msg
=
new
Gson
().
fromJson
(
cPushMessage
.
getContent
(),
ReceiverMsg
.
class
);
long
second
=
System
.
currentTimeMillis
()/
1000
-
msg
.
getPushed_at
()
;
if
(
second
<
msg
.
getTime_config
().
getQrcode_timeout
()){
try
{
Thread
.
sleep
(
msg
.
getTime_config
().
getAfter_open_weixin_index_delay
());
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
NewService
.
showToast
(
context
,
String
.
format
(
"接收到消息,时间:%d秒前"
,
second
));
EventBus
.
getDefault
().
post
(
msg
);
}
else
{
NewService
.
showToast
(
context
,
String
.
format
(
"接收到消息,任务超时,时间:%d秒前"
,
second
));
}
NewService
.
showToast
(
context
,
String
.
format
(
"origin_id:%s,unique_id:%s"
,
msg
.
getOrigin_id
(),
msg
.
getUnique_id
()));
// Intent intent = new Intent();
// 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.setComponent(cmp);
// myApplication.getInstence().startActivity(intent);
ReceiverMsg
msg
=
new
Gson
().
fromJson
(
cPushMessage
.
getContent
(),
ReceiverMsg
.
class
);
long
second
=
System
.
currentTimeMillis
()
/
1000
-
msg
.
getPushed_at
();
if
(
second
<
msg
.
getTime_config
().
getQrcode_timeout
())
{
try
{
Thread
.
sleep
(
msg
.
getTime_config
().
getAfter_open_weixin_index_delay
());
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}).
start
();
NewService
.
showToast
(
context
,
String
.
format
(
"接收到消息,时间:%d秒前"
,
second
));
// EventBus.getDefault().post(msg);
MainActivity
.
startWorkService
(
context
,
msg
);
}
else
{
NewService
.
showToast
(
context
,
String
.
format
(
"接收到消息,任务超时,时间:%d秒前"
,
second
));
}
NewService
.
showToast
(
context
,
String
.
format
(
"origin_id:%s,unique_id:%s"
,
msg
.
getOrigin_id
(),
msg
.
getUnique_id
()));
// showNotify(context);
...
...
@@ -109,7 +105,7 @@ public class MyMessageReceiver extends MessageReceiver {
}
private
void
showNotify
(
Context
context
)
{
private
void
showNotify
(
Context
context
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
getDefault
());
String
strTime
=
df
.
format
(
calendar
.
getTime
());
...
...
@@ -117,10 +113,10 @@ public class MyMessageReceiver extends MessageReceiver {
Notification
notification
=
new
NotificationCompat
.
Builder
(
context
)
.
setSmallIcon
(
R
.
mipmap
.
ic_launcher
)
.
setContentTitle
(
"微信click 有新消息"
)
.
setContentText
(
"时间 "
+
strTime
)
.
setContentText
(
"时间 "
+
strTime
)
.
build
();
NotificationManager
notifyManager
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notifyManager
.
notify
(
1
,
notification
);
notifyManager
.
notify
(
1
,
notification
);
}
...
...
app/src/main/java/com/xf/weixinclick/utils/NotificationUtils.java
0 → 100644
View file @
972d8d8b
package
com
.
xf
.
weixinclick
.
utils
;
import
android.app.Notification
;
import
android.app.PendingIntent
;
import
android.app.Service
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.v4.app.NotificationCompat
;
import
com.xf.weixinclick.MainActivity
;
import
com.xf.weixinclick.R
;
import
static
android
.
app
.
PendingIntent
.
FLAG_UPDATE_CURRENT
;
/**
* 创建日期:2018/3/28 on 9:52
* 描述:
* 作者:Li
*/
public
class
NotificationUtils
{
public
static
final
int
FOREGROUND_NOTIFICATION_ID
=
88
;
public
static
void
foreground
(
Context
context
,
Service
service
){
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
context
)
//设置小图标
.
setSmallIcon
(
R
.
mipmap
.
ic_launcher
)
//设置通知标题
.
setContentTitle
(
"我正在运行"
)
.
setContentIntent
(
PendingIntent
.
getActivity
(
context
,
1
,
new
Intent
(
context
,
MainActivity
.
class
),
FLAG_UPDATE_CURRENT
))
//设置通知内容
.
setContentText
(
"有这个说明正在运行"
);
Notification
notification
=
builder
.
build
();
service
.
startForeground
(
FOREGROUND_NOTIFICATION_ID
,
notification
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment