Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李雅为
/
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
9dc3c589
authored
Apr 23, 2018
by
jeffrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v1.5.7
parent
5720b9bd
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
152 additions
and
58 deletions
+152
-58
app/build.gradle
+2
-2
app/src/main/AndroidManifest.xml
+1
-1
app/src/main/java/com/xf/weixinclick/NewService.java
+0
-0
app/src/main/java/com/xf/weixinclick/TestService.java
+78
-0
app/src/main/java/com/xf/weixinclick/agent/auto/EnableAccessibility.java
+22
-22
app/src/main/java/com/xf/weixinclick/core/Cmder.java
+2
-2
app/src/main/java/com/xf/weixinclick/core/MsgSender.java
+4
-4
app/src/main/java/com/xf/weixinclick/core/TaskSession2.java
+29
-15
app/src/main/java/com/xf/weixinclick/core/WXIdsConfig2.java
+1
-1
app/src/main/java/com/xf/weixinclick/core/Worker2.java
+10
-8
app/src/main/java/com/xf/weixinclick/http/HttpClientApi.java
+3
-3
device-2018-04-03-114133.png
+0
-0
No files found.
app/build.gradle
View file @
9dc3c589
...
...
@@ -22,8 +22,8 @@ android {
applicationId
versions
.
applicationId
minSdkVersion
versions
.
minSdkVersion
targetSdkVersion
versions
.
targetSdkVersion
versionCode
8
versionName
"1.5.
5
"
versionCode
9
versionName
"1.5.
7
"
multiDexEnabled
true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
// externalNativeBuild {
...
...
app/src/main/AndroidManifest.xml
View file @
9dc3c589
...
...
@@ -69,7 +69,7 @@
<service
android:name=
".
WXC
Service"
android:name=
".
New
Service"
android:enabled=
"true"
android:exported=
"true"
android:label=
"@string/app_name"
...
...
app/src/main/java/com/xf/weixinclick/NewService.java
View file @
9dc3c589
This diff is collapsed.
Click to expand it.
app/src/main/java/com/xf/weixinclick/TestService.java
0 → 100644
View file @
9dc3c589
package
com
.
xf
.
weixinclick
;
import
android.accessibilityservice.AccessibilityService
;
import
android.graphics.Rect
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.accessibility.AccessibilityEvent
;
import
android.view.accessibility.AccessibilityNodeInfo
;
import
java.util.List
;
/**
* 创建日期:2018/4/16 on 11:43
* 描述:
* 作者:Li
*/
public
class
TestService
extends
AccessibilityService
{
String
TAG
=
TestService
.
class
.
getSimpleName
();
@Override
public
void
onAccessibilityEvent
(
AccessibilityEvent
accessibilityEvent
)
{
Log
.
d
(
TAG
,
"包名 "
+
accessibilityEvent
.
getPackageName
());
Log
.
d
(
TAG
,
"类名 "
+
accessibilityEvent
.
getClassName
());
Log
.
d
(
TAG
,
"动作 "
+
accessibilityEvent
.
getAction
());
if
(
accessibilityEvent
.
getClassName
().
toString
().
contains
(
"ListView"
)){
// printAllNode();
}
AccessibilityNodeInfo
nodeInfo
=
findByIdAndText
(
getRootInActiveWindow
(),
"com.tencent.mm:id/apv"
,
"文件传输助手"
);
if
(
nodeInfo
==
null
){
Log
.
d
(
TAG
,
"没有找到"
);
}
else
{
Rect
rect
=
new
Rect
();
nodeInfo
.
getBoundsInScreen
(
rect
);
Log
.
d
(
TAG
,
"位置 = "
+
rect
.
left
+
" "
+
rect
.
top
);
}
}
@Override
public
void
onInterrupt
()
{
}
private
AccessibilityNodeInfo
findByIdAndText
(
AccessibilityNodeInfo
rootInActiveWindow
,
String
id
,
String
text
){
List
<
AccessibilityNodeInfo
>
nodeInfos
=
rootInActiveWindow
.
findAccessibilityNodeInfosByViewId
(
id
);
if
(
isEmptyNodes
(
nodeInfos
)){
return
null
;
}
for
(
AccessibilityNodeInfo
nodeInfo
:
nodeInfos
)
{
if
(
TextUtils
.
equals
(
text
,
nodeInfo
.
getText
())){
return
nodeInfo
;
}
}
return
null
;
}
private
boolean
isEmptyNodes
(
List
<
AccessibilityNodeInfo
>
nodeInfos
){
return
nodeInfos
==
null
||
nodeInfos
.
isEmpty
();
}
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);
}
}
}
app/src/main/java/com/xf/weixinclick/agent/auto/EnableAccessibility.java
View file @
9dc3c589
...
...
@@ -48,25 +48,13 @@ public class EnableAccessibility implements Callable<Boolean> {
Cmder
.
scrollDown
(
400
);
SystemClock
.
sleep
(
1000
);
Cmder
.
scrollDown
(
400
);
SystemClock
.
sleep
(
5
000
);
SystemClock
.
sleep
(
6
000
);
// MotionRunner.get().scrollDown(800);
// SystemClock.sleep(1000);
Log
.
e
(
TAG
,
"exec --> 滑动 结束,搜索[无障碍]"
);
int
maxTry
=
2
;
int
currentTry
=
0
;
UiHierarchyFinder
finder
=
null
;
List
<
UiNode
>
nodes
=
null
;
while
(
currentTry
<
maxTry
&&
(
nodes
==
null
||
nodes
.
isEmpty
())){
finder
=
new
UiHierarchyFinder
();
nodes
=
finder
.
dumpAndFindByName
(
"无障碍"
);
Log
.
e
(
TAG
,
"第"
+
currentTry
+
"次,找到"
+
nodes
.
size
()+
"个节点"
);
currentTry
++;
}
List
<
UiNode
>
nodes
=
findTextWithRetry
(
"无障碍"
);
if
(
nodes
.
isEmpty
()){
DebugTools
.
log
(
"没有在[设置]-[辅助功能]中找到 [无障碍]选项 !"
);
...
...
@@ -79,14 +67,12 @@ public class EnableAccessibility implements Callable<Boolean> {
Log
.
e
(
TAG
,
"点击第0个节点的位置"
+
bounds
);
Cmder
.
clickPX
(
bounds
.
centerX
(),
bounds
.
centerY
());
SystemClock
.
sleep
(
4
000
);
SystemClock
.
sleep
(
5
000
);
//打开了无障碍页面
//搜索家粉
Log
.
e
(
TAG
,
"跳转到无障碍服务列表页面,开始搜索[家粉]"
);
finder
=
new
UiHierarchyFinder
();
SystemClock
.
sleep
(
4000
);
nodes
=
finder
.
dumpAndFindByName
(
"家粉"
);
nodes
=
findTextWithRetry
(
"家粉"
);
if
(
nodes
.
isEmpty
()){
Log
.
e
(
TAG
,
"没有在[无障碍]页面找到[家粉] 的辅助服务!"
);
...
...
@@ -99,21 +85,21 @@ public class EnableAccessibility implements Callable<Boolean> {
bounds
=
nodes
.
get
(
0
).
getBounds
();
Cmder
.
clickPX
(
bounds
.
centerX
(),
bounds
.
centerY
());
SystemClock
.
sleep
(
4
000
);
SystemClock
.
sleep
(
6
000
);
//如果正常 进入家粉辅助服务详情页面
//判断是否跳转成功了,搜索辅助服务的描述
finder
=
new
UiHierarchyFinder
();
SystemClock
.
sleep
(
2000
);
nodes
=
finder
.
dumpAndFindByName
(
"微信点击辅助服务"
);
nodes
=
findTextWithRetry
(
"微信点击辅助服务"
);
if
(
nodes
.
isEmpty
()){
Log
.
e
(
TAG
,
"没有正常打开 辅助服务详情 界面 !"
);
throw
new
RuntimeException
(
" 没有正常打开 辅助服务详情 界面 !"
);
}
else
{
nodes
=
find
er
.
findNodeByText
(
"家粉"
);
nodes
=
find
TextWithRetry
(
"家粉"
);
if
(
nodes
.
isEmpty
()
||
nodes
.
size
()
<=
1
){
throw
new
RuntimeException
(
" 没有正常打开 [辅助服务详情] 界面 !"
);
...
...
@@ -163,6 +149,20 @@ public class EnableAccessibility implements Callable<Boolean> {
}
List
<
UiNode
>
findTextWithRetry
(
String
text
){
final
int
MAX_TRY
=
3
;
int
currentTry
=
0
;
UiHierarchyFinder
finder
=
null
;
List
<
UiNode
>
nodes
=
null
;
while
(
currentTry
<
MAX_TRY
&&
(
nodes
==
null
||
nodes
.
isEmpty
())){
finder
=
new
UiHierarchyFinder
();
nodes
=
finder
.
dumpAndFindByName
(
text
);
Log
.
e
(
TAG
,
"第"
+
currentTry
+
"次查找"
+
text
+
",找到"
+
nodes
.
size
()+
"个节点"
);
currentTry
++;
SystemClock
.
sleep
(
2000
);
}
return
nodes
;
}
private
void
startAct
(){
Intent
intent2
=
new
Intent
(
...
...
app/src/main/java/com/xf/weixinclick/core/Cmder.java
View file @
9dc3c589
...
...
@@ -44,8 +44,8 @@ public class Cmder {
public
static
void
clickNode
(
AccessibilityNodeInfo
node
){
Rect
rect
=
new
Rect
();
node
.
getBoundsInScreen
(
rect
);
int
x
=
rect
.
left
+
Common
.
dip2px
(
1
0
);
int
y
=
rect
.
top
+
Common
.
dip2px
(
1
0
);
int
x
=
rect
.
left
+
Common
.
dip2px
(
1
5
);
int
y
=
rect
.
top
+
Common
.
dip2px
(
2
0
);
execShellCmd
(
TAP_EVENT_CMD
+
x
+
" "
+
y
);
}
...
...
app/src/main/java/com/xf/weixinclick/core/MsgSender.java
View file @
9dc3c589
...
...
@@ -24,17 +24,17 @@ public class MsgSender {
@Override
public
void
onSuccess
(
Boolean
aBoolean
)
{
if
(
aBoolean
){
Log
.
d
(
TAG
,
"开启无障碍成功
"
);
EventBus
.
getDefault
().
post
(
msg
);
NewService
.
logToastAndUpload
(
TAG
,
"开启无障碍成功 等待新任务
"
);
//
EventBus.getDefault().post(msg);
}
else
{
NewService
.
logToastAndUpload
(
TAG
,
"
auto open AccessibilityService fail?
"
);
NewService
.
logToastAndUpload
(
TAG
,
"
开启无障碍失败
"
);
}
}
@Override
public
void
onError
(
Throwable
error
)
{
NewService
.
logToastAndUpload
(
TAG
,
"
auto open AccessibilityService
error:"
+
error
.
getMessage
());
NewService
.
logToastAndUpload
(
TAG
,
"
开启无障碍失败
error:"
+
error
.
getMessage
());
}
});
...
...
app/src/main/java/com/xf/weixinclick/core/TaskSession2.java
View file @
9dc3c589
...
...
@@ -15,10 +15,9 @@ import com.xf.weixinclick.NewService;
import
com.xf.weixinclick.bean.msg.ReceiverMsg
;
import
com.xf.weixinclick.receiver.WeChatStatus
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
xf
.
weixinclick
.
NewService
.
findNodeByTexts
;
import
static
com
.
xf
.
weixinclick
.
receiver
.
WeChatStatus
.
needClick
;
/**
* 创建日期:2018/4/17 on 11:36
...
...
@@ -29,7 +28,7 @@ import static com.xf.weixinclick.receiver.WeChatStatus.needClick;
public
class
TaskSession2
{
private
final
int
MSG_TIME_OUT
=
-
100
;
private
final
int
TIME_OUT
=
4
0
*
1000
;
private
final
int
TIME_OUT
=
5
0
*
1000
;
ReceiverMsg
mMsg
;
int
mStep
;
final
String
TAG
=
TaskSession2
.
class
.
getSimpleName
();
...
...
@@ -50,7 +49,7 @@ public class TaskSession2 {
@Override
public
boolean
handleMessage
(
Message
msg
)
{
if
(
msg
.
what
==
MSG_TIME_OUT
){
Log
(
TAG
,
"超时返回"
);
NewService
.
logToastAndUpload
(
TAG
,
"超时返回"
);
turnBack
();
taskFinish
();
}
...
...
@@ -151,11 +150,19 @@ public class TaskSession2 {
if
(
fill
(
rootInActiveWindow
,
mMsg
.
getQr_addr
())){
mStep
++;
Log
(
TAG
,
"文件传输详情页面_填充_完成"
);
send
(
rootInActiveWindow
);
handler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
mStep
++;
Log
(
TAG
,
"开始点击"
);
clickMsg
(
rootInActiveWindow
,
mMsg
.
getQr_addr
());
mStep
++;
}
},
2000
);
}
else
{
Log
(
TAG
,
"文件传输详情页面_填充_失败"
);
}
...
...
@@ -164,7 +171,9 @@ public class TaskSession2 {
}
if
(
mStep
==
4
&&
className
.
equals
(
WXIdsConfig2
.
WeChatWebView
)){
if
(
mStep
==
5
&&
className
.
equals
(
WXIdsConfig2
.
WeChatWebView
)){
mStep
++;
handler
.
postDelayed
(
new
Runnable
()
{
...
...
@@ -176,7 +185,7 @@ public class TaskSession2 {
},
mMsg
.
getTime_config
().
getAfter_click_message_delay
());
}
if
(
mStep
==
6
&&
className
.
equals
(
WXIdsConfig2
.
WeChatAlert
)){
if
(
mStep
==
7
&&
className
.
equals
(
WXIdsConfig2
.
WeChatAlert
)){
Log
(
TAG
,
"开始点击确认二维码"
);
mStep
++;
...
...
@@ -190,13 +199,13 @@ public class TaskSession2 {
}
if
(
mStep
==
8
&&
className
.
equals
(
WXIdsConfig2
.
WeChatWebView
)){
if
(
mStep
==
9
&&
className
.
equals
(
WXIdsConfig2
.
WeChatWebView
)){
Log
(
TAG
,
"开始点击确认登录"
);
handler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
Cmder
.
click
(
40
,
315
);
Cmder
.
click
(
40
,
3
7
5
);
Cmder
.
click
(
40
,
3
3
5
);
mSuccess
=
true
;
turnBack
();
}
...
...
@@ -230,17 +239,22 @@ public class TaskSession2 {
return
;
}
List
<
AccessibilityNodeInfo
>
ac
=
rootNode
.
findAccessibilityNodeInfosByViewId
(
WXIdsConfig2
.
ITEM_MSG_CARD
);
List
<
AccessibilityNodeInfo
>
ac2
=
rootNode
.
findAccessibilityNodeInfosByText
(
msg
);
List
<
AccessibilityNodeInfo
>
ac
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
WXIdsConfig2
.
ITEM_MSG_CARD
.
length
;
i
++){
String
id
=
WXIdsConfig2
.
ITEM_MSG_CARD
[
i
];
ac
=
rootNode
.
findAccessibilityNodeInfosByViewId
(
id
);
if
(
ac
.
size
()
>
0
){
Log
.
d
(
TAG
,
"通过id "
+
id
+
"找到了消息url"
);
break
;
}
}
AccessibilityNodeInfo
n
=
null
;
if
(
ac
.
size
()
>
0
)
{
Log
.
d
(
TAG
,
"通过id找到了消息url"
);
n
=
ac
.
get
(
ac
.
size
()
-
1
);
}
if
(
ac2
.
size
()
>
0
)
{
Log
.
d
(
TAG
,
"通过文字找到了消息url"
);
n
=
ac2
.
get
(
ac2
.
size
()
-
1
);
}
if
(
n
!=
null
)
{
Cmder
.
clickNode
(
n
);
...
...
app/src/main/java/com/xf/weixinclick/core/WXIdsConfig2.java
View file @
9dc3c589
...
...
@@ -21,7 +21,7 @@ final class WXIdsConfig2 {
public
static
final
String
BTN_SEND_MSG
=
ID_PREFIX
+
"aai"
;
//聊天页面发送按钮
public
static
final
String
ITEM_MSG_CARD
=
ID_PREFIX
+
"jj"
;
//聊天页面消息卡片
public
static
final
String
[]
ITEM_MSG_CARD
=
new
String
[]{
ID_PREFIX
+
"jj"
,
ID_PREFIX
+
"jz"
}
;
//聊天页面消息卡片
public
static
final
String
BTN_SCAN_QR
=
ID_PREFIX
+
"ga"
;
//识别二维码
...
...
app/src/main/java/com/xf/weixinclick/core/Worker2.java
View file @
9dc3c589
...
...
@@ -8,6 +8,7 @@ import android.view.accessibility.AccessibilityEvent;
import
android.view.accessibility.AccessibilityNodeInfo
;
import
com.alibaba.sdk.android.push.noonesdk.PushServiceFactory
;
import
com.xf.weixinclick.NewService
;
import
com.xf.weixinclick.bean.msg.ReceiverMsg
;
import
com.xf.weixinclick.http.HttpClientApi
;
import
com.xf.weixinclick.http.HttpSubscriber
;
...
...
@@ -65,23 +66,24 @@ public class Worker2 {
//有的话就开始执行任务 直到成功或者失败
try
{
//take会一直等待到有新的任务
Log
.
d
(
TAG
,
" 准备拿任务"
);
final
ReceiverMsg
msg
=
mTasks
.
take
();
Log
.
d
(
TAG
,
" 拿到任务了 "
+
msg
.
getUnique_id
()
+
" 剩余 "
+
mTasks
.
size
());
NewService
.
logToastAndUpload
(
TAG
,
" 准备拿任务"
);
ReceiverMsg
msg
=
mTasks
.
take
();
final
String
msgOriginId
=
msg
.
getUnique_id
();
NewService
.
logToastAndUpload
(
TAG
,
" 拿到任务了 "
+
msg
.
getUnique_id
()
+
" 剩余 "
+
mTasks
.
size
());
mCurrentTaskSession
=
new
TaskSession2
(
msg
,
new
TaskSession2
.
TaskCallback
()
{
@Override
public
void
onSuccess
()
{
Log
.
d
(
TAG
,
" 任务成功"
);
NewService
.
logToastAndUpload
(
TAG
,
" 任务成功"
+
msgOriginId
);
taskCanStart
();
upResult
(
ACTION_SUCCESS
,
msg
.
getOrigin_id
()
);
upResult
(
ACTION_SUCCESS
,
msg
OriginId
);
}
@Override
public
void
onError
(
String
errMsg
)
{
Log
.
d
(
TAG
,
" 任务失败"
);
NewService
.
logToastAndUpload
(
TAG
,
" 任务失败"
+
msgOriginId
);
taskCanStart
();
upResult
(
ACTION_FAIL
,
msg
.
getOrigin_id
()
);
upResult
(
ACTION_FAIL
,
msg
OriginId
);
}
});
startWechat
();
...
...
@@ -141,7 +143,7 @@ public class Worker2 {
@Override
public
void
onNext
(
String
responseBase
)
{
Log
.
d
(
TAG
,
"上报结果 "
+
responseBase
);
NewService
.
logToastAndUploa
d
(
TAG
,
"上报结果 "
+
responseBase
);
}
});
}
...
...
app/src/main/java/com/xf/weixinclick/http/HttpClientApi.java
View file @
9dc3c589
...
...
@@ -186,11 +186,11 @@ public class HttpClientApi {
}
public
static
void
uploadDeviceLog
(
String
device_code
,
String
tag
,
String
message
,
Subscriber
<
String
>
subscriber
)
{
public
static
void
uploadDeviceLog
(
String
device_code
,
String
name
,
String
tag
,
String
message
,
Subscriber
<
String
>
subscriber
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"code"
,
device_code
);
map
.
put
(
"name"
,
tag
);
map
.
put
(
"msg"
,
message
);
map
.
put
(
"name"
,
name
);
map
.
put
(
"msg"
,
tag
+
" "
+
message
);
getInstance
().
devicesLog
(
map
)
.
subscribeOn
(
io
)
.
observeOn
(
io
)
...
...
device-2018-04-03-114133.png
0 → 100644
View file @
9dc3c589
128 KB
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