├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── xml │ │ │ │ └── accessibility.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── zheng_shaozhuo │ │ │ └── accessibility_20180115 │ │ │ └── MyAccessibility.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── zheng_shaozhuo │ │ │ └── accessibility_20180115 │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── example │ │ └── zheng_shaozhuo │ │ └── accessibility_20180115 │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .idea ├── modules.xml ├── runConfigurations.xml ├── gradle.xml └── misc.xml ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | wx辅助工具 v1.0版本 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zheng-Shaozhuo/wxAuto/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jan 15 09:29:05 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/xml/accessibility.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/zheng_shaozhuo/accessibility_20180115/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.zheng_shaozhuo.accessibility_20180115; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 微信自动添加好友 2 | 调用Android AccessibilityService服务 3 | 4 | 实现自动添加好友 5 | #### 基于Android系统AccessibilityService辅助功能, 触发事件为 添加朋友页面点击输入账号, 待加账号数据来自接口 http://iface.vgambler.xyz/, 请自行修改 6 | 7 | 微信好友来源于在线数据 8 | 9 | AccessibilityService是什么 10 | AccessibilityService是什么,官网是这样解释的 11 | 12 | Accessibility services are intended to assist users with disabilities in using Android devices and apps. They run in the background and receive callbacks by the system whenAccessibilityEvents are fired. 13 | 14 | 也就是说这是个辅助功能,目的是辅助人们去使用Android设备和应用。它在后台运行,可以接收系统的回调。 15 | 可见AccessibilityService的出现Google的初衷是辅助人们去使用Android设备和应用,但是当你对它足够了解了之后你会发现它的作用不仅仅只是这样。对windows编程有了解的同学肯定知道hook(钩子),AccessibilityService和windows下的hook有那么一点的相似。AccessibilityService可以拦截到系统发出的一些消息(比如窗体状态的改变,通知栏状态的改变,View被点击了等等),当拦截到这些事件我们就可以去做一些我们想做的事儿了~~~ 16 | AccessibilityService能做些什么呢? 比如自动化测试、自动抢红包、自动安装等等。在带来便利的同时,也还是有需要注意的地方:当你开启了辅助功能之后会对你的隐私信息带来一些风险,所以还是需要谨慎的去开启第三方的辅助功能。当然这对于我们开发者而言都不是事,因为我们完全可以自己去开发属于我们的辅助功能。 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/zheng_shaozhuo/accessibility_20180115/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.zheng_shaozhuo.accessibility_20180115; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.zheng_shaozhuo.accessibility_20180115", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.example.zheng_shaozhuo.accessibility_20180115" 7 | minSdkVersion 19 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:26.0.0-beta1' 24 | testImplementation 'junit:junit:4.12' 25 | androidTestImplementation 'com.android.support.test:runner:0.5' 26 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2' 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zheng_shaozhuo/accessibility_20180115/MyAccessibility.java: -------------------------------------------------------------------------------- 1 | package com.example.zheng_shaozhuo.accessibility_20180115; 2 | 3 | import android.accessibilityservice.AccessibilityService; 4 | import android.content.ClipData; 5 | import android.content.ClipboardManager; 6 | import android.util.Log; 7 | import android.view.KeyEvent; 8 | import android.view.accessibility.AccessibilityEvent; 9 | import android.view.accessibility.AccessibilityNodeInfo; 10 | 11 | import java.io.BufferedReader; 12 | import java.io.InputStreamReader; 13 | import java.net.HttpURLConnection; 14 | import java.net.URL; 15 | import java.util.List; 16 | 17 | import static java.lang.Thread.sleep; 18 | 19 | /** 20 | * Created by Zheng-Shaozhuo on 2018/1/15. 21 | */ 22 | 23 | public class MyAccessibility extends AccessibilityService { 24 | private final String TAG = "vgambler"; 25 | private int normalStep = 99; 26 | private int addedNum = 0; 27 | private int isFreqperat = 0; 28 | private String[] wxList = {}; 29 | 30 | @Override 31 | protected void onServiceConnected() { 32 | super.onServiceConnected(); 33 | 34 | new Thread(new Runnable() { 35 | @Override 36 | public void run() { 37 | wxList = getListByHttp(); 38 | Log.i(TAG, "wxList length is " + wxList.length); 39 | } 40 | }).start(); 41 | 42 | // AccessibilityServiceInfo mServeiceInfo = new AccessibilityServiceInfo(); 43 | // mServeiceInfo.eventTypes = AccessibilityEvent.TYPES_ALL_MASK; 44 | // mServeiceInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN; 45 | // setServiceInfo(mServeiceInfo); 46 | 47 | } 48 | 49 | private String[] getListByHttp() { 50 | String[] targetList = {}; 51 | String result = null; 52 | URL url = null; 53 | HttpURLConnection connection = null; 54 | InputStreamReader in = null; 55 | try { 56 | url = new URL("http://iface.vgambler.xyz/"); 57 | connection = (HttpURLConnection) url.openConnection(); 58 | in = new InputStreamReader(connection.getInputStream()); 59 | BufferedReader bufferedReader = new BufferedReader(in); 60 | StringBuffer strBuffer = new StringBuffer(); 61 | String line = null; 62 | while ((line = bufferedReader.readLine()) != null) { 63 | strBuffer.append(line); 64 | } 65 | 66 | result = strBuffer.toString(); 67 | Log.i(TAG, result); 68 | targetList = result.split(","); 69 | } catch(Exception e) { 70 | Log.i(TAG, e.toString()); 71 | } 72 | 73 | return targetList; 74 | } 75 | 76 | @Override 77 | protected boolean onKeyEvent(KeyEvent event) { 78 | Log.i(TAG, "onKeyEvent : " + event.getCharacters()); 79 | return super.onKeyEvent(event); 80 | } 81 | 82 | @Override 83 | public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) { 84 | int eventType = accessibilityEvent.getEventType(); 85 | String eventTypeName = ""; 86 | switch (eventType) { 87 | case AccessibilityEvent.TYPE_VIEW_CLICKED: 88 | eventTypeName = "TYPE_VIEW_CLICKED"; 89 | break; 90 | case AccessibilityEvent.TYPE_VIEW_FOCUSED: 91 | eventTypeName = "TYPE_VIEW_FOCUSED"; 92 | break; 93 | case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED: 94 | eventTypeName = "TYPE_VIEW_LONG_CLICKED"; 95 | break; 96 | case AccessibilityEvent.TYPE_VIEW_SELECTED: 97 | eventTypeName = "TYPE_VIEW_SELECTED"; 98 | break; 99 | case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: 100 | eventTypeName = "TYPE_VIEW_TEXT_CHANGED"; 101 | break; 102 | case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: 103 | eventTypeName = "TYPE_WINDOW_STATE_CHANGED"; 104 | break; 105 | case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: 106 | eventTypeName = "TYPE_NOTIFICATION_STATE_CHANGED"; 107 | break; 108 | case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END: 109 | eventTypeName = "TYPE_TOUCH_EXPLORATION_GESTURE_END"; 110 | break; 111 | case AccessibilityEvent.TYPE_ANNOUNCEMENT: 112 | eventTypeName = "TYPE_ANNOUNCEMENT"; 113 | break; 114 | case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START: 115 | eventTypeName = "TYPE_TOUCH_EXPLORATION_GESTURE_START"; 116 | break; 117 | case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: 118 | eventTypeName = "TYPE_VIEW_HOVER_ENTER"; 119 | break; 120 | case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT: 121 | eventTypeName = "TYPE_VIEW_HOVER_EXIT"; 122 | break; 123 | case AccessibilityEvent.TYPE_VIEW_SCROLLED: 124 | eventTypeName = "TYPE_VIEW_SCROLLED"; 125 | break; 126 | case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: 127 | eventTypeName = "TYPE_VIEW_TEXT_SELECTION_CHANGED"; 128 | break; 129 | case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: 130 | eventTypeName = "TYPE_WINDOW_CONTENT_CHANGED"; 131 | break; 132 | } 133 | 134 | if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && accessibilityEvent.getClassName().equals("com.tencent.mm.plugin.search.ui.FTSAddFriendUI")) { 135 | normalStep = 0; 136 | } 137 | if (isFreqperat == 3) { 138 | addedNum++; 139 | isFreqperat = 0; 140 | } 141 | 142 | if (addedNum < wxList.length && wxList.length > 0) { 143 | if (0 == normalStep) { 144 | try { 145 | sleep(600); 146 | } catch (InterruptedException e) { 147 | e.printStackTrace(); 148 | } 149 | 150 | if (EditSearchV()) { 151 | normalStep = 1; 152 | 153 | try { 154 | sleep((long) (Math.random() * 2800 + 1000)); 155 | } catch (InterruptedException e) { 156 | e.printStackTrace(); 157 | } 158 | } else { 159 | normalStep = 5; 160 | } 161 | } else if (1 == normalStep) { 162 | if (clickSearch()) { 163 | normalStep = 2; 164 | 165 | try { 166 | sleep((long) (Math.random() * 2800 + 1000)); 167 | } catch (InterruptedException e) { 168 | e.printStackTrace(); 169 | } 170 | } 171 | } else if (2 == normalStep) { 172 | if (clickAdd()) { 173 | normalStep = 3; 174 | addedNum++; 175 | 176 | try { 177 | sleep((long) (Math.random() * 2800 + 1000)); 178 | } catch (InterruptedException e) { 179 | e.printStackTrace(); 180 | } 181 | Log.i(TAG, "添加到通讯录 点击..."); 182 | } else if (checkWordsBytxt(getRootInActiveWindow(), "设置备注和标签") || justFindNode(getRootInActiveWindow(), "设置备注和标签", null, "android.widget.TextView")) { 183 | if (clickAdd()) { 184 | normalStep = 3; 185 | addedNum++; 186 | } else { 187 | performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK); 188 | normalStep = 5; 189 | addedNum++; 190 | 191 | try { 192 | sleep(2000); 193 | } catch (InterruptedException e) { 194 | e.printStackTrace(); 195 | } 196 | Log.i(TAG, "该联系人已存在"); 197 | } 198 | } else if (checkWordsBytxt(getRootInActiveWindow(), "该用户不存在") || justFindNode(getRootInActiveWindow(), "该用户不存在", null, "android.widget.TextView")) { 199 | while (true) { 200 | try { 201 | sleep(500); 202 | } catch (InterruptedException e) { 203 | e.printStackTrace(); 204 | } 205 | if (clickClean()) { 206 | Log.i(TAG, "该用户不存在,那么add : " + addedNum); 207 | normalStep = 0; 208 | addedNum++; 209 | break; 210 | } 211 | } 212 | } else if (checkWordsBytxt(getRootInActiveWindow(), "被搜帐号状态异常,无法显示") || justFindNode(getRootInActiveWindow(), "被搜帐号状态异常,无法显示", null, "android.widget.TextView")) { 213 | while (true) { 214 | try { 215 | sleep(500); 216 | } catch (InterruptedException e) { 217 | e.printStackTrace(); 218 | } 219 | if (clickClean()) { 220 | Log.i(TAG, "该用户不存在,那么add : " + addedNum); 221 | normalStep = 0; 222 | addedNum++; 223 | break; 224 | } 225 | } 226 | } else if (checkWordsBytxt(getRootInActiveWindow(), "操作过于频繁,请稍后再试") || justFindNode(getRootInActiveWindow(), "操作过于频繁,请稍后再试", null, "android.widget.TextView")) { 227 | while (true) { 228 | try { 229 | sleep(500); 230 | } catch (InterruptedException e) { 231 | e.printStackTrace(); 232 | } 233 | if (clickClean()) { 234 | normalStep = 0; 235 | addedNum++; 236 | break; 237 | } 238 | } 239 | isFreqperat++; 240 | } else if (findNode2Execute(getRootInActiveWindow(), wxList[addedNum].toLowerCase(), null, "android.widget.TextView", null)) { 241 | normalStep = 2; 242 | addedNum++; 243 | 244 | try { 245 | sleep((long) (Math.random() * 2800 + 1000)); 246 | } catch (InterruptedException e) { 247 | e.printStackTrace(); 248 | } 249 | Log.i(TAG, "不是添加到通讯录 点击..."); 250 | } 251 | 252 | } else if (3 == normalStep) { 253 | if (clickSend()) { 254 | normalStep = 4; 255 | 256 | try { 257 | sleep((long) (Math.random() * 11200 + 1000)); 258 | } catch (InterruptedException e) { 259 | e.printStackTrace(); 260 | } 261 | } 262 | } else if (4 == normalStep) { 263 | clickBack(); 264 | normalStep = 5; 265 | 266 | try { 267 | sleep((long) (Math.random() * 2800 + 1000)); 268 | } catch (InterruptedException e) { 269 | e.printStackTrace(); 270 | } 271 | }else if (5 == normalStep) { 272 | if (clickClean()) { 273 | normalStep = 0; 274 | 275 | try { 276 | sleep((long) (Math.random() * 2800 + 1000)); 277 | } catch (InterruptedException e) { 278 | e.printStackTrace(); 279 | } 280 | } 281 | } else { 282 | normalStep = 99; 283 | } 284 | } else { 285 | Log.i(TAG, wxList.length + ", 人加完了,加完了,加完了。。。。。。。。。。。。。。"); 286 | } 287 | 288 | bl(accessibilityEvent.getSource()); 289 | Log.i(TAG, "Step: " + normalStep + ", eventTypeName:" + eventTypeName + ", Version: " + android.os.Build.VERSION.SDK_INT + ", " + accessibilityEvent.getClassName() + ", " + accessibilityEvent.getPackageName()); 290 | } 291 | 292 | private boolean EditSearchV() { 293 | Log.i(TAG, "target node text: 搜索, contentDescription: , className: android.widget.EditText, inputText: " + wxList[addedNum]); 294 | 295 | return findNode2Execute(getRootInActiveWindow(), "搜索", null, "android.widget.EditText", wxList[addedNum]); 296 | } 297 | 298 | private boolean clickSearch() { 299 | Log.i(TAG, "target node text: 搜索, contentDescription: , className: android.widget.TextView"); 300 | 301 | return findNode2Execute(getRootInActiveWindow(), "搜索:", null, "android.widget.TextView", null); 302 | } 303 | 304 | private boolean clickClean() { 305 | Log.i(TAG, "target node text: 清除, contentDescription: , className: android.widget.ImageButton"); 306 | 307 | return findNode2Execute(getRootInActiveWindow(), "清除", null, "android.widget.ImageButton", null); 308 | } 309 | 310 | private boolean clickAdd() { 311 | Log.i(TAG, "target node text: 添加到通讯录, contentDescription: , className: android.widget.Button"); 312 | 313 | return findNode2Execute(getRootInActiveWindow(), "添加到通讯录", null, "android.widget.Button", null); 314 | } 315 | 316 | private boolean clickSend() { 317 | Log.i(TAG, "target node text: 发送, contentDescription: , className: android.widget.TextView"); 318 | 319 | return findNode2Execute(getRootInActiveWindow(), "发送", null, "android.widget.TextView", null); 320 | } 321 | 322 | private void clickBack() { 323 | performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK); 324 | } 325 | 326 | 327 | private void bl(AccessibilityNodeInfo node) { 328 | if (null != node) { 329 | int num = node.getChildCount(); 330 | if (num > 0) { 331 | for (int i = 0; i < num; i++) { 332 | bl(node.getChild(i)); 333 | } 334 | } else { 335 | Log.i(TAG, "current node text: " + node.getText() + ", contentDescription: " + node.getContentDescription() + ", className: " + node.getClassName()); 336 | } 337 | } 338 | } 339 | 340 | private boolean checkWordsBytxt(AccessibilityNodeInfo root, String kWrords) { 341 | List list = root.findAccessibilityNodeInfosByText(kWrords); 342 | if (list.size() > 0) { 343 | return true; 344 | } 345 | return false; 346 | } 347 | 348 | private boolean justFindNode(AccessibilityNodeInfo node, String targetText, String targetContentDescription, String targetClassName) { 349 | if (null != node) { 350 | int childnum = node.getChildCount(); 351 | if (childnum == 0) { 352 | CharSequence text = null; 353 | CharSequence contentDescription = null; 354 | CharSequence className = node.getClassName(); 355 | 356 | if (null != className && className.equals(targetClassName)) { 357 | if (null != targetText) { 358 | text = node.getText(); 359 | if (null != text) { 360 | if (text.equals(targetText)) { 361 | Log.i(TAG, "[justFindNode] tnode text: " + node.getText() + ", contentDescription: " + node.getContentDescription() + ", className: " + node.getClassName()); 362 | return true; 363 | } else { 364 | return false; 365 | } 366 | } else { 367 | return false; 368 | } 369 | } else if(null != targetContentDescription) { 370 | contentDescription = node.getContentDescription(); 371 | if (null != contentDescription) { 372 | if (contentDescription.equals(targetContentDescription)) { 373 | Log.i(TAG, "[justFindNode] tnode text: " + node.getText() + ", contentDescription: " + node.getContentDescription() + ", className: " + node.getClassName()); 374 | return true; 375 | } else { 376 | return false; 377 | } 378 | } 379 | } else { 380 | return false; 381 | } 382 | } else { 383 | Log.i(TAG, "[justFindNode] current node className is not target, targetClassName: " + targetClassName); 384 | return false; 385 | } 386 | } else { 387 | boolean childFlag = false; 388 | for (int i = 0; i < childnum; i++) { 389 | if (childFlag) { 390 | justFindNode(node.getChild(i), targetText, targetContentDescription, targetClassName); 391 | } else { 392 | childFlag = justFindNode(node.getChild(i), targetText, targetContentDescription, targetClassName); 393 | } 394 | } 395 | return childFlag; 396 | } 397 | } 398 | return false; 399 | } 400 | 401 | private boolean findNode2Execute(AccessibilityNodeInfo node, String targetText, String targetContentDescription, String targetClassName, String textLabel) { 402 | if (null != node) { 403 | int childnum = node.getChildCount(); 404 | if (childnum == 0) { 405 | Log.i(TAG, "[findNode2Execute] cnode text: " + node.getText() + ", contentDescription: " + node.getContentDescription() + ", className: " + node.getClassName()); 406 | boolean isTarget = false; 407 | CharSequence text = null; 408 | CharSequence contentDescription = null; 409 | CharSequence className = node.getClassName(); 410 | 411 | if (null != className && className.equals(targetClassName)) { 412 | if (null != targetText) { 413 | text = node.getText(); 414 | if (null != text) { 415 | if (!targetText.equals("搜索:") && text.equals(targetText)) { 416 | if (text.equals("设置备注和标签")) { 417 | return true; 418 | } 419 | 420 | isTarget = true; 421 | }else if (text.toString().indexOf(targetText) >= 0) { 422 | isTarget = true; 423 | } else { 424 | return false; 425 | } 426 | } else if (targetText.equals("清除") && node.getPackageName().equals("com.tencent.mm")) { 427 | isTarget = true; 428 | } else { 429 | return false; 430 | } 431 | } else if(null != targetContentDescription) { 432 | contentDescription = node.getContentDescription(); 433 | if (null != contentDescription) { 434 | if (contentDescription.equals(targetContentDescription)) { 435 | isTarget = true; 436 | } else { 437 | return false; 438 | } 439 | } 440 | } else { 441 | return false; 442 | } 443 | 444 | if (isTarget) { 445 | try { 446 | sleep((long) ((Math.random() / 3) * 10000)); 447 | } catch (InterruptedException e) { 448 | e.printStackTrace(); 449 | } 450 | 451 | // Log.i(TAG, node.toString()); 452 | // node.performAction(AccessibilityNodeInfo.ACTION_CLICK); 453 | // Log.i(TAG, "isClicked is " + node.isClickable()); 454 | // try{ 455 | // AccessibilityNodeInfo tn = node.getParent(); 456 | // int nn = tn.getChildCount(); 457 | // Log.i(TAG, "nn is " + nn); 458 | // for (int n = 0; n < nn; n++) { 459 | // Log.i(TAG, "No." + n + " is : " + tn.getChild(n).toString()); 460 | // tn.getChild(n).performAction(AccessibilityNodeInfo.ACTION_CLICK); 461 | // } 462 | // 463 | // tn.performAction(AccessibilityNodeInfo.ACTION_CLICK); 464 | // tn.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK); 465 | // tn.getParent().getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK); 466 | // tn.getParent().getParent().getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK); 467 | // tn.getParent().getParent().getParent().getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK); 468 | // }catch (Exception e){ 469 | // Log.i(TAG, e.toString()); 470 | // } 471 | 472 | if (targetClassName.equals("android.widget.EditText")) { 473 | return findNode2Edit(node, textLabel); 474 | } 475 | if (node.isClickable()) { 476 | node.performAction(AccessibilityNodeInfo.ACTION_CLICK); 477 | return true; 478 | } else { 479 | try{ 480 | AccessibilityNodeInfo tnode = node.getParent(); 481 | while (!tnode.isClickable()) { 482 | tnode = tnode.getParent(); 483 | } 484 | tnode.performAction(AccessibilityNodeInfo.ACTION_CLICK); 485 | }catch (Exception e) { 486 | Log.i(TAG, e.toString()); 487 | return false; 488 | } 489 | 490 | return true; 491 | } 492 | } 493 | } else { 494 | Log.i(TAG, "current node className is not target, targetClassName: " + targetClassName); 495 | return false; 496 | } 497 | } else { 498 | boolean childFlag = false; 499 | for (int i = 0; i < childnum; i++) { 500 | if (childFlag) { 501 | findNode2Execute(node.getChild(i), targetText, targetContentDescription, targetClassName, textLabel); 502 | } else { 503 | childFlag = findNode2Execute(node.getChild(i), targetText, targetContentDescription, targetClassName, textLabel); 504 | } 505 | } 506 | return childFlag; 507 | } 508 | } 509 | return false; 510 | } 511 | 512 | private boolean findNode2Edit(AccessibilityNodeInfo node, String textLabel) { 513 | Log.i(TAG, "findNode2Edit enter."); 514 | 515 | ClipboardManager clipBoard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 516 | ClipData clip = ClipData.newPlainText("label", textLabel); 517 | clipBoard.setPrimaryClip(clip); 518 | if (node.isEditable()) { 519 | node.performAction(AccessibilityNodeInfo.ACTION_CLICK); 520 | node.performAction(AccessibilityNodeInfo.ACTION_PASTE); 521 | } else { 522 | try{ 523 | AccessibilityNodeInfo tnode = node.getParent(); 524 | while (!tnode.isEditable()) { 525 | tnode = tnode.getParent(); 526 | } 527 | node.performAction(AccessibilityNodeInfo.ACTION_CLICK); 528 | node.performAction(AccessibilityNodeInfo.ACTION_PASTE); 529 | }catch (Exception e) { 530 | Log.i(TAG, e.toString()); 531 | return false; 532 | } 533 | } 534 | return true; 535 | } 536 | 537 | @Override 538 | public void onInterrupt() { 539 | 540 | } 541 | } 542 | --------------------------------------------------------------------------------