AccessibilityService自动刷视频

使用AccessibilityService实现自动刷视频,赚点小钱

最近很多人在推精简版的快手、抖音等app来赚钱,邀请人之后,可得佣金,每天刷视频也可以的金币换RMB,所以一些闲来无事的人就整体拿着手机刷刷刷,那么有没有什么自动的方式,让我们解放双手呢?
Android自动化测试的框架比较多,大家可以自行百度。下面就介绍几种常用的:

模拟MotionEvent

这个功能只能给自己本身的app发送Event,无法跨App。

Instrumentation

现在有很多基于Instrumentation的自动化测试框架,但是也无法跨App操作,如果想要跨App的话,就只有获得root权限或者系统签名。这两种方式都有些麻烦。

ADB命令

需要在PC端执行adb命令,那么就需要USB连接到电脑上,在PC端发送input的shell脚本命令,如果再手机端执行input tap等命令,也需要root权限。操作还是很麻烦

AccessibilityService服务

现在很多复制工具都是基于AccessibilityService开发的,通过给予一定的权限,监听手机端的动作,然后查找相应节点,向指定节点发送相应的指令。为了节约时间,我在百度找到一篇文章AccessibilityService实现文本的自动全选黏贴、点击、滑动。利用dispatchGesture+AccessibilityService来实现自动刷新视频,我将其稍作修改,就可以对刷抖音、快手、趣多多等app进行跨应用刷视频,这样一来省了不少时间。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
private void slideVertical(int startSlideRatio, int stopSlideRatio) {
sliderCount++;
int screenHeight = ScreenUtils.getScreenHeight(getApplicationContext());
int screenWidth = ScreenUtils.getScreenWidth(getApplicationContext());
L.e("屏幕:" + (screenHeight - (screenHeight / 10)) + "/" +
(screenHeight - (screenHeight - (screenHeight / 10))) + "/" + screenWidth / 2);

Path path = new Path();
int start = (screenHeight / 20) * startSlideRatio;
int stop = (screenHeight / 20) * stopSlideRatio;
L.e("屏幕:" + start + "/" +
stop + "/" + screenWidth / 2);
path.moveTo(screenWidth / 2, start);//如果只是设置moveTo就是点击
path.lineTo(screenWidth / 2, stop);//如果设置这句就是滑动
StringBuffer sb = new StringBuffer();
sb.append("滑动次数" + sliderCount + "次\n");
sb.append("滑动时间" + Utils.formatUTC(System.currentTimeMillis(),null) + "\n");
sb.append("开始位置" + start + "\n");
sb.append("结束位置" + stop + "\n");
Intent mIntent = new Intent(MainActivity.RECEIVER_ACTION);
mIntent.putExtra("result", sb.toString());

//发送广播
sendBroadcast(mIntent);
GestureDescription.Builder builder = new GestureDescription.Builder();
GestureDescription gestureDescription = builder
.addStroke(new GestureDescription.
StrokeDescription(path,
200,
200))
.build();

dispatchGesture(gestureDescription, new GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
super.onCompleted(gestureDescription);
L.w("滑动结束" + gestureDescription.getStrokeCount());

}

@Override
public void onCancelled(GestureDescription gestureDescription) {
super.onCancelled(gestureDescription);
L.w("滑动取消");
}
}, null);
}

效果图:

You forgot to set the qrcode for Alipay. Please set it in _config.yml.
You forgot to set the qrcode for Wechat. Please set it in _config.yml.
You forgot to set the business and currency_code for Paypal. Please set it in _config.yml.
You forgot to set the url Patreon. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×