6.0.1 - 增加客户端/服务端连接方式 增加部分全局对象 部分插件及工具版本更新
This commit is contained in:
@@ -9,9 +9,9 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << '-Xlint:deprecation' << '-Xlint:unchecked'
|
||||
}
|
||||
// tasks.withType(JavaCompile) {
|
||||
// options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
|
||||
// }
|
||||
|
||||
android {
|
||||
compileSdkVersion versions.compile
|
||||
@@ -24,7 +24,7 @@ android {
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
@@ -41,37 +41,22 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation "junit:junit:${junitVer}"
|
||||
|
||||
api 'org.greenrobot:eventbus:3.2.0'
|
||||
implementation "net.lingala.zip4j:zip4j:2.9.1"
|
||||
|
||||
api 'net.lingala.zip4j:zip4j:2.9.1'
|
||||
|
||||
api 'com.afollestad.material-dialogs:core:0.9.6.0'
|
||||
api 'com.google.android.material:material:1.6.0-alpha01'
|
||||
|
||||
api 'com.github.hyb1996:EnhancedFloaty:0.31'
|
||||
|
||||
api 'com.makeramen:roundedimageview:2.3.0'
|
||||
implementation "com.afollestad.material-dialogs:core:0.9.6.0"
|
||||
implementation "com.google.android.material:material:1.6.0-alpha01"
|
||||
|
||||
// OkHttp
|
||||
api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.3'
|
||||
|
||||
// JDeferred
|
||||
api 'org.jdeferred:jdeferred-android-aar:1.2.6'
|
||||
|
||||
// RootShell
|
||||
api 'com.github.Stericson:RootShell:1.6'
|
||||
implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.3"
|
||||
|
||||
// Gson
|
||||
api 'com.google.code.gson:gson:2.8.9'
|
||||
implementation "com.google.code.gson:gson:2.8.9"
|
||||
|
||||
// Log4j
|
||||
api group: 'de.mindpipe.android', name: 'android-logging-log4j', version: '1.0.3'
|
||||
api group: 'log4j', name: 'log4j', version: '1.2.17'
|
||||
|
||||
// Preference
|
||||
api 'androidx.preference:preference-ktx:1.1.1'
|
||||
implementation group: "de.mindpipe.android", name: "android-logging-log4j", version: "1.0.3"
|
||||
implementation group: "log4j", name: "log4j", version: "1.2.17"
|
||||
|
||||
// Terminal emulator
|
||||
api project(":libs:jackpal.androidterm.libtermexec-1.0")
|
||||
@@ -80,8 +65,8 @@ dependencies {
|
||||
|
||||
api project(":libs:com.android.dx-1.7.0")
|
||||
api project(":libs:org.mozilla.rhino-1.7.14")
|
||||
api project(':libs:org.opencv-4.5.4')
|
||||
api project(":libs:org.opencv-4.5.4")
|
||||
|
||||
api project(':common')
|
||||
api project(':automator')
|
||||
api project(":common")
|
||||
api project(":automator")
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.stardust.autojs">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
@@ -63,7 +63,7 @@ runtime.init();
|
||||
(function (scope) {
|
||||
var modules = ['app', 'automator', 'console', 'dialogs', 'io', 'selector', 'shell', 'web', 'ui',
|
||||
'images', 'threads', 'events', 'engines', 'RootAutomator', 'http', 'storages', 'floaty',
|
||||
'sensors', 'media', 'plugins', 'continuation'];
|
||||
'sensors', 'media', 'plugins', 'continuation', '$base64'];
|
||||
var len = modules.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var m = modules[i];
|
||||
@@ -78,6 +78,11 @@ runtime.init();
|
||||
Canvas = com.stardust.autojs.core.graphics.ScriptCanvas;
|
||||
Image = com.stardust.autojs.core.image.ImageWrapper;
|
||||
|
||||
OkHttpClient = Packages.okhttp3.OkHttpClient;
|
||||
MutableOkHttp = com.stardust.autojs.core.http.MutableOkHttp;
|
||||
Intent = android.content.Intent;
|
||||
BroadcastReceiver = com.stardust.autojs.core.content.BroadcastReceiver;
|
||||
|
||||
// 重定向require以便支持相对路径和npm模块
|
||||
Module = require('jvm-npm.js');
|
||||
require = Module.require;
|
||||
|
||||
27
autojs/src/main/assets/modules/__$base64__.js
Normal file
27
autojs/src/main/assets/modules/__$base64__.js
Normal file
@@ -0,0 +1,27 @@
|
||||
module.exports = function (runtime, global) {
|
||||
const Base64 = android.util.Base64;
|
||||
|
||||
const $base64 = () => void 0;
|
||||
|
||||
let _ = {
|
||||
charsetNames: [
|
||||
// charset names updated up to android sdk 27
|
||||
'us-ascii', 'iso-8859-1', 'utf-8', 'utf-16be', 'utf-16le', 'utf-16',
|
||||
],
|
||||
isValidEncoding(encode) {
|
||||
return this.charsetNames.includes(encode);
|
||||
},
|
||||
};
|
||||
|
||||
// noinspection JSValidateTypes
|
||||
$base64.encode = (str, encoding) => _.isValidEncoding(encoding)
|
||||
? Base64.encodeToString(new java.lang.String(str).getBytes(encoding), Base64.NO_WRAP)
|
||||
: Base64.encodeToString(new java.lang.String(str).getBytes(), Base64.NO_WRAP);
|
||||
|
||||
// noinspection JSValidateTypes
|
||||
$base64.decode = (str, encoding) => _.isValidEncoding(encoding)
|
||||
? String(new java.lang.String(Base64.decode(str, Base64.NO_WRAP), encoding))
|
||||
: String(new java.lang.String(Base64.decode(str, Base64.NO_WRAP)));
|
||||
|
||||
return $base64;
|
||||
};
|
||||
@@ -2,38 +2,40 @@
|
||||
module.exports = function (runtime, scope) {
|
||||
const ResultAdapter = require("result_adapter");
|
||||
|
||||
var MatchingResult = (function () {
|
||||
var comparators = {
|
||||
"left": (l, r) => l.point.x - r.point.x,
|
||||
"top": (l, r) => l.point.y - r.point.y,
|
||||
"right": (l, r) => r.point.x - l.point.x,
|
||||
"bottom": (l, r) => r.point.y - l.point.y
|
||||
}
|
||||
const MatchingResult = (function () {
|
||||
let comparators = {
|
||||
'left': (l, r) => l.point.x - r.point.x,
|
||||
'top': (l, r) => l.point.y - r.point.y,
|
||||
'right': (l, r) => r.point.x - l.point.x,
|
||||
'bottom': (l, r) => r.point.y - l.point.y,
|
||||
};
|
||||
|
||||
function MatchingResult(list) {
|
||||
if (Array.isArray(list)) {
|
||||
this.matches = list;
|
||||
} else {
|
||||
this.matches = runtime.bridges.bridges.toArray(list);
|
||||
}
|
||||
this.__defineGetter__("points", () => {
|
||||
this.__defineGetter__('points', () => {
|
||||
if (typeof (this.__points__) == 'undefined') {
|
||||
this.__points__ = this.matches.map(m => m.point);
|
||||
}
|
||||
return this.__points__;
|
||||
});
|
||||
}
|
||||
|
||||
MatchingResult.prototype.first = function () {
|
||||
if (this.matches.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return this.matches[0];
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.last = function () {
|
||||
if (this.matches.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return this.matches[this.matches.length - 1];
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.findMax = function (cmp) {
|
||||
if (this.matches.length == 0) {
|
||||
return null;
|
||||
@@ -45,32 +47,32 @@ module.exports = function (runtime, scope) {
|
||||
}
|
||||
});
|
||||
return target;
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.leftmost = function () {
|
||||
return this.findMax(comparators.left);
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.topmost = function () {
|
||||
return this.findMax(comparators.top);
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.rightmost = function () {
|
||||
return this.findMax(comparators.right);
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.bottommost = function () {
|
||||
return this.findMax(comparators.bottom);
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.worst = function () {
|
||||
return this.findMax((l, r) => l.similarity - r.similarity);
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.best = function () {
|
||||
return this.findMax((l, r) => r.similarity - l.similarity);
|
||||
}
|
||||
};
|
||||
MatchingResult.prototype.sortBy = function (cmp) {
|
||||
var comparatorFn = null;
|
||||
if (typeof (cmp) == 'string') {
|
||||
cmp.split("-").forEach(direction => {
|
||||
cmp.split('-').forEach(direction => {
|
||||
var buildInFn = comparators[direction];
|
||||
if (!buildInFn) {
|
||||
throw new Error("unknown direction '" + direction + "' in '" + cmp + "'");
|
||||
throw new Error('unknown direction \'' + direction + '\' in \'' + cmp + '\'');
|
||||
}
|
||||
(function (fn) {
|
||||
if (comparatorFn == null) {
|
||||
@@ -83,7 +85,7 @@ module.exports = function (runtime, scope) {
|
||||
return fn(l, r);
|
||||
}
|
||||
return cmpValue;
|
||||
}
|
||||
};
|
||||
})(comparatorFn, fn);
|
||||
}
|
||||
})(buildInFn);
|
||||
@@ -94,7 +96,7 @@ module.exports = function (runtime, scope) {
|
||||
var clone = this.matches.slice();
|
||||
clone.sort(comparatorFn);
|
||||
return new MatchingResult(clone);
|
||||
}
|
||||
};
|
||||
return MatchingResult;
|
||||
})();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.stardust.util.UiHandler;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -175,7 +176,7 @@ public class ScriptEngineService {
|
||||
@Subscribe
|
||||
public void onScriptExecution(ScriptExecutionEvent event) {
|
||||
if (event.getCode() == ScriptExecutionEvent.ON_START) {
|
||||
mGlobalConsole.verbose(mContext.getString(R.string.text_start_running) + "[" + event.getMessage() + "]");
|
||||
mGlobalConsole.verbose(MessageFormat.format("{0} [{1}].", mContext.getString(R.string.text_start_running), event.getMessage()));
|
||||
} else if (event.getCode() == ScriptExecutionEvent.ON_EXCEPTION) {
|
||||
mUiHandler.toast(mContext.getString(R.string.text_error) + ": " + event.getMessage());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.stardust.autojs.core.console;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.stardust.util.UiHandler;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
@@ -15,6 +17,7 @@ import java.util.Locale;
|
||||
* Created by Stardust on 2017/10/22.
|
||||
*/
|
||||
|
||||
@SuppressLint("ConstantLocale")
|
||||
public class GlobalConsole extends ConsoleImpl {
|
||||
private static final String LOG_tAG = "GlobalConsole";
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault());
|
||||
@@ -37,7 +40,6 @@ public class GlobalConsole extends ConsoleImpl {
|
||||
private Priority toLog4jLevel(int level) {
|
||||
switch (level) {
|
||||
case android.util.Log.VERBOSE:
|
||||
return Level.DEBUG;
|
||||
case android.util.Log.DEBUG:
|
||||
return Level.DEBUG;
|
||||
case android.util.Log.INFO:
|
||||
@@ -53,22 +55,15 @@ public class GlobalConsole extends ConsoleImpl {
|
||||
}
|
||||
|
||||
private String getLevelChar(int level) {
|
||||
switch (level) {
|
||||
case android.util.Log.VERBOSE:
|
||||
return "V";
|
||||
case android.util.Log.DEBUG:
|
||||
return "D";
|
||||
case android.util.Log.INFO:
|
||||
return "I";
|
||||
case android.util.Log.WARN:
|
||||
return "W";
|
||||
case android.util.Log.ERROR:
|
||||
return "E";
|
||||
case android.util.Log.ASSERT:
|
||||
return "A";
|
||||
|
||||
}
|
||||
return "";
|
||||
return switch (level) {
|
||||
case android.util.Log.VERBOSE -> "V";
|
||||
case android.util.Log.DEBUG -> "D";
|
||||
case android.util.Log.INFO -> "I";
|
||||
case android.util.Log.WARN -> "W";
|
||||
case android.util.Log.ERROR -> "E";
|
||||
case android.util.Log.ASSERT -> "A";
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,6 +87,9 @@ public class Timer {
|
||||
}
|
||||
}
|
||||
|
||||
public void post(Runnable r) {
|
||||
|
||||
}
|
||||
|
||||
public boolean clearInterval(int id) {
|
||||
return clearCallback(id);
|
||||
|
||||
@@ -15,8 +15,10 @@ import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.stardust.autojs.R;
|
||||
@@ -73,13 +75,8 @@ public class Device {
|
||||
public static final String securityPatch;
|
||||
|
||||
static {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||
baseOS = Build.VERSION.BASE_OS;
|
||||
securityPatch = Build.VERSION.SECURITY_PATCH;
|
||||
} else {
|
||||
baseOS = null;
|
||||
securityPatch = null;
|
||||
}
|
||||
baseOS = Build.VERSION.BASE_OS;
|
||||
securityPatch = Build.VERSION.SECURITY_PATCH;
|
||||
}
|
||||
|
||||
public static final String codename = Build.VERSION.CODENAME;
|
||||
@@ -87,7 +84,7 @@ public class Device {
|
||||
@SuppressLint("HardwareIds")
|
||||
public static final String serial = Build.SERIAL;
|
||||
|
||||
private Context mContext;
|
||||
private final Context mContext;
|
||||
private PowerManager.WakeLock mWakeLock;
|
||||
private int mWakeLockFlag;
|
||||
|
||||
@@ -285,16 +282,13 @@ public class Device {
|
||||
return;
|
||||
}
|
||||
SettingsCompat.manageWriteSettings(mContext);
|
||||
throw new SecurityException(mContext.getString(R.string.no_write_settings_permissin));
|
||||
throw new SecurityException(mContext.getString(R.string.no_write_settings_permission));
|
||||
}
|
||||
|
||||
|
||||
private void checkReadPhoneStatePermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (mContext.checkSelfPermission(Manifest.permission.READ_PHONE_STATE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException(mContext.getString(R.string.no_read_phone_state_permissin));
|
||||
}
|
||||
if (mContext.checkSelfPermission(Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException(mContext.getString(R.string.no_read_phone_state_permissin));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +317,9 @@ public class Device {
|
||||
return getMacByFile();
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
String mac = wifiInf.getMacAddress();
|
||||
|
||||
if (FAKE_MAC_ADDRESS.equals(mac)) {
|
||||
mac = null;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
<string name="text_start_running">Script Running</string>
|
||||
<string name="text_path_is_empty">Path is empty</string>
|
||||
<string name="text_file_not_exists">File does not exist</string>
|
||||
<string name="text_no_file_rw_permission">No file reading&writing permission</string>
|
||||
<string name="text_no_running_script">No running script</string>
|
||||
<string name="text_already_stop_n_scripts">Stop %d script(s)</string>
|
||||
<string name="text_no_file_rw_permission">No file r/w permission</string>
|
||||
<string name="text_no_running_scripts">No running scripts</string>
|
||||
<string name="text_already_stop_n_scripts">%d script(s) stopped</string>
|
||||
<string name="text_requires_sdk_version_to_run_the_script">Required Android OS version:</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
@@ -14,7 +14,7 @@
|
||||
<string name="text_no_floating_window_permission">No drawing overlay permission</string>
|
||||
<string name="text_accessibility_service_description">Auto.js</string>
|
||||
<string name="text_should_enable_key_observing">Key observing is disabled, please enable in settings</string>
|
||||
<string name="no_write_settings_permissin">No writing settings permission</string>
|
||||
<string name="no_write_settings_permission">No writing settings permission</string>
|
||||
<string name="exception_notification_service_disabled">通知服务未运行,请重新启用通知权限</string>
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<string name="text_path_is_empty">路径为空</string>
|
||||
<string name="text_file_not_exists">文件不存在</string>
|
||||
<string name="text_no_file_rw_permission">无文件读写权限</string>
|
||||
<string name="text_no_running_script">没有正在运行的脚本</string>
|
||||
<string name="text_already_stop_n_scripts">已停止%d个正在运行的脚本</string>
|
||||
<string name="text_no_running_scripts">没有正在运行的脚本</string>
|
||||
<string name="text_already_stop_n_scripts">已停止 %d 个正在运行的脚本</string>
|
||||
<string name="text_requires_sdk_version_to_run_the_script">本脚本需要此安卓版本以上才能运行:</string>
|
||||
<string name="ok">确定</string>
|
||||
<string name="cancel">取消</string>
|
||||
@@ -15,7 +15,7 @@
|
||||
<string name="text_accessibility_service_description">使脚本自动操作(点击、长按、滑动等)所需,若关闭则只能执行不涉及自动操作的脚本。</string>
|
||||
<string name="text_should_enable_key_observing">按键监听未启用,请在软件设置中开启</string>
|
||||
<string name="text_should_enable_gesture_observing">手势监听未启用,请在软件设置中开启</string>
|
||||
<string name="no_write_settings_permissin">沒有修改系統设置权限</string>
|
||||
<string name="no_write_settings_permission">沒有修改系統设置权限</string>
|
||||
<string name="exception_notification_service_disabled">通知服务未运行,请重新启用通知权限</string>
|
||||
<string name="text_requires_app_version_to_run_the_script" formatted="true">本脚本需要Auto.js版本号%d以上才能运行</string>
|
||||
<string name="text_drawer_open">打开侧拉菜单</string>
|
||||
|
||||
Reference in New Issue
Block a user