6.7.0 - Alpha4 - 修复 isJavaClass/isJavaPackage 等全局方法无效的问题

This commit is contained in:
SuperMonster003
2025-09-10 11:26:15 +08:00
parent c2aab17618
commit 6b8c6b2339
4 changed files with 48 additions and 34 deletions

View File

@@ -27,7 +27,8 @@
"内置模块相关方法实参类型的异常消息增加类型摘要信息",
"文件管理器浮动按钮展开后点击菜单项时优化菜单收起时机",
"崩溃报告页面支持双指缩放调整字体大小并添加常用功能按钮",
"应用启动器图标支持自适应图标特性 _[`issue #405`](http://issues.autojs6.com/405)_"
"应用启动器图标支持自适应图标特性 _[`issue #405`](http://issues.autojs6.com/405)_",
"Gradle 构建脚本提升 7z 格式文件的解压效率"
],
"dependency": [
"附加 Androidx Core (KTX) 版本 1.15.0",
@@ -57,6 +58,7 @@
"util.dpToPx/spToPx/pxToDp/pxToSp 方法, 用于像素单位转换"
],
"fix": [
"isJavaClass/isJavaPackage 等全局方法无效的问题",
"屏幕旋转至横向时子标题可能显示不完整的问题",
"屏幕旋转至横向时部分页面内容被侧边导航栏遮挡的问题",
"Android 15 部分页面状态栏背景着色区域不完整的问题 _[`issue #398`](http://issues.autojs6.com/398)_",

View File

@@ -704,20 +704,20 @@ class ScriptRuntime private constructor(builder: Builder) {
private fun augment(target: ScriptableObject) {
Global(this).assign(target, GlobalClasses)
GlobalLegacy(this).assign(target)
IsNullish.augment(target, false)
Util.augment(target, true).apply {
UtilJava.augment(this, false)
UtilVersion.augment(this, false)
UtilVersionCodes.augment(this, VersionCodesInfo.obj, false)
UtilInspect.augment(this, false)
UtilMorseCode.augment(this, false)
Global(this).assignWithGlobal(target, topLevelScope, GlobalClasses)
GlobalLegacy(this).assignWithGlobal(target, topLevelScope)
IsNullish.augmentWithGlobal(target, topLevelScope, false)
Util.augmentWithGlobal(target, topLevelScope, true).apply {
UtilJava.augmentWithGlobal(this, topLevelScope, false)
UtilVersion.augmentWithGlobal(this, topLevelScope, false)
UtilVersionCodes.augmentWithGlobal(this, topLevelScope, VersionCodesInfo.obj, false)
UtilInspect.augmentWithGlobal(this, topLevelScope, false)
UtilMorseCode.augmentWithGlobal(this, topLevelScope, false)
}
Species.augment(target, true)
Species.augmentWithGlobal(target, topLevelScope, true)
App(this).augment(target, app, true).also { augmentedApp = it }
Autojs(this).augment(target, true).also { augmentedAutojs = it }.apply {
AutojsVersion.augment(this, false)
AutojsVersion.augmentWithGlobal(this, topLevelScope, false)
}
Shell(this).augment(target, true)
Timers(this).augment(target, timers, true)
@@ -725,7 +725,7 @@ class ScriptRuntime private constructor(builder: Builder) {
Automator(this).augment(target, true)
Selector(this).augment(target, true, READONLY)
Events(this).augment(target, events, true)
Keys.augment(target, true)
Keys.augmentWithGlobal(target, topLevelScope, true)
Images(this).augment(target, true)
Ocr(this).augment(target, true).apply {
OcrMLKit(this@ScriptRuntime).augment(this, false).also { augmentedOcrMLKit = it }
@@ -736,15 +736,15 @@ class ScriptRuntime private constructor(builder: Builder) {
QrCode(this).augment(target, true)
Threads(this).augment(target, threads, true)
UI(this).proxying(target, ui, true)
Colors.augment(target, listOf(colors, Colors), true)
Color.augment(target, false)
Colors.augmentWithGlobal(target, topLevelScope, listOf(colors, Colors), true)
Color.augmentWithGlobal(target, topLevelScope, false)
Tasks(this).augment(target, true)
Dialogs(this).augment(target, true)
Continuation(this).augment(target, js_mod_continuation, true, READONLY)
Http(this).augment(target, http, true)
Web(this).augment(target, true)
WebSocket(this).augment(target, WebSocketFields, false)
S13n.augment(target, true)
S13n.augmentWithGlobal(target, topLevelScope, true)
Console(this).proxying(target, console, true).also { consoleProxyObject = it }
Plugins(this).augment(target, true)
Arrayx(this).augment(target, false)
@@ -752,29 +752,29 @@ class ScriptRuntime private constructor(builder: Builder) {
Mathx(this).augment(target, false)
Jsox(this).augment(target, true)
Files(this).augment(target, files, true)
Crypto.augment(target, CoreCrypto, true)
Crypto.augmentWithGlobal(target, topLevelScope, CoreCrypto, true)
RootAutomator(this).augment(target, false)
Engines(this).augment(target, true)
Floaty(this).augment(target, true)
Storages.augment(target, true)
Storages.augmentWithGlobal(target, topLevelScope, true)
Device(this).augment(target, device, true)
Recorder(this).augment(target, recorder, true)
Toast(this).augment(target, true)
Media.augment(target, media, true)
Sensors.augment(target, sensors, true)
Base64.augment(target, true)
Media.augmentWithGlobal(target, topLevelScope, media, true)
Sensors.augmentWithGlobal(target, topLevelScope, sensors, true)
Base64.augmentWithGlobal(target, topLevelScope, true)
Notice(this).augment(target, true).apply {
NoticeChannel(this@ScriptRuntime).augment(this, false)
}
Shizuku(this).augment(target, shizuku, true)
OpenCC.augment(target, true)
OpenCC.augmentWithGlobal(target, topLevelScope, true)
Mime(this).augment(target, mime, true)
SysProps(this).augment(target, true)
SQLite(this).augment(target, true)
Zip(this).augment(target, true)
NanoID.augment(target, true)
Pinyin.augment(target, true)
Pinyin4j.augment(target, true)
NanoID.augmentWithGlobal(target, topLevelScope, true)
Pinyin.augmentWithGlobal(target, topLevelScope, true)
Pinyin4j.augmentWithGlobal(target, topLevelScope, true)
Mediainfo(this).augment(target, true)
augmentedApp.defineProp(Autojs::class.java.simpleName.lowercase(), augmentedAutojs)

View File

@@ -135,11 +135,19 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F
fun originateKeyName() = also { mIsOriginalKeyName = true }
fun augment(target: Scriptable, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject {
return augment(target, emptyList<Any>(), withDollarPrefix, additionalAttributes)
fun augmentWithGlobal(target: Scriptable, specifiedGlobal: ScriptableObject, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject {
return augment(target, withDollarPrefix, additionalAttributes, specifiedGlobal)
}
fun augment(target: Scriptable, proto: Any, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject {
fun augmentWithGlobal(target: Scriptable, specifiedGlobal: ScriptableObject, proto: Any, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject {
return augment(target, proto, withDollarPrefix, additionalAttributes, specifiedGlobal)
}
fun augment(target: Scriptable, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0, specifiedGlobal: ScriptableObject? = null): ScriptableObject {
return augment(target, emptyList<Any>(), withDollarPrefix, additionalAttributes, specifiedGlobal)
}
fun augment(target: Scriptable, proto: Any, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0, specifiedGlobal: ScriptableObject? = null): ScriptableObject {
val callFunc: (args: Array<out Any?>) -> Any? = { args ->
try {
(this as Invokable).invoke(*args)
@@ -180,7 +188,7 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F
else -> RhinoUtils.newObject(target)
}
assign(newObj, proto)
assign(newObj, proto, specifiedGlobal)
val keys = mutableListOf(key)
if (withDollarPrefix) keys += "\$$key"
@@ -192,13 +200,17 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F
return newObj
}
fun assignWithGlobal(target: ScriptableObject, specifiedGlobal: ScriptableObject, proto: Any? = null) {
assign(target, proto, specifiedGlobal)
}
/**
* When the subclass calls assign, the value of key will be ignored.
* zh-CN: 子类调用 assign 时将忽略 key 的值.
*/
fun assign(target: ScriptableObject, proto: Any? = null) {
fun assign(target: ScriptableObject, proto: Any? = null, specifiedGlobal: ScriptableObject? = null) {
val global: ScriptableObject = scriptRuntime?.topLevelScope ?: ScriptableObject.getTopLevelScope(target) as ScriptableObject
val global: ScriptableObject = specifiedGlobal ?: scriptRuntime?.topLevelScope ?: ScriptableObject.getTopLevelScope(target) as ScriptableObject
val protos = when (proto) {
null -> emptyList()

View File

@@ -1,5 +1,5 @@
#Fri Sep 05 15:31:16 CST 2025
BUILD_TIME=1757057476985
#Wed Sep 10 11:24:53 CST 2025
BUILD_TIME=1757474693346
COMPILE_SDK_VERSION=35
IMAGE_QUANT_CMAKE_VERSION=3.22.1
IMAGE_QUANT_NDK_VERSION=26.1.10909125
@@ -24,6 +24,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
TARGET_SDK_VERSION=35
TARGET_SDK_VERSION_INRT=29
VERSION_BUILD=3355
VERSION_BUILD=3359
VERSION_NAME=6.7.0 Alpha4
VSCODE_EXT_REQUIRED_VERSION=1.0.8