From aab0e7e254b20f236b8dd65c4bb04f686645543f Mon Sep 17 00:00:00 2001 From: SuperMonster003 Date: Fri, 14 Mar 2025 20:00:53 +0800 Subject: [PATCH] =?UTF-8?q?6.6.2=20-=20Alpha4=20-=20=E4=BF=AE=E5=A4=8D=20G?= =?UTF-8?q?radle=20=E6=9E=84=E5=BB=BA=E6=97=B6=20Kotlin=20Array=20?= =?UTF-8?q?=E6=B3=9B=E5=9E=8B=E5=8F=8A=E4=BE=9D=E8=B5=96=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E7=AD=89=E8=AD=A6=E5=91=8A=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changelog/lang_zh-Hans.json | 1 + apksigner/build.gradle | 7 +- app/build.gradle.kts | 7 +- .../core/ui/attribute/WebViewAttributes.kt | 1 + .../runtime/api/augment/images/Images.kt | 100 +++++++++--------- .../autojs/runtime/api/augment/shell/Shell.kt | 2 +- .../ui/keystore/ManageKeyStoreActivity.kt | 16 +-- version.properties | 6 +- 8 files changed, 71 insertions(+), 69 deletions(-) diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index 989f2745..006d55e9 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -35,6 +35,7 @@ "升级 Gradle 版本 8.12 -> 8.13", "升级 Rhino 版本 1.8.0-SNAPSHOT -> 1.8.1-SNAPSHOT", "升级 Androidx Recyclerview 版本 1.3.2 -> 1.4.0", + "升级 Androidx WebKit 版本 1.12.1 -> 1.13.0", "升级 Pinyin4j 版本 2.5.0 -> 2.5.1" ] }, diff --git a/apksigner/build.gradle b/apksigner/build.gradle index 0067dba7..2d679652 100644 --- a/apksigner/build.gradle +++ b/apksigner/build.gradle @@ -42,7 +42,12 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.google.android.material:material:1.12.0' - implementation("com.madgag.spongycastle:core:1.58.0.0") + // @Hint by SuperMonster003 on Mar 14, 2025. + // ! Dependency "prov" contains "core" (zh-CN: 依赖 "prov" 已包含 "core"): + // ! | \--- com.madgag.spongycastle:prov:1.58.0.0 + // ! | +--- com.madgag.spongycastle:core:1.58.0.0 + // ! | \--- junit:junit:4.12 (*) + // # implementation("com.madgag.spongycastle:core:1.58.0.0") implementation("com.madgag.spongycastle:prov:1.58.0.0") testImplementation 'junit:junit:4.13.2' diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e051a048..529a04f9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -89,7 +89,7 @@ dependencies /* Unclassified */ { implementation("com.squareup.okhttp3:okhttp:4.12.0") // Webkit - implementation("androidx.webkit:webkit:1.12.1") + implementation("androidx.webkit:webkit:1.13.0") // Gson implementation("com.google.code.gson:gson:2.11.0") @@ -216,6 +216,9 @@ dependencies /* Unclassified */ { // ApkSigner implementation(project(":modules:apksigner")) + + // Spongy Castle + implementation("com.madgag.spongycastle:prov:1.58.0.0") } dependencies /* MIME */ { @@ -639,7 +642,7 @@ android { } buildTypes { - val proguardFiles = arrayOf( + val proguardFiles = arrayOf( getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", ) diff --git a/app/src/main/java/org/autojs/autojs/core/ui/attribute/WebViewAttributes.kt b/app/src/main/java/org/autojs/autojs/core/ui/attribute/WebViewAttributes.kt index 967b078f..f01e06df 100644 --- a/app/src/main/java/org/autojs/autojs/core/ui/attribute/WebViewAttributes.kt +++ b/app/src/main/java/org/autojs/autojs/core/ui/attribute/WebViewAttributes.kt @@ -19,6 +19,7 @@ open class WebViewAttributes(scriptRuntime: ScriptRuntime, resourceParser: Resou registerAttr("blockNetworkImage") { view.settings.blockNetworkImage = it.toBoolean() } registerAttr("blockNetworkLoads") { view.settings.blockNetworkLoads = it.toBoolean() } registerAttrs(arrayOf("enableBuiltInZoomControls", "builtInZoomControls")) { view.settings.builtInZoomControls = it.toBoolean() } + @Suppress("DEPRECATION") registerAttrs(arrayOf("enableDatabase", "databaseEnabled", "isDatabaseEnabled")) { view.settings.databaseEnabled = it.toBoolean() } registerAttrs(arrayOf("fontSize", "defaultFontSize")) { view.settings.defaultFontSize = it.toInt() } registerAttrs(arrayOf("fixedFontSize", "defaultFixedFontSize")) { view.settings.defaultFixedFontSize = it.toInt() } diff --git a/app/src/main/java/org/autojs/autojs/runtime/api/augment/images/Images.kt b/app/src/main/java/org/autojs/autojs/runtime/api/augment/images/Images.kt index 6a496a7b..79af1d1c 100644 --- a/app/src/main/java/org/autojs/autojs/runtime/api/augment/images/Images.kt +++ b/app/src/main/java/org/autojs/autojs/runtime/api/augment/images/Images.kt @@ -184,7 +184,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @JvmStatic @RhinoRuntimeFunctionInterface fun copy(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsOnlyOne(args) { o -> - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.copy must be a ImageWrapper" } scriptRuntime.images.copy(image) } @@ -201,13 +201,13 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt when (it.size) { 5 -> { val (o, x, y, w, h) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.clip must be a ImageWrapper" } scriptRuntime.images.clip(image, coerceIntNumber(x), coerceIntNumber(y), coerceIntNumber(w), coerceIntNumber(h)) } 2 -> { val (o, region) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.clip must be a ImageWrapper" } when { region.isJsNullish() -> image.apply { shoot() } @@ -228,7 +228,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun pixel(scriptRuntime: ScriptRuntime, args: Array) = ensureArgumentsLength(args, 3) { val (o, x, y) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.pixel must be a ImageWrapper" } ApiImages.pixel(image, coerceIntNumber(x), coerceIntNumber(y)) } @@ -297,7 +297,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun save(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsLengthInRange(args, 2..4) { val (o, path, format, quality) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.save must be a ImageWrapper" } require(!path.isJsNullish()) { "Argument path for images.save must be non-nullish" } scriptRuntime.images.save(image, scriptRuntime.files.path(coerceString(path)), parseImageFormat(format), parseQuality(quality, DEFAULT_IMAGE_SAVE_QUALITY)) @@ -307,7 +307,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun saveImage(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsLengthInRange(args, 2..4) { val (o, path, format, quality) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.saveImage must be a ImageWrapper" } require(!path.isJsNullish()) { "Argument path for images.saveImage must be non-nullish" } scriptRuntime.images.save(image, scriptRuntime.files.path(coerceString(path)), parseImageFormat(format), parseQuality(quality, DEFAULT_IMAGE_SAVE_QUALITY)) @@ -316,7 +316,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @JvmStatic @RhinoRuntimeFunctionInterface fun invert(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsOnlyOne(args) { o -> - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.invert must be a ImageWrapper" } scriptRuntime.images.invert(image) } @@ -325,7 +325,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun grayscale(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 1..2) { val (o, dstCn) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.grayscale must be a ImageWrapper" } cvtColor(scriptRuntime, arrayOf(image, "BGR2GRAY", dstCn)) } @@ -333,7 +333,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @JvmStatic @RhinoRuntimeFunctionInterface fun isGrayscale(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsOnlyOne(args) { o -> - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o val mat = when (image) { is OpencvMat -> image is ImageWrapper -> image.mat @@ -359,7 +359,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun threshold(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 3..4) { val (o, threshold, maxVal, type) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.threshold must be a ImageWrapper" } initOpenCvIfNeeded() val mat = AutoJsMat() @@ -372,7 +372,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun inRange(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLength(args, 3) { val (o, lowerBound, upperBound) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.inRange must be a ImageWrapper" } initOpenCvIfNeeded() val dst = AutoJsMat() @@ -385,7 +385,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun interval(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLength(args, 3) { val (o, color, threshold) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.interval must be a ImageWrapper" } initOpenCvIfNeeded() val (lowerBound, upperBound) = parseScalars(Colors.toIntRhino(color), coerceNumber(threshold)) @@ -400,7 +400,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun adaptiveThreshold(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLength(args, 6) { val (o, maxValue, adaptiveMethod, thresholdType, blockSize, C) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.adaptiveThreshold must be a ImageWrapper" } initOpenCvIfNeeded() val mat = AutoJsMat() @@ -415,7 +415,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun blur(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 2..4) { val (o, ksize, anchor, type) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.blur must be a ImageWrapper" } initOpenCvIfNeeded() val mat = AutoJsMat() @@ -433,7 +433,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun medianBlur(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLength(args, 2) { val (o, size) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.medianBlur must be a ImageWrapper" } initOpenCvIfNeeded() val ksize = when (size) { @@ -467,7 +467,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun gaussianBlur(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 2..5) { val (o, size, sigmaX, sigmaY, type) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.gaussianBlur must be a ImageWrapper" } /* 按需初始化 OpenCV. */ initOpenCvIfNeeded() @@ -489,7 +489,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun bilateralFilter(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 1..5) { val (o, d, sigmaColor, sigmaSpace, borderType) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.bilateralFilter must be a ImageWrapper" } initOpenCvIfNeeded() val mat = AutoJsMat() @@ -505,7 +505,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun cvtColor(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 2..3) { val (o, code, dstCn) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.cvtColor must be a ImageWrapper" } initOpenCvIfNeeded() val mat = AutoJsMat() @@ -522,7 +522,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findCircles(scriptRuntime: ScriptRuntime, args: Array): List = ensureArgumentsLengthInRange(args, 1..2) { val (o, optionsArg) = it - val rawImage = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val rawImage = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(rawImage is ImageWrapper) { "Argument grayImage for images.findCircles must be a ImageWrapper" } val grayImage = if (isGrayscale(scriptRuntime, arrayOf(rawImage))) rawImage else grayscale(scriptRuntime, arrayOf(rawImage)) initOpenCvIfNeeded() @@ -564,7 +564,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun resize(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 2..3) { val (o, size, interpolation) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.resize must be a ImageWrapper" } initOpenCvIfNeeded() val mat = AutoJsMat() @@ -577,7 +577,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun scale(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 3..4) { val (o, fx, fy, interpolation) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.scale must be a ImageWrapper" } initOpenCvIfNeeded() val mat = AutoJsMat() @@ -590,7 +590,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun rotate(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 2..4) { val (o, degree, centerXArg, centerYArg) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.rotate must be a ImageWrapper" } initOpenCvIfNeeded() val centerX = parseNumber(centerXArg) { image.width / 2 }.toFloat() @@ -602,9 +602,9 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun concat(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLengthInRange(args, 2..3) { val (oA, oB, direction) = it - val imageA = if (oA is String) read(scriptRuntime, arrayOf(oA, true)) else oA + val imageA = if (oA is String) read(scriptRuntime, arrayOf(oA, true)) else oA require(imageA is ImageWrapper) { "Argument imageA for images.concat must be a ImageWrapper" } - val imageB = if (oB is String) read(scriptRuntime, arrayOf(oB, true)) else oB + val imageB = if (oB is String) read(scriptRuntime, arrayOf(oB, true)) else oB require(imageB is ImageWrapper) { "Argument imageB for images.concat must be a ImageWrapper" } initOpenCvIfNeeded() ApiImages.concat(imageA, imageB, directionToGravityToConcat(direction)) @@ -614,7 +614,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun detectColor(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsLengthInRange(args, 4..6) { val (o, color, x, y, threshold, algorithm) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.detectColor must be a ImageWrapper" } initOpenCvIfNeeded() val pixel = pixel(scriptRuntime, arrayOf(image, coerceIntNumber(x), coerceIntNumber(y))) @@ -628,7 +628,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun detectsColor(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsLengthInRange(args, 4..6) { val (o) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.detectsColor must be a ImageWrapper" } detectColor(scriptRuntime, it) } @@ -647,7 +647,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun detectsMultiColors(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsLengthInRange(args, 5..6) { val (o, _, _, _, paths) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.detectMultiColors must be a ImageWrapper" } require(paths is NativeArray) { "Argument paths for images.detectMultiColors must be a JavaScript Array" } detectMultiColors(scriptRuntime, it) @@ -657,7 +657,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findPointByColor(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 2..7) { argList -> val (o, color, xOrOptions, y, width, height, threshold) = argList - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findPointByColor must be a ImageWrapper" } initOpenCvIfNeeded() val opt = when { @@ -681,7 +681,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findColor(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 2..3) { val (o, color, options) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findColor must be a ImageWrapper" } findPointByColor(scriptRuntime, arrayOf(image, color, options)) } @@ -691,7 +691,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findColorInRegion(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 2..7) { val (o) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findColorInRegion must be a ImageWrapper" } findPointByColor(scriptRuntime, it) } @@ -700,7 +700,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findPointByColorExactly(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 2..6) { val (o) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findPointByColorExactly must be a ImageWrapper" } findPointByColor(scriptRuntime, it + /* threshold = */ 0) } @@ -710,7 +710,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findColorEquals(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 2..6) { val (o) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findColorEquals must be a ImageWrapper" } findPointByColorExactly(scriptRuntime, it) } @@ -719,7 +719,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findPointsByColor(scriptRuntime: ScriptRuntime, args: Array): NativeArray = ensureArgumentsLengthInRange(args, 2..3) { val (o, color, options) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findPointsByColor must be a ImageWrapper" } initOpenCvIfNeeded() val opt = options as? NativeObject ?: newNativeObject() @@ -736,7 +736,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findAllPointsForColor(scriptRuntime: ScriptRuntime, args: Array): NativeArray = ensureArgumentsLengthInRange(args, 2..3) { val (o) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findAllPointsForColor must be a ImageWrapper" } findPointsByColor(scriptRuntime, it) } @@ -745,7 +745,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findPointByColors(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 3..4) { val (o, firstColor, paths, options) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findPointByColors must be a ImageWrapper" } require(paths is NativeArray) { "Argument paths for images.findPointByColors must be a JavaScript Array" } initOpenCvIfNeeded() @@ -767,7 +767,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findMultiColors(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 3..4) { val (o, _, paths) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findMultiColors must be a ImageWrapper" } require(paths is NativeArray) { "Argument paths for images.findMultiColors must be a JavaScript Array" } findPointByColors(scriptRuntime, it) @@ -777,7 +777,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findPointsByColors(scriptRuntime: ScriptRuntime, args: Array): NativeArray = ensureArgumentsLengthInRange(args, 3..4) { val (o, firstColor, paths, options) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findPointsByColors must be a ImageWrapper" } require(paths is NativeArray) { "Argument paths for images.findPointsByColors must be a JavaScript Array" } initOpenCvIfNeeded() @@ -798,7 +798,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findPointByImage(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 2..7) { argList -> val (o, template, xOrOptions, y, width, height, thresholdArg) = argList - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findPointByImage must be a ImageWrapper" } require(template is ImageWrapper) { "Argument template for images.findPointByImage must be a ImageWrapper" } initOpenCvIfNeeded() @@ -829,7 +829,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findImage(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 2..3) { val (o, template) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findImage must be a ImageWrapper" } require(template is ImageWrapper) { "Argument template for images.findImage must be a ImageWrapper" } findPointByImage(scriptRuntime, it) @@ -840,7 +840,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun findImageInRegion(scriptRuntime: ScriptRuntime, args: Array): OpencvPoint? = ensureArgumentsLengthInRange(args, 2..7) { val (o, template) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.findImageInRegion must be a ImageWrapper" } require(template is ImageWrapper) { "Argument template for images.findImageInRegion must be a ImageWrapper" } findPointByImage(scriptRuntime, it) @@ -850,7 +850,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun matchTemplate(scriptRuntime: ScriptRuntime, args: Array): MatchingResult = ensureArgumentsLengthInRange(args, 2..3) { val (o, template, options) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.matchTemplate must be a ImageWrapper" } require(template is ImageWrapper) { "Argument template for images.matchTemplate must be a ImageWrapper" } initOpenCvIfNeeded() @@ -878,7 +878,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun toBase64(scriptRuntime: ScriptRuntime, args: Array): String = ensureArgumentsLengthInRange(args, 1..3) { val (o, format, quality) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.toBase64 must be a ImageWrapper" } scriptRuntime.images.toBase64(image, parseImageFormat(format), parseQuality(quality, DEFAULT_IMAGE_TO_BASE64_QUALITY)) } @@ -897,7 +897,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun toBytes(scriptRuntime: ScriptRuntime, args: Array): ByteArray = ensureArgumentsLengthInRange(args, 1..3) { val (o, format, quality) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.toBytes must be a ImageWrapper" } scriptRuntime.images.toBytes(image, parseImageFormat(format), parseQuality(quality, DEFAULT_IMAGE_TO_BYTES_QUALITY)) } @@ -933,7 +933,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun detectAndComputeFeatures(scriptRuntime: ScriptRuntime, args: Array): ImageFeatures = ensureArgumentsLengthInRange(args, 1..2) { val (o, options) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.detectAndComputeFeatures must be a ImageWrapper instead of ${image.jsBrief()}" } val opt = fillDetectAndComputeFeaturesOptions(image.height, image.width, options as? NativeObject ?: newNativeObject()) val rect = buildRegionInternal(image, opt.region) @@ -1005,7 +1005,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun compress(scriptRuntime: ScriptRuntime, args: Array): ImageWrapper = ensureArgumentsLength(args, 2) { val (o, compressLevelArg) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.compress must be a ImageWrapper" } val compressLevel = coerceNumber(compressLevelArg, 1.0) val level = 2.0.pow(floor(ln(compressLevel.coerceAtLeast(1.0)) / ln(2.0))).toInt() @@ -1063,7 +1063,7 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun buildRegion(scriptRuntime: ScriptRuntime, args: Array): OpencvRect = ensureArgumentsLength(args, 2) { val (o, region) = it - val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o + val image = if (o is String) read(scriptRuntime, arrayOf(o, true)) else o require(image is ImageWrapper) { "Argument image for images.buildRegion must be a ImageWrapper" } require(region.isJsNullish() || region.isJsArray() || region is OpencvRect || region is AndroidRect) { "Argument region ${region.jsSpecies()} is invalid for images.buildRegion" @@ -1111,9 +1111,9 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt @RhinoRuntimeFunctionInterface fun isEqual(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsLength(args, 2) { argList -> val (oA, oB) = argList - val imageA = if (oA is String) read(scriptRuntime, arrayOf(oA, true)) else oA + val imageA = if (oA is String) read(scriptRuntime, arrayOf(oA, true)) else oA require(imageA is ImageWrapper) { throw WrappedIllegalArgumentException("The first image argument for images.isEqual must be a ImageWrapper instead of ${imageA.jsBrief()}") } - val imageB = if (oB is String) read(scriptRuntime, arrayOf(oB, true)) else oB + val imageB = if (oB is String) read(scriptRuntime, arrayOf(oB, true)) else oB require(imageB is ImageWrapper) { throw WrappedIllegalArgumentException("The second image argument for images.isEqual must be a ImageWrapper instead of ${imageA.jsBrief()}") } ImageSimilarity.isEqual(imageA.mat, imageB.mat) } @@ -1399,13 +1399,13 @@ class Images(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime), AsEmitt val matA = when (imageA) { is ImageWrapper -> imageA.bgrMat is OpencvMat -> imageA - is String -> read(scriptRuntime, arrayOf(imageA, true))!!.bgrMat + is String -> read(scriptRuntime, arrayOf(imageA, true))!!.bgrMat else -> throw WrappedIllegalArgumentException("The first image argument for images.$funcName must be a ImageWrapper or a Mat instead of ${imageA.jsBrief()}") } val matB = when (imageB) { is ImageWrapper -> imageB.bgrMat is OpencvMat -> imageB - is String -> read(scriptRuntime, arrayOf(imageB, true))!!.bgrMat + is String -> read(scriptRuntime, arrayOf(imageB, true))!!.bgrMat else -> throw WrappedIllegalArgumentException("The second image argument for images.$funcName must be a ImageWrapper or a Mat instead of ${imageB.jsBrief()}") } return matA to matB diff --git a/app/src/main/java/org/autojs/autojs/runtime/api/augment/shell/Shell.kt b/app/src/main/java/org/autojs/autojs/runtime/api/augment/shell/Shell.kt index c56ab0e1..43cf6d89 100644 --- a/app/src/main/java/org/autojs/autojs/runtime/api/augment/shell/Shell.kt +++ b/app/src/main/java/org/autojs/autojs/runtime/api/augment/shell/Shell.kt @@ -90,7 +90,7 @@ class Shell(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntim if (!RootUtils.isRootAvailable()) return@ensureArgumentsOnlyOne false when (val packageName = App.getPackageName(scriptRuntime, arrayOf(app))) { null -> false - else -> execCommand(scriptRuntime, arrayOf("am force-stop $packageName", true)).code == 0 + else -> execCommand(scriptRuntime, arrayOf("am force-stop $packageName", true)).code == 0 } } diff --git a/app/src/main/java/org/autojs/autojs/ui/keystore/ManageKeyStoreActivity.kt b/app/src/main/java/org/autojs/autojs/ui/keystore/ManageKeyStoreActivity.kt index 31a5996e..1dc4ec68 100644 --- a/app/src/main/java/org/autojs/autojs/ui/keystore/ManageKeyStoreActivity.kt +++ b/app/src/main/java/org/autojs/autojs/ui/keystore/ManageKeyStoreActivity.kt @@ -226,25 +226,17 @@ class ManageKeyStoreActivity : BaseActivity() { configs: VerifyKeyStoreDialog.VerifyKeyStoreConfigs, keyStore: KeyStore, ) { // 验证密钥库密码 - val tmpKeyStore = try { + val tmpKeyStore = runCatching { KeyStoreHelper.loadKeyStore(File(keyStore.absolutePath), configs.password.toCharArray()) - } catch (e: Exception) { - null - } - - if (tmpKeyStore == null) { + }.getOrElse { showToast(R.string.text_verify_failed) return } // 验证别名和别名密码 - val tmpKey = try { + runCatching { tmpKeyStore.getKey(configs.alias, configs.aliasPassword.toCharArray()) - } catch (e: Exception) { - null - } - - if (tmpKey == null) { + }.getOrElse { showToast(R.string.text_verify_failed) return } diff --git a/version.properties b/version.properties index 145046f9..65c4e236 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Thu Mar 13 17:43:40 CST 2025 -BUILD_TIME=1741859020501 +#Fri Mar 14 19:50:02 CST 2025 +BUILD_TIME=1741953002410 COMPILE_SDK_VERSION=35 JAVA_VERSION=23 JAVA_VERSION_MIN_RADICAL=0 @@ -17,6 +17,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=3025 +VERSION_BUILD=3029 VERSION_NAME=6.6.2 Alpha4 VSCODE_EXT_REQUIRED_VERSION=1.0.8