├── app ├── .gitignore ├── src │ ├── main │ │ ├── assets │ │ │ ├── xposed_init │ │ │ └── config.properties │ │ ├── res │ │ │ ├── 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 │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── xml │ │ │ │ └── provider_paths.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── liuliuzhu │ │ │ │ └── autojs │ │ │ │ ├── utils │ │ │ │ ├── MyFileUtils.java │ │ │ │ ├── HookUtils.java │ │ │ │ ├── FileProviderUtils.java │ │ │ │ ├── OpenFileUtils.java │ │ │ │ └── ShareFileUtils.java │ │ │ │ ├── Config.java │ │ │ │ ├── annotate │ │ │ │ └── ShareContentType.java │ │ │ │ ├── Hook.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── liuliuzhu │ │ │ └── autojs │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── liuliuzhu │ │ └── autojs │ │ └── ExampleInstrumentedTest.java ├── libs │ └── api-82.jar ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitee └── ISSUE_TEMPLATE.zh-CN.md ├── README.md ├── README.en.md ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/src/main/assets/xposed_init: -------------------------------------------------------------------------------- 1 | com.liuliuzhu.autojs.Hook -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name='Autojs' 2 | include ':app' 3 | -------------------------------------------------------------------------------- /app/src/main/assets/config.properties: -------------------------------------------------------------------------------- 1 | filename=autojs_sourcecode_微信公众号_AI小子.js -------------------------------------------------------------------------------- /app/libs/api-82.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/66pig/Autojs_tools/HEAD/app/libs/api-82.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/66pig/Autojs_tools/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gitee/ISSUE_TEMPLATE.zh-CN.md: -------------------------------------------------------------------------------- 1 | ### 该问题是怎么引起的? 2 | 3 | 4 | 5 | ### 重现步骤 6 | 7 | 8 | 9 | ### 报错信息 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/66pig/Autojs_tools/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/66pig/Autojs_tools/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/66pig/Autojs_tools/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/66pig/Autojs_tools/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/66pig/Autojs_tools/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/66pig/Autojs_tools/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/66pig/Autojs_tools/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/66pig/Autojs_tools/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/66pig/Autojs_tools/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/66pig/Autojs_tools/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auto.js辅助工具 2 | 3 | #### 介绍 4 | 对Auto.js打包的APP进行逆向分析,制作出属于自己的脚本提取工具 5 | 6 | #### 软件架构 7 | Xposed、Java、Android 8 | 9 | #### 广告 10 | 个人微信公众号:AI小子 -------------------------------------------------------------------------------- /README.en.md: -------------------------------------------------------------------------------- 1 | # Auto.js辅助工具 2 | 3 | #### 介绍 4 | 对Auto.js打包的APP进行逆向分析,制作出属于自己的脚本提取工具 5 | 6 | #### 软件架构 7 | Xposed、Java、Android 8 | 9 | #### 广告 10 | 个人微信公众号:AI小子 -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #6200EE 4 | #3700B3 5 | #03DAC5 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 21 16:02:07 CST 2020 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-5.6.4-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 | -------------------------------------------------------------------------------- /app/src/main/java/com/liuliuzhu/autojs/utils/MyFileUtils.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs.utils; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * @author 溜溜猪 7 | * @date 2020/05/23 8 | * @desc 微信公众号:AI小子 9 | */ 10 | public class MyFileUtils { 11 | 12 | public static Boolean isFile(String path) { 13 | File file = new File(path); 14 | return file.isFile(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/liuliuzhu/autojs/Config.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs; 2 | 3 | import android.os.Environment; 4 | 5 | /** 6 | * @author 溜溜猪 7 | * @date 2020/05/23 8 | * @desc 微信公众号:AI小子 9 | */ 10 | public interface Config { 11 | String FILENAME = "autojs_sourcecode.js"; 12 | String FILEDIR = Environment.getExternalStorageDirectory() + "/微信公众号_AI小子/"; 13 | String FILEPATH = FILEDIR + FILENAME; 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/liuliuzhu/autojs/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs; 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() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Auto.js脚本提取器 3 | 微信公众号:AI小子 4 | autojs_sourcecode_微信公众号_AI小子.js 5 | 6 | 路径: 7 | 打开源码文件 8 | 分享给好友 9 | 溜溜猪 10 | 601090231 11 | AI小子 12 | jiarui.xing@foxmail.com 13 | 注意!请在Xposed框架中运行该应用,否则无法正常工作 14 | 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | .DS_Store 3 | .AppleDouble 4 | .LSOverride 5 | 6 | # Icon must end with two \r 7 | Icon 8 | 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear in the root of a volume 14 | .DocumentRevisions-V100 15 | .fseventsd 16 | .Spotlight-V100 17 | .TemporaryItems 18 | .Trashes 19 | .VolumeIcon.icns 20 | .com.apple.timemachine.donotpresent 21 | 22 | # Directories potentially created on remote AFP share 23 | .AppleDB 24 | .AppleDesktop 25 | Network Trash Folder 26 | Temporary Items 27 | .apdisk 28 | 29 | *.iml 30 | .gradle 31 | /local.properties 32 | /.idea/caches 33 | /.idea/libraries 34 | /.idea/modules.xml 35 | /.idea/workspace.xml 36 | /.idea/navEditor.xml 37 | /.idea/assetWizardSettings.xml 38 | .DS_Store 39 | /build 40 | /captures 41 | .externalNativeBuild 42 | .cxx 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/java/com/liuliuzhu/autojs/annotate/ShareContentType.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs.annotate; 2 | 3 | import androidx.annotation.StringDef; 4 | 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | @StringDef({ShareContentType.TEXT, ShareContentType.IMAGE, ShareContentType.AUDIO, ShareContentType.VIDEO, ShareContentType.FILE}) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface ShareContentType { 11 | /** 12 | * Share Text 13 | */ 14 | final String TEXT = "text/plain"; 15 | 16 | /** 17 | * Share Image 18 | */ 19 | final String IMAGE = "image/*"; 20 | 21 | /** 22 | * Share Audio 23 | */ 24 | final String AUDIO = "audio/*"; 25 | 26 | /** 27 | * Share Video 28 | */ 29 | final String VIDEO = "video/*"; 30 | 31 | /** 32 | * Share File 33 | */ 34 | final String FILE = "*/*"; 35 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/liuliuzhu/autojs/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | 25 | assertEquals("com.liuliuzhu.autojs", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/res/xml/provider_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 12 | 13 | 16 | 17 | 20 | 22 | 25 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "29.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.liuliuzhu.autojs" 9 | minSdkVersion 15 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.2" 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | } 24 | 25 | dependencies { 26 | implementation 'androidx.appcompat:appcompat:1.1.0' 27 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 30 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 31 | compileOnly files('libs/api-82.jar') 32 | } 33 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/liuliuzhu/autojs/Hook.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.liuliuzhu.autojs.utils.HookUtils; 7 | 8 | import de.robv.android.xposed.IXposedHookLoadPackage; 9 | import de.robv.android.xposed.XC_MethodHook; 10 | import de.robv.android.xposed.XposedHelpers; 11 | import de.robv.android.xposed.callbacks.XC_LoadPackage; 12 | 13 | 14 | /** 15 | * @author 溜溜猪 16 | * @date 2020/05/23 17 | * @desc 微信公众号:AI小子 18 | */ 19 | public class Hook extends Application implements IXposedHookLoadPackage, Config { 20 | @Override 21 | public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { 22 | 23 | final Class clazz = XposedHelpers.findClass( 24 | "com.stardust.autojs.engine.encryption.ScriptEncryption", 25 | loadPackageParam.classLoader); 26 | 27 | XposedHelpers.findAndHookMethod( 28 | clazz, 29 | "decrypt", 30 | byte[].class, 31 | int.class, 32 | int.class, 33 | new XC_MethodHook() { 34 | @Override 35 | protected void afterHookedMethod(MethodHookParam param) throws Throwable { 36 | // 拿到的解密数据 37 | String str = HookUtils.bytesToString((byte[]) param.getResult()); 38 | HookUtils.strToFile(str, FILEPATH); 39 | } 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/liuliuzhu/autojs/utils/HookUtils.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs.utils; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.File; 6 | import java.io.FileWriter; 7 | import java.io.IOException; 8 | import java.io.UnsupportedEncodingException; 9 | import java.util.ArrayList; 10 | 11 | 12 | /** 13 | * @author 溜溜猪 14 | * @date 2020/05/23 15 | * @desc 微信公众号:AI小子 16 | */ 17 | public abstract class HookUtils { 18 | 19 | /** 20 | * 将字节数组转为字符串 21 | * @param bs: 字节数组 22 | * @return 23 | */ 24 | public static String bytesToString(byte[] bs) { 25 | try { 26 | // 通过指定的字符集解码指定的byte数组并构造一个新的字符串 27 | return new String(bs, "utf-8"); 28 | } catch (UnsupportedEncodingException e) { 29 | e.printStackTrace(); 30 | } 31 | return null; 32 | } 33 | 34 | /** 35 | * 将字符串写入文件并保存 36 | * @param data: 脚本数据文件 37 | */ 38 | public static void strToFile(String data, String filePath) { 39 | String path = filePath.substring(0, filePath.lastIndexOf("/")); 40 | File destDir = new File(path); 41 | if (!destDir.exists()) { 42 | destDir.mkdirs(); 43 | } 44 | FileWriter fwriter = null; 45 | try { 46 | fwriter = new FileWriter(filePath); 47 | fwriter.write(data); 48 | } catch (IOException ex) { 49 | ex.printStackTrace(); 50 | Log.d("溜溜猪提示", ex.toString()); 51 | } finally { 52 | if (fwriter != null) 53 | try { 54 | fwriter.flush(); 55 | fwriter.close(); 56 | Log.d("溜溜猪提示", "保存路径为:" + filePath); 57 | } catch (IOException ex) { 58 | ex.printStackTrace(); 59 | } 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/liuliuzhu/autojs/utils/FileProviderUtils.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs.utils; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.os.Build; 8 | 9 | import androidx.core.content.FileProvider; 10 | 11 | import com.liuliuzhu.autojs.BuildConfig; 12 | 13 | import java.io.File; 14 | 15 | /** 16 | * @author SmartSean 17 | * @date 17/12/11 14:23 18 | * @desc 已被修改:2020/05/22 by 溜溜猪 19 | */ 20 | class FileProviderUtils { 21 | 22 | public static Uri getUriForFile(Context mContext, File file) { 23 | Uri fileUri = null; 24 | if (Build.VERSION.SDK_INT >= 24) { 25 | fileUri = getUriForFile24(mContext, file); 26 | } else { 27 | fileUri = Uri.fromFile(file); 28 | } 29 | return fileUri; 30 | } 31 | 32 | private static Uri getUriForFile24(Context mContext, File file) { 33 | Uri fileUri = FileProvider.getUriForFile(mContext, 34 | BuildConfig.APPLICATION_ID + ".fileprovider", 35 | file); 36 | return fileUri; 37 | } 38 | 39 | static void setIntentDataAndType(Context mContext, 40 | Intent intent, 41 | String type, 42 | File file, 43 | boolean writeAble) { 44 | if (Build.VERSION.SDK_INT >= 24) { 45 | Uri contentUri = getUriForFile(mContext, file); 46 | intent.setDataAndType(contentUri, type); 47 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 48 | if (writeAble) { 49 | intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 50 | } 51 | } else { 52 | intent.setDataAndType(Uri.fromFile(file), type); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 14 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 40 | 41 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/liuliuzhu/autojs/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.liuliuzhu.autojs; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | import androidx.core.app.ActivityCompat; 5 | 6 | import android.Manifest; 7 | import android.app.Activity; 8 | import android.content.pm.PackageManager; 9 | import android.os.Bundle; 10 | import android.view.View; 11 | import android.widget.Button; 12 | import android.widget.TextView; 13 | import android.widget.Toast; 14 | 15 | import com.liuliuzhu.autojs.utils.OpenFileUtils; 16 | import com.liuliuzhu.autojs.utils.ShareFileUtils; 17 | 18 | import java.io.File; 19 | 20 | /** 21 | * @author 溜溜猪 22 | * @date 2020/05/23 23 | * @desc 微信公众号:AI小子 24 | */ 25 | public class MainActivity extends AppCompatActivity implements Config { 26 | private Button mBtnOpen; 27 | private Button mBtnShare; 28 | private TextView mViewFilePath; 29 | 30 | private final int REQUEST_EXTERNAL_STORAGE = 1; 31 | 32 | private String[] PERMISSIONS_STORAGE = { 33 | Manifest.permission.READ_EXTERNAL_STORAGE, 34 | Manifest.permission.WRITE_EXTERNAL_STORAGE}; 35 | 36 | public void verifyStoragePermissions(Activity activity) { 37 | // Check if we have write permission 38 | int permission = ActivityCompat.checkSelfPermission(activity, 39 | Manifest.permission.WRITE_EXTERNAL_STORAGE); 40 | if (permission != PackageManager.PERMISSION_GRANTED) { 41 | // We don't have permission so prompt the user 42 | ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, 43 | REQUEST_EXTERNAL_STORAGE); 44 | } 45 | } 46 | 47 | @Override 48 | protected void onCreate(Bundle savedInstanceState) { 49 | super.onCreate(savedInstanceState); 50 | setContentView(R.layout.activity_main); 51 | mBtnOpen = findViewById(R.id.openFile); 52 | mBtnShare = findViewById(R.id.shareFile); 53 | mViewFilePath = findViewById(R.id.filePath); 54 | verifyStoragePermissions(this); 55 | init(); 56 | } 57 | 58 | private void init() { 59 | final Boolean aBoolean = checkFile(FILEPATH); 60 | if (aBoolean) { 61 | mViewFilePath.setText(FILEPATH); 62 | } 63 | // 打开文件 64 | mBtnOpen.setOnClickListener(new View.OnClickListener() { 65 | @Override 66 | public void onClick(View v) { 67 | if (aBoolean) { 68 | openFile(FILEPATH); 69 | } else { 70 | Toast.makeText(MainActivity.this, "文件不存在", Toast.LENGTH_LONG).show(); 71 | } 72 | } 73 | }); 74 | 75 | // 分享文件 76 | mBtnShare.setOnClickListener(new View.OnClickListener() { 77 | @Override 78 | public void onClick(View v) { 79 | if (aBoolean) { 80 | ShareFileUtils.shareFile(MainActivity.this, FILEPATH); 81 | } else { 82 | Toast.makeText(MainActivity.this, "文件不存在", Toast.LENGTH_LONG).show(); 83 | } 84 | } 85 | }); 86 | } 87 | 88 | /** 89 | * 打开文件 90 | * @param path 91 | */ 92 | public void openFile(String path) { 93 | File file = new File(path); 94 | try { 95 | OpenFileUtils.openFile(this, file); 96 | } catch (Exception e) { 97 | Toast.makeText(MainActivity.this, "无可用打开方式", Toast.LENGTH_LONG).show(); 98 | e.printStackTrace(); 99 | } 100 | } 101 | 102 | /** 103 | * 检查文件是否存在 104 | * @param path 105 | * @return 106 | */ 107 | private Boolean checkFile(String path) { 108 | File file = new File(path); 109 | return file.exists(); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 21 | 22 | 27 | 33 | 38 | 39 | 40 | 46 | 52 | 57 | 58 | 59 | 65 | 71 | 72 | 77 | 78 | 79 | 80 | 85 | 86 | 90 | 91 | 97 | 98 | 99 | 108 | 109 |