6.5.0 - 新增 opencc 模块; 修复编辑器问题; 优化打包应用功能及文件管理器

This commit is contained in:
SuperMonster003
2023-12-02 13:52:14 +08:00
parent afc0bce2c9
commit 17616504ab
907 changed files with 6766 additions and 3005 deletions

View File

@@ -14,7 +14,7 @@ import org.autojs.autojs.theme.ThemeColorMutable;
import java.lang.reflect.Field;
/**
* Created by Stardust on 2016/8/14.
* Created by Stardust on Aug 14, 2016.
*/
public class ThemeColorRecyclerView extends RecyclerView implements ThemeColorMutable {

View File

@@ -41,7 +41,7 @@ import org.mozilla.javascript.WrappedException
import java.io.File
/**
* Created by Stardust on 2017/11/29.
* Created by Stardust on Nov 29, 2017.
* Modified by SuperMonster003 as of Jun 10, 2022.
* Transformed by SuperMonster003 on Oct 10, 2022.
* Modified by LZX284 (https://github.com/LZX284) as of Sep 30, 2023.

View File

@@ -40,7 +40,7 @@ import java.lang.ref.WeakReference
import java.lang.reflect.Method
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
* Modified by SuperMonster003 as of Aug 23, 2022.
*/
class App : MultiDexApplication() {

View File

@@ -33,7 +33,7 @@ import java.util.concurrent.Executors
import org.autojs.autojs.inrt.autojs.AutoJs as AutoJsInrt
/**
* Created by Stardust on 2017/4/2.
* Created by Stardust on Apr 2, 2017.
* Modified by SuperMonster003 as of Dec 1, 2021.
* Transformed by SuperMonster003 on Oct 10, 2022.
* Modified by LZX284 (https://github.com/LZX284) as of Sep 30, 2023.

View File

@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Stardust on 2017/4/3.
* Created by Stardust on Apr 3, 2017.
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)

View File

@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Stardust on 2017/4/2.
* Created by Stardust on Apr 2, 2017.
*/
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.METHOD})

View File

@@ -1,7 +1,7 @@
package org.autojs.autojs.annotation
/**
* Created by Stardust on 2017/4/2.
* Created by Stardust on Apr 2, 2017.
*/
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FIELD)

View File

@@ -1,19 +1,25 @@
package org.autojs.autojs.apkbuilder
import android.content.Context
import android.content.pm.PackageManager.ApplicationInfoFlags
import android.content.pm.PackageManager.GET_SHARED_LIBRARY_FILES
import android.content.res.AssetManager
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Build
import android.util.Log
import com.reandroid.arsc.chunk.TableBlock
import org.autojs.autojs.apkbuilder.util.StreamUtils
import org.autojs.autojs.app.GlobalAppContext
import org.autojs.autojs.engine.encryption.AdvancedEncryptionStandard
import org.autojs.autojs.io.Zip
import org.autojs.autojs.pio.PFiles
import org.autojs.autojs.project.BuildInfo
import org.autojs.autojs.project.ProjectConfig
import org.autojs.autojs.script.EncryptedScriptFileHeader.writeHeader
import org.autojs.autojs.script.JavaScriptFileSource
import org.autojs.autojs.util.MD5Utils
import org.autojs.autojs6.BuildConfig
import org.autojs.autojs6.R
import pxb.android.StringItem
import pxb.android.axml.AxmlWriter
import zhao.arsceditor.ResDecoder.ARSCDecoder
@@ -21,30 +27,36 @@ import java.io.*
import java.util.concurrent.Callable
/**
* Created by Stardust on 2017/10/24.
* Created by Stardust on Oct 24, 2017.
* Modified by SuperMonster003 as of Jul 8, 2022.
*/
open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: File, private val mWorkspacePath: String) {
open class ApkBuilder(apkInputStream: InputStream?, private val outApkFile: File, private val workspacePath: String) {
private var mProgressCallback: ProgressCallback? = null
private val mApkPackager = ApkPackager(apkInputStream, mWorkspacePath)
private var mArscPackageName: String? = null
private var mManifestEditor: ManifestEditor? = null
private var mInitVector: String? = null
private var mKey: String? = null
private val mAssetManager: AssetManager by lazy { GlobalAppContext.get().assets }
private val mManifestFile
get() = File(mWorkspacePath, "AndroidManifest.xml")
private val mResourcesArscFile
get() = File(mWorkspacePath, "resources.arsc")
private lateinit var mAppConfig: AppConfig
private val mApkPackager = ApkPackager(apkInputStream, workspacePath)
private val mAssetManager: AssetManager by lazy { globalContext.assets }
private val mNativePath by lazy { File(globalContext.cacheDir, "native-lib").path }
private var mLibsIncludes = Libs.DEFALUT_INCLUDES.toMutableList()
private var mAssetsFileIncludes = Assets.File.DEFAULT_INCLUDES.toMutableList()
private var mAssetsDirExcludes = Assets.Dir.DEFAULT_EXCLUDES.toMutableList()
private val mManifestFile
get() = File(workspacePath, "AndroidManifest.xml")
private val mResourcesArscFile
get() = File(workspacePath, "resources.arsc")
init {
PFiles.ensureDir(mOutApkFile.path)
PFiles.ensureDir(outApkFile.path)
}
fun setProgressCallback(callback: ProgressCallback?) = also { mProgressCallback = callback }
@@ -52,61 +64,70 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
@Throws(IOException::class)
fun prepare() = also {
mProgressCallback?.let { callback -> GlobalAppContext.post { callback.onPrepare(this) } }
File(mWorkspacePath).mkdirs()
File(workspacePath).mkdirs()
mApkPackager.unzip()
copyAssetsRecursively("", File(mWorkspacePath, "assets"))
unzipLibs()
}
@Throws(IOException::class)
fun setScriptFile(path: String?) = also {
path?.let {
when {
PFiles.isDir(it) -> copyDir("assets/project/", it)
else -> replaceFile("assets/project/main.js", it)
PFiles.isDir(it) -> copyDir(it, "assets/project/")
else -> replaceFile(it, "assets/project/main.js")
}
}
}
@Throws(IOException::class)
fun copyDir(relativePath: String, path: String) {
val fromDir = File(path)
val toDir = File(mWorkspacePath, relativePath).apply { mkdir() }
fromDir.listFiles()?.forEach { child ->
if (child.isFile) {
if (child.name.endsWith(".js")) {
encrypt(toDir, child)
@Suppress("SameParameterValue")
private fun copyDir(srcPath: String, relativeDestPath: String) {
copyDir(File(srcPath), relativeDestPath)
}
@Throws(IOException::class)
fun copyDir(srcFile: File, relativeDestPath: String) {
val destDirFile = File(workspacePath, relativeDestPath).apply { mkdir() }
srcFile.listFiles()?.forEach { srcChildFile ->
if (srcChildFile.isFile) {
if (srcChildFile.name.endsWith(".js")) {
encryptToDir(srcChildFile, destDirFile)
} else {
StreamUtils.write(FileInputStream(child), FileOutputStream(File(toDir, child.name)))
srcChildFile.copyTo(File(destDirFile, srcChildFile.name), true)
}
} else {
if (!mAppConfig.ignoredDirs.contains(child)) {
copyDir(PFiles.join(relativePath, child.name + "/"), child.path)
if (!mAppConfig.ignoredDirs.contains(srcChildFile)) {
copyDir(srcChildFile, PFiles.join(relativeDestPath, srcChildFile.name + File.separator))
}
}
}
}
@Throws(IOException::class)
private fun encrypt(toDir: File, file: File) = encrypt(FileOutputStream(File(toDir, file.name)), file)
@Throws(IOException::class)
private fun encrypt(fos: FileOutputStream, file: File) {
try {
writeHeader(fos, JavaScriptFileSource(file).executionMode.toShort())
private fun encrypt(srcFile: File, destFile: File) {
destFile.outputStream().use { os ->
writeHeader(os, JavaScriptFileSource(srcFile).executionMode.toShort())
AdvancedEncryptionStandard(mKey!!.toByteArray(), mInitVector!!)
.encrypt(PFiles.readBytes(file.path))
.let { bytes -> fos.apply { write(bytes) }.apply { close() } }
} catch (e: Exception) {
throw IOException(e)
.encrypt(PFiles.readBytes(srcFile.path))
.let { bytes -> os.write(bytes) }
}
}
private fun encryptToDir(srcFile: File, destDirFile: File) {
val destFile = File(destDirFile, srcFile.name)
encrypt(srcFile, destFile)
}
@Throws(IOException::class)
fun replaceFile(relativePath: String, newFilePath: String) = also {
if (newFilePath.endsWith(".js")) {
encrypt(FileOutputStream(File(mWorkspacePath, relativePath)), File(newFilePath))
fun replaceFile(srcPath: String, relativeDestPath: String) = replaceFile(File(srcPath), relativeDestPath)
@Throws(IOException::class)
fun replaceFile(srcFile: File, relativeDestPath: String) = also {
val destFile = File(workspacePath, relativeDestPath)
if (destFile.name.endsWith(".js")) {
encrypt(srcFile, destFile)
} else {
StreamUtils.write(FileInputStream(newFilePath), FileOutputStream(File(mWorkspacePath, relativePath)))
srcFile.copyTo(destFile, true)
}
}
@@ -121,6 +142,8 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
setArscPackageName(packageName)
updateProjectConfig(this)
copyAssetsRecursively("", File(workspacePath, "assets"))
copyLibraries(this)
setScriptFile(sourcePath)
}
}
@@ -143,14 +166,36 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
.setPackageName(appConfig.packageName)
.setVersionName(appConfig.versionName)
.setVersionCode(appConfig.versionCode)
.also {
it.buildInfo = BuildInfo.generate(appConfig.versionCode.toLong())
PFiles.write(File(mWorkspacePath, "assets/project/project.json").path, it.toJson())
.also { config ->
config.buildInfo = BuildInfo.generate(appConfig.versionCode.toLong())
File(workspacePath, "assets/project/project.json").also { file ->
file.parentFile?.let { parent -> if (!parent.exists()) parent.mkdirs() }
}.writeText(config.toJson())
}
}
}.run {
mKey = MD5Utils.md5(packageName + versionName + mainScriptFile)
mInitVector = MD5Utils.md5(buildInfo.buildId + name).substring(0, 16)
if (appConfig.libs.contains(Constants.OPENCV)) {
mLibsIncludes += Libs.OPENCV.toSet()
mAssetsDirExcludes -= Assets.Dir.OPENCV.toSet()
}
if (appConfig.libs.contains(Constants.MLKIT_GOOGLE_OCR)) {
mLibsIncludes += Libs.MLKIT_GOOGLE_OCR.toSet()
mAssetsDirExcludes -= Assets.Dir.MLKIT_GOOGLE_OCR.toSet()
}
if (appConfig.libs.contains(Constants.PADDLE_LITE)) {
mLibsIncludes += Libs.PADDLE_LITE.toSet() + Libs.PADDLE_LITE_EXT.toSet()
mAssetsDirExcludes -= Assets.Dir.PADDLE_LITE.toSet()
}
if (appConfig.libs.contains(Constants.MLKIT_BARCODE)) {
mLibsIncludes += Libs.MLKIT_BARCODE.toSet()
mAssetsDirExcludes -= Assets.Dir.MLKIT_BARCODE.toSet()
}
if (appConfig.libs.contains(Constants.OPENCC)) {
mLibsIncludes += Libs.OPENCC.toSet()
mAssetsDirExcludes -= Assets.Dir.OPENCC.toSet()
}
}
}
@@ -167,7 +212,7 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
val appIcon = packageBlock.getOrCreate("", ICON_RES_DIR, ICON_NAME)
val appIconPath = appIcon.resValue.decodeValue()
Log.d(TAG, "Icon path: $appIconPath")
val file = File(mWorkspacePath, appIconPath).also {
val file = File(workspacePath, appIconPath).also {
if (!it.exists()) {
File(it.parent!!).mkdirs()
it.createNewFile()
@@ -186,6 +231,11 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
if (targetFile.isFile && targetFile.exists()) return
val list = mAssetManager.list(assetPath) ?: return
if (list.isEmpty()) /* asset is file */ {
if (!assetPath.contains(File.separatorChar)) /* assets root dir */ {
if (!mAssetsFileIncludes.contains(assetPath)) {
return
}
}
mAssetManager.open(assetPath).use { input ->
FileOutputStream(targetFile.absolutePath).use { output ->
input.copyTo(output)
@@ -193,6 +243,9 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
}
}
} else /* asset is folder */ {
if (mAssetsDirExcludes.any { assetPath.matches(Regex("$it(/[^/]+)*")) }) {
return
}
targetFile.delete()
targetFile.mkdir()
list.forEach {
@@ -205,14 +258,14 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
@Throws(Exception::class)
fun sign() = also {
mProgressCallback?.let { callback -> GlobalAppContext.post { callback.onSign(this) } }
val fos = FileOutputStream(mOutApkFile)
TinySign.sign(File(mWorkspacePath), fos)
val fos = FileOutputStream(outApkFile)
TinySign.sign(File(workspacePath), fos)
fos.close()
}
fun cleanWorkspace() = also {
mProgressCallback?.let { callback -> GlobalAppContext.post { callback.onClean(this) } }
delete(File(mWorkspacePath))
delete(File(workspacePath))
}
@Throws(IOException::class)
@@ -220,8 +273,8 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
@Throws(IOException::class)
private fun buildArsc() {
val oldArsc = File(mWorkspacePath, "resources.arsc")
val newArsc = File(mWorkspacePath, "resources.arsc.new")
val oldArsc = File(workspacePath, "resources.arsc")
val newArsc = File(workspacePath, "resources.arsc.new")
val decoder = ARSCDecoder(BufferedInputStream(FileInputStream(oldArsc)), null, false)
decoder.CloneArsc(FileOutputStream(newArsc), mArscPackageName, true)
oldArsc.delete()
@@ -256,6 +309,10 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
var ignoredDirs = ArrayList<File>()
var icon: Callable<Bitmap>? = null
private set
var abis: List<String> = emptyList()
private set
var libs: List<String> = emptyList()
private set
fun ignoreDir(dir: File) = also { ignoredDirs.add(dir) }
@@ -273,6 +330,10 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
fun setIcon(iconPath: String?) = also { iconPath?.let { this.icon = Callable { BitmapFactory.decodeFile(it) } } }
fun setAbis(abis: List<String>?) = also { abis?.let { this.abis = it } }
fun setLibs(libs: List<String>?) = also { libs?.let { this.libs = it } }
companion object {
@JvmStatic
fun fromProjectConfig(projectDir: String?, projectConfig: ProjectConfig) = AppConfig()
@@ -298,13 +359,144 @@ open class ApkBuilder(apkInputStream: InputStream?, private val mOutApkFile: Fil
}
}
companion object {
private fun unzipLibs() {
Zip.unzip(appApkFile, File(mNativePath), "lib/")
}
private val TAG = ApkBuilder::class.java.simpleName
private fun copyLibraries(config: AppConfig) {
config.abis.forEach { abi ->
mLibsIncludes.distinct().forEach { name ->
runCatching {
File(mNativePath, "$abi/$name").copyTo(
File(workspacePath, "lib/$abi/$name"),
overwrite = true
)
}
}
}
}
companion object {
const val ICON_NAME = "ic_launcher"
const val ICON_RES_DIR = "mipmap"
const val TEMPLATE_APK_NAME = "template.apk"
private val TAG = ApkBuilder::class.java.simpleName
private val globalContext: Context by lazy { GlobalAppContext.get() }
val appApkFile by lazy {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
File(globalContext.packageManager.getApplicationInfo(globalContext.packageName, ApplicationInfoFlags.of(GET_SHARED_LIBRARY_FILES.toLong())).sourceDir)
} else {
File(globalContext.packageManager.getApplicationInfo(globalContext.packageName, 0).sourceDir)
}
}
}
@Suppress("SpellCheckingInspection")
object Libs {
private val BASIC = listOf(
"libjackpal-androidterm5.so", /* Terminal Emulator. */
"libjackpal-termexec2.so", /* Terminal Emulator. */
)
private val MISCELLANEOUS = emptyList<String>()
@JvmField
val OPENCV = listOf(
"libc++_shared.so",
"libopencv_java4.so"
)
@JvmField
val MLKIT_GOOGLE_OCR = listOf(
"libmlkit_google_ocr_pipeline.so"
)
@JvmField
val PADDLE_LITE = listOf(
"libc++_shared.so",
"libpaddle_light_api_shared.so",
"libNative.so"
)
val PADDLE_LITE_EXT = listOf(
"libhiai.so",
"libhiai_ir.so",
"libhiai_ir_build.so",
)
@JvmField
val MLKIT_BARCODE = emptyList<String>()
@JvmField
val OPENCC = emptyList<String>()
val DEFALUT_INCLUDES: List<String> = (BASIC + MISCELLANEOUS).distinct()
@JvmStatic
fun ensure(name: String, libNameList: List<String>) {
if (!BuildConfig.isInrt) return
val nativeLibraryDir = File(globalContext.applicationInfo.nativeLibraryDir)
val primaryNativeLibraries = nativeLibraryDir.list()?.toList() ?: emptyList()
if (!primaryNativeLibraries.containsAll(libNameList)) {
throw Exception(globalContext.getString(R.string.error_module_does_not_work_due_to_the_lack_of_necessary_library_files, name))
}
}
}
@Suppress("SpellCheckingInspection")
object Assets {
object File {
private val BASIC = listOf(
"init.js", "roboto_medium.ttf"
)
private val MISCELLANEOUS = emptyList<String>()
val DEFAULT_INCLUDES = (BASIC + MISCELLANEOUS).distinct()
}
object Dir {
private val BASIC = listOf("doc", "docs", "editor", "indices", "js-beautify", "sample")
private val MISCELLANEOUS = listOf("stored-locales")
@JvmField
val OPENCV = emptyList<String>()
@JvmField
val MLKIT_GOOGLE_OCR = listOf("mlkit-google-ocr-models")
@JvmField
val MLKIT_BARCODE = listOf("mlkit_barcode_models")
@JvmField
val PADDLE_LITE = listOf("models")
@JvmField
val OPENCC = listOf("openccdata")
val DEFAULT_EXCLUDES = (BASIC + MLKIT_GOOGLE_OCR + MLKIT_BARCODE + PADDLE_LITE + OPENCC + MISCELLANEOUS).distinct()
}
}
object Constants {
const val OPENCV = "OpenCV"
const val MLKIT_GOOGLE_OCR = "MLKit Google OCR"
const val PADDLE_LITE = "MLKit Barcode"
const val MLKIT_BARCODE = "Paddle Lite"
const val OPENCC = "OpenCC"
}
}

View File

@@ -1,58 +0,0 @@
package org.autojs.autojs.apkbuilder;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import org.autojs.autojs.pio.UncheckedIOException;
import org.autojs.autojs6.BuildConfig;
import org.autojs.autojs.util.DeveloperUtils;
import java.io.IOException;
import java.io.InputStream;
/**
* Created by Stardust on 2017/11/29.
*/
public class ApkBuilderPluginHelper {
private static final String PLUGIN_PACKAGE_NAME = "org.autojs.apkbuilderplugin";
private static final boolean DEBUG_APK_PLUGIN = false;
public static final String TEMPLATE_APK_PATH = "template.apk";
public static boolean isPluginAvailable(Context context) {
// return DeveloperUtils.checkSignature(context, PLUGIN_PACKAGE_NAME);
try {
context.getPackageManager().getPackageInfo(PLUGIN_PACKAGE_NAME, 0);
} catch (PackageManager.NameNotFoundException e) {
return false;
}
return true;
}
public static InputStream openTemplateApk(Context context) {
try {
if (DEBUG_APK_PLUGIN && BuildConfig.DEBUG) {
return context.getAssets().open(TEMPLATE_APK_PATH);
}
return context.getPackageManager().getResourcesForApplication(PLUGIN_PACKAGE_NAME)
.getAssets().open(TEMPLATE_APK_PATH);
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
}
public static int getPluginVersion(Context context) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo(PLUGIN_PACKAGE_NAME, 0);
return info.versionCode;
} catch (PackageManager.NameNotFoundException e) {
return -1;
}
}
}

View File

@@ -16,7 +16,7 @@ import java.util.zip.ZipInputStream;
import pxb.android.tinysign.TinySign;
/**
* Created by Stardust on 2017/10/23.
* Created by Stardust on Oct 23, 2017.
*/
public class ApkPackager {

View File

@@ -10,7 +10,7 @@ import pxb.android.axml.AxmlWriter;
import pxb.android.axml.NodeVisitor;
/**
* Created by Stardust on 2017/10/23.
* Created by Stardust on Oct 23, 2017.
*/
public class ManifestEditor {

View File

@@ -46,7 +46,7 @@ public class TinySign {
if (f.isFile()) {
doFile(prefix + f.getName(), f, zos, dos, m);
} else {
doDir(prefix + f.getName() + "/", f, zos, dos, m);
doDir(prefix + f.getName() + File.separator, f, zos, dos, m);
}
}
}
@@ -168,7 +168,7 @@ public class TinySign {
if (f.isFile()) {
doFile(f.getName(), f, zos, dos, m);
} else {
doDir(f.getName() + "/", f, zos, dos, m);
doDir(f.getName() + File.separator, f, zos, dos, m);
}
}
}

View File

@@ -1,9 +1,10 @@
package org.autojs.autojs.apkbuilder.util;
/**
* Created by Stardust on 2017/10/23.
* Created by Stardust on Oct 23, 2017.
*/
public interface BoolFunction<T> {
boolean accept(T t);
}

View File

@@ -6,7 +6,7 @@ import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by Stardust on 2017/10/23.
* Created by Stardust on Oct 23, 2017.
*/
public class StreamUtils {

View File

@@ -17,7 +17,7 @@ import org.autojs.autojs6.databinding.OperationDialogItemBinding;
import java.util.ArrayList;
/**
* Created by Stardust on 2017/6/26.
* Created by Stardust on Jun 26, 2017.
*/
public class CircularMenuOperationDialogBuilder extends AppLevelThemeDialogBuilder {

View File

@@ -19,7 +19,7 @@ import org.autojs.autojs.util.ViewUtils.showSnack
import org.autojs.autojs6.R
/**
* Created by Stardust on 2017/8/4.
* Created by Stardust on Aug 4, 2017.
* Modified by SuperMonster003 as of Sep 10, 2022.
* Transformed by SuperMonster003 on Oct 19, 2022.
*/

View File

@@ -10,7 +10,7 @@ import android.view.ViewGroup;
import org.autojs.autojs.util.ViewUtils;
/**
* Created by Stardust on 2017/1/30.
* Created by Stardust on Jan 30, 2017.
*/
public abstract class Fragment extends androidx.fragment.app.Fragment {

View File

@@ -12,7 +12,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* Created by Stardust on 2017/3/24.
* Created by Stardust on Mar 24, 2017.
*/
public class FragmentPagerAdapterBuilder {

View File

@@ -7,7 +7,7 @@ import android.os.Handler;
import android.os.Looper;
/**
* Created by Stardust on 2018/3/22.
* Created by Stardust on Mar 22, 2018.
*/
public class GlobalAppContext {

View File

@@ -8,7 +8,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* Created by Stardust on 2017/3/5.
* Created by Stardust on Mar 5, 2017.
*/
public interface OnActivityResultDelegate {

View File

@@ -5,7 +5,7 @@ import android.app.Application;
import android.os.Bundle;
/**
* Created by Stardust on 2017/4/2.
* Created by Stardust on Apr 2, 2017.
*/
public class SimpleActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {

View File

@@ -2,7 +2,6 @@ package org.autojs.autojs.app.tool
import android.app.Activity
import android.content.Context
import org.autojs.autojs.service.AccessibilityService
import org.autojs.autojs.ui.floating.FloatyWindowManger
import org.autojs.autojs.ui.main.drawer.ShowableItemHelper
@@ -11,8 +10,6 @@ import org.autojs.autojs.ui.main.drawer.ShowableItemHelper
*/
open class FloatingButtonTool(final override val context: Context) : ShowableItemHelper {
private val mAccessibilityService: AccessibilityService = AccessibilityService(context)
override val isShowing
get() = FloatyWindowManger.isCircularMenuShowing()
@@ -20,10 +17,14 @@ open class FloatingButtonTool(final override val context: Context) : ShowableIte
override fun show(): Boolean {
FloatyWindowManger.showCircularMenu(context)
return when (isShowing) {
true -> true.also { mAccessibilityService.startIfNeeded() }
else -> false
}
// @Comment by SuperMonster003 on Nov 16, 2023.
// ! Seems pointless to force a11y service
// ! to start along with showing floating button.
// return when (isShowing) {
// true -> true.also { mAccessibilityService.startIfNeeded() }
// else -> false
// }
return isShowing
}
override fun showIfNeeded() {

View File

@@ -7,7 +7,7 @@ import org.autojs.autojs.core.accessibility.NodeInfo;
import org.autojs.autojs.core.automator.UiObject;
/**
* Created by Stardust on 2017/12/7.
* Created by Stardust on Dec 7, 2017.
*/
public class CodeGenerator {

View File

@@ -10,7 +10,7 @@ import org.autojs.autojs.core.accessibility.NodeInfo;
import org.autojs.autojs.core.automator.UiObject;
/**
* Created by Stardust on 2017/11/5.
* Created by Stardust on Nov 5, 2017.
*/
public class ReadOnlyUiObject extends UiObject {

View File

@@ -5,7 +5,7 @@ import org.autojs.autojs.core.automator.UiObject
import org.autojs.autojs.tool.Consumer
/**
* Created by Stardust on 2017/12/7.
* Created by Stardust on Dec 7, 2017.
* Modified by SuperMonster003 as of Sep 2, 2022.
*/
class UiSelectorGenerator(private val mRoot: UiObject, private val mTarget: UiObject) {

View File

@@ -4,7 +4,7 @@ import java.lang.reflect.Array;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Created by Stardust on 2017/12/30.
* Created by Stardust on Dec 30, 2017.
*/
public class ConcurrentArrayList<T> {

View File

@@ -4,7 +4,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by Stardust on 2017/5/2.
* Created by Stardust on May 2, 2017.
*/
public class UnderUseExecutors {

View File

@@ -1,7 +1,7 @@
package org.autojs.autojs.concurrent;
/**
* Created by Stardust on 2017/12/27.
* Created by Stardust on Dec 27, 2017.
*/
public class Value<T> {

View File

@@ -1,8 +1,7 @@
package org.autojs.autojs.concurrent;
/**
* Created by Stardust on 2017/5/8.
* Created by Stardust on May 8, 2017.
* Modified by SuperMonster003 as of Jun 11, 2022.
*/
public class VolatileBox<T> {

View File

@@ -1,7 +1,7 @@
package org.autojs.autojs.concurrent;
/**
* Created by Stardust on 2017/10/28.
* Created by Stardust on Oct 28, 2017.
*/
public class VolatileDispose<T> {

View File

@@ -7,6 +7,7 @@ import android.view.accessibility.AccessibilityWindowInfo;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.autojs.autojs.annotation.ScriptInterface;
import org.autojs.autojs.core.activity.ActivityInfoProvider;
import org.autojs.autojs.permission.UsageStatsPermission;
import org.autojs.autojs.runtime.accessibility.AccessibilityConfig;
@@ -17,9 +18,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Created by Stardust on 2017/4/2.
* Created by Stardust on Apr 2, 2017.
*/
public abstract class AccessibilityBridge {
@@ -152,6 +152,7 @@ public abstract class AccessibilityBridge {
return mConfig;
}
@ScriptInterface
public void setAccessibilityListener(AccessibilityServiceCallback listener) {
AccessibilityService.Companion.setCallback(listener);
}

View File

@@ -4,7 +4,7 @@ import android.accessibilityservice.AccessibilityService
import android.view.accessibility.AccessibilityEvent
/**
* Created by Stardust on 2017/2/14.
* Created by Stardust on Feb 14, 2017.
*/
interface AccessibilityDelegate {

View File

@@ -8,7 +8,7 @@ import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import java.util.*
/**
* Created by Stardust on 2017/3/22.
* Created by Stardust on Mar 22, 2017.
* Modified by SuperMonster003 as of Jun 17, 2022.
*/
open class AccessibilityNodeInfoAllocator {
@@ -110,7 +110,8 @@ open class AccessibilityNodeInfoAllocator {
val global = AccessibilityNodeInfoAllocator()
fun recycleList(root: AccessibilityNodeInfo, list: List<AccessibilityNodeInfo>) {
// FIXME: 2017/5/1 Issue #180
// FIXME by Stardust on May 1, 2017.
// ! Issue #180.
list.takeIf { SDK_INT < TIRAMISU }
?.filter { it !== root }
?.forEach {

View File

@@ -5,7 +5,7 @@ import android.view.accessibility.AccessibilityNodeInfo
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
/**
* Created by Stardust on 2017/3/6.
* Created by Stardust on Mar 6, 2017.
*/
object AccessibilityNodeInfoHelper {

View File

@@ -10,7 +10,7 @@ import java.util.ArrayList
import java.util.concurrent.CopyOnWriteArrayList
/**
* Created by Stardust on 2017/11/3.
* Created by Stardust on Nov 3, 2017.
*/
class AccessibilityNotificationObserver(private val mContext: Context) : NotificationListener, AccessibilityDelegate {

View File

@@ -1,7 +1,5 @@
package org.autojs.autojs.core.accessibility
import android.accessibilityservice.AccessibilityServiceInfo
import android.os.Build
import android.util.Log
import android.view.KeyEvent
import android.view.accessibility.AccessibilityEvent
@@ -13,14 +11,15 @@ import org.autojs.autojs.core.accessibility.SimpleActionAutomator.Companion.Acce
import org.autojs.autojs.core.automator.AccessibilityEventWrapper
import org.autojs.autojs.event.EventDispatcher
import org.autojs.autojs.pref.Language
import org.autojs.autojs.pref.Pref
import java.util.*
import java.util.TreeMap
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.concurrent.locks.ReentrantLock
/**
* Created by Stardust on 2017/5/2.
* Created by Stardust on May 2, 2017.
* Modified by SuperMonster003 as of Mar 20, 2022.
*/
open class AccessibilityService : android.accessibilityservice.AccessibilityService() {
@@ -33,6 +32,10 @@ open class AccessibilityService : android.accessibilityservice.AccessibilityServ
private val gestureEventDispatcher = EventDispatcher<GestureListener>()
private var mEventExecutor: ExecutorService? = null
private val eventExecutor: ExecutorService
get() = mEventExecutor ?: Executors.newSingleThreadExecutor().also { mEventExecutor = it }
private fun eventNameToType(event: String): Int {
return try {
AccessibilityEvent::class.java.getField(
@@ -53,7 +56,6 @@ open class AccessibilityService : android.accessibilityservice.AccessibilityServ
override fun onAccessibilityEvent(event: AccessibilityEvent) {
instance = this
connected = true
val type = event.eventType
eventBox[type]?.onAccessibilityEvent(AccessibilityEventWrapper(event))
if (containsAllEventTypes || eventTypes.contains(type)) {
@@ -106,40 +108,26 @@ open class AccessibilityService : android.accessibilityservice.AccessibilityServ
override fun onDestroy() {
Log.v(TAG, "onDestroy: $instance")
eventExecutor.shutdownNow()
eventExecutor.awaitTermination(1000L, TimeUnit.MILLISECONDS)
instance = null
bridge = null
mEventExecutor?.shutdownNow()
callback?.onDisconnected()
connected = false
super.onDestroy()
}
override fun onServiceConnected() {
Log.d(TAG, "onServiceConnected")
instance = this
connected = true
super.onServiceConnected()
Log.d(TAG, "onServiceConnected: $serviceInfo")
instance = this
callback?.onConnected()
LOCK.lock()
try {
ENABLED.signalAll()
serviceInfo = serviceInfo.also { info ->
AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS.let {
info.flags = (if (Pref.isStableModeEnabled) info.flags and it.inv() else info.flags or it)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE.let {
info.flags = (if (Pref.isGestureObservingEnabled) info.flags or it else info.flags and it.inv())
}
}
}
callback?.onConnected()
} finally {
LOCK.unlock()
}
// FIXME: 2017/2/12 有时在无障碍中开启服务后这里不会调用服务也不会运行安卓的BUG???
ENABLED.signalAll()
LOCK.unlock()
// FIXME by Stardust on Feb 12, 2017.
// ! 有时在无障碍中开启服务后这里不会调用服务也不会运行, 安卓的 BUG ???
}
companion object {
@@ -153,9 +141,6 @@ open class AccessibilityService : android.accessibilityservice.AccessibilityServ
private val LOCK = ReentrantLock()
private val ENABLED = LOCK.newCondition()
private var callback: AccessibilityServiceCallback? = null
private val eventExecutor = Executors.newSingleThreadExecutor()
private var connected = false
var instance: AccessibilityService? = null
private set
@@ -168,7 +153,7 @@ open class AccessibilityService : android.accessibilityservice.AccessibilityServ
val stickOnKeyObserver = OnKeyListener.Observer()
fun isRunning() = connected && instance != null
fun isRunning() = instance != null
fun addDelegate(uniquePriority: Int, delegate: AccessibilityDelegate) {
// @Hint by 抠脚本人 on Jul 10, 2023.
@@ -184,10 +169,7 @@ open class AccessibilityService : android.accessibilityservice.AccessibilityServ
fun stop() = try {
instance?.disableSelf()
eventExecutor.shutdownNow()
eventExecutor.awaitTermination(1000L, TimeUnit.MILLISECONDS)
callback?.onDisconnected()
connected = false
instance = null
true
} catch (e: Exception) {
false
@@ -227,5 +209,7 @@ open class AccessibilityService : android.accessibilityservice.AccessibilityServ
interface GestureListener {
fun onGesture(gestureId: Int)
}
}
}

View File

@@ -0,0 +1,35 @@
package org.autojs.autojs.core.accessibility
import android.accessibilityservice.AccessibilityServiceInfo
import android.os.Build
import android.util.Log
import org.autojs.autojs.pref.Pref
class AccessibilityServiceUsher : AccessibilityService() {
override fun onServiceConnected() {
Log.d(TAG, "onServiceConnected")
val serviceInfo = serviceInfo
if (Pref.isStableModeEnabled) {
serviceInfo.flags = serviceInfo.flags and AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS.inv()
} else {
serviceInfo.flags = serviceInfo.flags or AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Pref.isGestureObservingEnabled) {
serviceInfo.flags = serviceInfo.flags or AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE
} else {
serviceInfo.flags = serviceInfo.flags and AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE.inv()
}
}
setServiceInfo(serviceInfo)
super.onServiceConnected()
}
companion object {
private val TAG = AccessibilityServiceUsher::class.java.simpleName
}
}

View File

@@ -8,6 +8,7 @@ import android.provider.Settings
import android.provider.Settings.Secure
import android.text.TextUtils
import android.util.Log
import org.autojs.autojs.app.GlobalAppContext
import org.autojs.autojs.pref.Pref
import org.autojs.autojs.runtime.api.ProcessShell
import org.autojs.autojs.runtime.exception.ScriptException
@@ -18,13 +19,13 @@ import org.autojs.autojs.util.ViewUtils
import org.autojs.autojs6.R
/**
* Created by Stardust on 2017/1/26.
* Created by Stardust on Jan 26, 2017.
* Modified by SuperMonster003 as of Feb 15, 2022.
*/
class AccessibilityTool(val context: Context) {
private val tag: String = AccessibilityTool::class.java.simpleName
private val serviceName = "${context.packageName}/${AccessibilityService::class.java.name}"
private val serviceName = "${(GlobalAppContext.get()?: context).packageName}/${AccessibilityServiceUsher::class.java.name}"
val service: Service = Service()
@@ -56,7 +57,7 @@ class AccessibilityTool(val context: Context) {
) ?: return false
TextUtils.SimpleStringSplitter(':').also { colonSplitter ->
colonSplitter.setString(services)
val expectedComponentName = ComponentName(context, AccessibilityService::class.java)
val expectedComponentName = ComponentName(context, AccessibilityServiceUsher::class.java)
while (colonSplitter.hasNext()) {
val componentNameString = colonSplitter.next()
val componentName = ComponentName.unflattenFromString(componentNameString)

View File

@@ -5,7 +5,7 @@ import android.view.KeyEvent
import java.util.concurrent.CopyOnWriteArrayList
/**
* Created by Stardust on 2018/2/27.
* Created by Stardust on Feb 27, 2018.
*/
interface KeyInterceptor {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.accessibility
import android.accessibilityservice.AccessibilityServiceInfo
/**
* Created by Stardust on 2017/7/13.
* Created by Stardust on Jul 13, 2017.
*/
class LayoutInspectService : AccessibilityService() {

View File

@@ -7,7 +7,7 @@ import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.Executors
/**
* Created by Stardust on 2017/3/10.
* Created by Stardust on Mar 10, 2017.
*/
class LayoutInspector(private val mContext: Context) {

View File

@@ -14,7 +14,7 @@ import java.util.ArrayList
import java.util.HashMap
/**
* Created by Stardust on 2017/3/10.
* Created by Stardust on Mar 10, 2017.
* Modified by SuperMonster003 as of Jun 17, 2022.
*/

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.accessibility
import org.autojs.autojs.core.notification.Notification
/**
* Created by Stardust on 2017/8/1.
* Created by Stardust on Aug 1, 2017.
*/
interface NotificationListener {

View File

@@ -5,7 +5,7 @@ import android.view.KeyEvent
import java.util.concurrent.CopyOnWriteArrayList
/**
* Created by Stardust on 2017/7/18.
* Created by Stardust on Jul 18, 2017.
*/
interface OnKeyListener {

View File

@@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger
import android.accessibilityservice.AccessibilityService as AndroidAccessibilityService
/**
* Created by Stardust on 2017/4/2.
* Created by Stardust on Apr 2, 2017.
*/
class SimpleActionAutomator(private val accessibilityBridge: AccessibilityBridge, private val scriptRuntime: ScriptRuntime) {

View File

@@ -6,7 +6,6 @@ import android.os.Looper
import android.os.SystemClock
import android.view.accessibility.AccessibilityNodeInfo
import androidx.annotation.FloatRange
import org.autojs.autojs.AutoJs
import org.autojs.autojs.annotation.ScriptInterface
import org.autojs.autojs.app.GlobalAppContext
import org.autojs.autojs.concurrent.VolatileBox
@@ -58,7 +57,7 @@ import org.mozilla.javascript.regexp.NativeRegExp
import java.math.BigInteger
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Jun 11, 2022.
*/
open class UiSelector : UiObjectActions {
@@ -750,13 +749,20 @@ open class UiSelector : UiObjectActions {
private fun addFilter(filter: Filter) = also { selector.add(filter) }
private fun append(selector: UiSelector?) = also {
fun append(selector: UiSelector?) = also {
selector?.let {
this.selector.append(it)
this.searchAlgorithm = it.searchAlgorithm
}
}
fun plus(selector: UiSelector?) = selector?.let { paramSel ->
UiSelector().also { newSel ->
newSel.selector.filters.addAll(this.selector.filters + paramSel.selector.filters)
newSel.searchAlgorithm = paramSel.searchAlgorithm
}
} ?: this
companion object {
internal const val ID_IDENTIFIER = ":id/"
@@ -766,34 +772,45 @@ open class UiSelector : UiObjectActions {
}
@JvmStatic
fun pickup(root: UiObject?, selector: Any?, compass: CharSequence?, resultType: Any?, callback: BaseFunction? = null): Any? {
return Picker.Builder()
.setRoot(root)
.setCompass(compass)
.setResultType(resultType)
.setSelector(selector)
.setCallback(callback)
.build()
.pick()
}
fun pickup(
root: UiObject?,
selector: Any?,
compass: CharSequence?,
resultType: Any?,
callback: BaseFunction? = null,
) = Picker.Builder()
.setRoot(root)
.setCompass(compass)
.setResultType(resultType)
.setSelector(selector)
.setCallback(callback)
.build()
.pick()
internal class Picker private constructor(val root: UiObject?, val selector: UiSelector?, val compass: CharSequence?, val resultType: Any?, val callback: BaseFunction? = null) {
internal class Picker private constructor(
val root: UiObject?,
val selector: UiSelector?,
val compass: CharSequence?,
val resultType: Any?,
val callback: BaseFunction? = null,
) {
internal fun pick(): Any? {
a11yToolService.ensure()
return Detector(compass, object : Result(resultType) {
internal fun pick() = Detector(compass, object : Result(resultType) {
override fun byOne() = selector?.run { root?.let { return@run findOneOf(it) } ?: findOnce() }
override fun byOne() = selector?.let { sel ->
root?.let { return sel.findOneOf(it) } ?: sel.findOnce()
}
override fun byAll() = selector?.run { root?.let { return@run findOf(it) } ?: find() } ?: EMPTY
override fun byAll() = selector?.let { sel ->
root?.let { return sel.findOf(it) } ?: sel.find()
} ?: EMPTY
}, callback, selector).detect()
}
}, callback, selector).detect()
internal class Builder {
private var mRoot: UiObject? = null
private var mSelector = UiSelector()
private var mSelector = UiSelector(AccessibilityService.bridge)
private var mCompass: CharSequence? = COMPASS_PASS_ON
private var mResultType: Any = RESULT_TYPE_WIDGET
private var mCallback: BaseFunction? = null

View File

@@ -16,7 +16,7 @@ import org.autojs.autojs.runtime.api.Shell
import java.util.regex.Pattern
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
*/
class ActivityInfoProvider(private val context: Context) : AccessibilityDelegate {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator
import android.os.Bundle
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
*/
abstract class ActionArgument private constructor(protected val key: String) {

View File

@@ -18,7 +18,7 @@ import org.autojs.autojs.runtime.api.ScreenMetrics
import org.autojs.autojs6.R
/**
* Created by Stardust on 2017/5/16.
* Created by Stardust on May 16, 2017.
* Modified by SuperMonster003 as of Dec 1, 2021.
*/
class GlobalActionAutomator(private val mContext: Context, private val mHandler: Handler?, private val serviceProvider: () -> AccessibilityService) {

View File

@@ -26,7 +26,7 @@ import org.opencv.core.Point
import org.opencv.core.Size
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of May 26, 2022.
*/
@@ -62,7 +62,7 @@ open class UiObject(
} ?: 0)
}
} catch (e: IllegalStateException) {
// FIXME: 2017/5/5
// FIXME by Stardust on May 5, 2017.
null.also { e.printStackTrace() }
}
@@ -75,7 +75,7 @@ open class UiObject(
return try {
super.getChild(i)?.run { UiObject(unwrap(), depth + 1, i) }
} catch (e: IllegalStateException) {
// FIXME: 2017/5/5
// FIXME by Stardust on May 5, 2017.
null.also { e.printStackTrace() }
}
}
@@ -391,14 +391,14 @@ open class UiObject(
else -> super.performAction(action, bundle)
}
} catch (e: IllegalStateException) {
// FIXME: 2017/5/5
// FIXME by Stardust on May 5, 2017.
false.also { e.printStackTrace() }
}
override fun performAction(action: Int): Boolean = try {
super.performAction(action)
} catch (e: IllegalStateException) {
// FIXME: 2017/5/5
// FIXME by Stardust on May 5, 2017.
false.also { e.printStackTrace() }
}

View File

@@ -4,7 +4,7 @@ import org.autojs.autojs.core.accessibility.UiSelector
import org.autojs.autojs.tool.Consumer
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Jul 1, 2022.
*/
class UiObjectCollection private constructor(val nodes: List<UiObject?>) : UiObjectActions {

View File

@@ -5,7 +5,7 @@ import org.autojs.autojs.core.automator.UiObject
import org.autojs.autojs.tool.SparseArrayEntries
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
interface Able {

View File

@@ -6,7 +6,7 @@ import android.view.accessibility.AccessibilityNodeInfo
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
object ActionFactory {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.action
import android.graphics.Rect
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
interface ActionTarget {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.action
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
class DepthFirstSearchTargetAction(action: Int, filter: Filter) : SearchTargetAction(action, filter) {

View File

@@ -7,7 +7,7 @@ import org.autojs.autojs.core.automator.UiObject
import java.util.*
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
abstract class FilterAction(private val mFilter: Filter) : SimpleAction() {

View File

@@ -5,7 +5,7 @@ import org.autojs.autojs.core.automator.UiObject
import java.util.ArrayList
/**
* Created by Stardust on 2017/2/12.
* Created by Stardust on Feb 12, 2017.
*/
class ScrollAction(private val mAction: Int, private val mIndex: Int) : SimpleAction() {

View File

@@ -8,7 +8,7 @@ import org.autojs.autojs.core.automator.UiObject
import java.util.HashSet
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
class ScrollMaxAction(private val mScrollAction: Int) : SimpleAction() {
private var mMaxScrollableNode: UiObject? = null

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.action
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
abstract class SearchTargetAction(val action: Int, filter: Filter) : FilterAction(filter) {

View File

@@ -4,7 +4,7 @@ package org.autojs.autojs.core.automator.action
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
class SearchUpTargetAction(action: Int, filter: Filter) : SearchTargetAction(action, filter) {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.action
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/1/27.
* Created by Stardust on Jan 27, 2017.
*/
abstract class SimpleAction {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
class BooleanFilter(private val mBooleanSupplier: BooleanSupplier, private val mExceptedValue: Boolean? = null) : Filter {

View File

@@ -10,7 +10,7 @@ import org.autojs.autojs.util.DisplayUtils.toFloorIntY
import org.autojs.autojs.util.StringUtils.formatDouble
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
class BoundsFilter(private val left: Double, private val top: Double, private val right: Double, private val bottom: Double, private val type: Int) : Filter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
object ClassNameFilter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
object DescFilter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
*/
interface Filter {

View File

@@ -4,7 +4,7 @@ import org.autojs.autojs.core.accessibility.UiSelector.Companion.ID_IDENTIFIER
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
object IdFilter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/11/5.
* Created by Stardust on Nov 5, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
class IntFilter(private val mIntProperty: IntProperty, private val mValue: Int) : Filter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
*/
interface KeyGetter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
object PackageNameFilter {

View File

@@ -4,18 +4,16 @@ import org.autojs.autojs.core.accessibility.UiSelector
import org.autojs.autojs.core.automator.UiObject
import java.util.*
class Selector : Filter {
open class Selector : Filter {
private val mFilters = LinkedList<Filter>()
val filters = LinkedList<Filter>()
override fun filter(node: UiObject) = mFilters.all { it.filter(node) }
override fun filter(node: UiObject) = filters.all { it.filter(node) }
private fun getFilter() = mFilters
fun add(filter: Filter) = filters.add(filter)
fun add(filter: Filter) = mFilters.add(filter)
fun append(uiSelector: UiSelector) = filters.addAll(uiSelector.selector.filters)
fun append(uiSelector: UiSelector) = mFilters.addAll(uiSelector.selector.getFilter())
override fun toString() = mFilters.joinToString(".").ifEmpty { Selector::class.java.toString() }
override fun toString() = filters.joinToString(".").ifEmpty { Selector::class.java.toString() }
}

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
class StringContainsFilter internal constructor(private val mContains: String, private val mKeyGetter: KeyGetter) : Filter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
class StringEndsWithFilter(private val mSuffix: String, private val mKeyGetter: KeyGetter) : Filter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
class StringEqualsFilter(private val mValue: String, private val mKeyGetter: KeyGetter) : Filter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
class StringMatchFilter internal constructor(private val mRegex: String, private val mKeyGetter: KeyGetter) : Filter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
*/
class StringMatchesFilter internal constructor(private val mRegex: String, private val mKeyGetter: KeyGetter) : Filter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
class StringStartsWithFilter(private val mPrefix: String, private val mKeyGetter: KeyGetter) : Filter {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.automator.filter
import org.autojs.autojs.core.automator.UiObject
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
* Modified by SuperMonster003 as of Nov 19, 2022.
*/
object TextFilter {

View File

@@ -7,7 +7,7 @@ import java.util.*
import kotlin.collections.ArrayList
/**
* Created by Stardust on 2017/3/9.
* Created by Stardust on Mar 9, 2017.
*/
object DFS : SearchAlgorithm {

View File

@@ -7,7 +7,7 @@ import java.util.*
import kotlin.math.max
/**
* Created by Stardust on 2017/5/5.
* Created by Stardust on May 5, 2017.
*/
class TestUiObject @JvmOverloads constructor(private val mChildCount: Int = max(0, random.nextInt(6) - 2)) : UiObject(null) {

View File

@@ -3,7 +3,7 @@ package org.autojs.autojs.core.broadcast;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* Created by Stardust on 2018/4/1.
* Created by Stardust on Apr 1, 2018.
*/
public class Broadcast {

View File

@@ -5,7 +5,7 @@ import org.autojs.autojs.core.looper.Timer;
import org.autojs.autojs.runtime.ScriptBridges;
/**
* Created by Stardust on 2018/4/1.
* Created by Stardust on Apr 1, 2018.
*/
public class BroadcastEmitter extends EventEmitter {

View File

@@ -22,7 +22,7 @@ import org.autojs.autojs6.databinding.FloatingConsoleExpandBinding
import org.autojs.autojs6.databinding.FloatingWindowCollapseBinding
/**
* Created by Stardust on 2017/4/20.
* Created by Stardust on Apr 20, 2017.
*/
class ConsoleFloaty(private val mConsole: ConsoleImpl) : AbstractResizableExpandableFloaty() {

View File

@@ -35,9 +35,8 @@ import java.util.concurrent.atomic.AtomicInteger
import kotlin.math.ceil
import kotlin.math.pow
/**
* Created by Stardust on 2017/5/2.
* Created by Stardust on May 2, 2017.
* Modified by SuperMonster003 as of Apr 12, 2023.
* Transformed by SuperMonster003 on Apr 12, 2023.
*/
@@ -432,7 +431,7 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
override fun setPosition(x: Double, y: Double) = runWithWindow {
configurator.setPosition(x, y)
if (isShowing) {
mFloatyWindow!!.windowBridge.updatePosition(x.toInt(), y.toInt())
mFloatyWindow!!.windowBridge?.updatePosition(x.toInt(), y.toInt())
}
}

View File

@@ -34,7 +34,7 @@ import java.util.Map;
import java.util.Objects;
/**
* Created by Stardust on 2017/5/2.
* Created by Stardust on May 2, 2017.
* <p>
* TODO: 优化为无锁形式
*/

View File

@@ -20,7 +20,7 @@ import java.util.Date;
import java.util.Locale;
/**
* Created by Stardust on 2017/10/22.
* Created by Stardust on Oct 22, 2017.
*/
public class GlobalConsole extends ConsoleImpl {
private static final String TAG = GlobalConsole.class.getSimpleName();

View File

@@ -17,7 +17,7 @@ import java.util.TooManyListenersException;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* Created by Stardust on 2017/7/19.
* Created by Stardust on Jul 19, 2017.
*/
public class EventEmitter {

View File

@@ -24,9 +24,8 @@ import org.autojs.autojs6.R
import org.autojs.autojs6.databinding.FloatyWindowBinding
import org.autojs.autojs6.databinding.RawWindowBinding
/**
* Created by Stardust on 2017/12/5.
* Created by Stardust on Dec 5, 2017.
* Modified by SuperMonster003 as of Jun 10, 2022.
* Transformed by SuperMonster003 on Oct 10, 2022.
*/

View File

@@ -17,7 +17,7 @@ import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
/**
* Created by Stardust on 2018/3/16.
* Created by Stardust on Mar 16, 2018.
*/
@SuppressLint("ViewConstructor")
class JsCanvasView : TextureView, TextureView.SurfaceTextureListener {

View File

@@ -18,7 +18,7 @@ import androidx.annotation.Nullable;
import org.autojs.autojs.core.image.ImageWrapper;
/**
* Created by Stardust on 2018/3/22.
* Created by Stardust on Mar 22, 2018.
*/
@SuppressWarnings("unused")
public class ScriptCanvas {

View File

@@ -6,7 +6,7 @@ import okhttp3.Response
import java.util.concurrent.TimeUnit
/**
* Created by Stardust on 2018/4/11.
* Created by Stardust on Apr 11, 2018.
* Modified by SuperMonster003 as of Sep 8, 2022.
*/
class MutableOkHttp : OkHttpClient() {

View File

@@ -12,7 +12,7 @@ import kotlin.math.roundToInt
import kotlin.math.sqrt
/**
* Created by Stardust on 2017/5/20.
* Created by Stardust on May 20, 2017.
* Modified by SuperMonster003 as of Feb 15, 2023.
*/
interface ColorDetector {

View File

@@ -18,9 +18,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* Created by Stardust on 2017/5/18.
* Created by Stardust on May 18, 2017.
*/
@SuppressWarnings("unused")
public class ColorFinder {

View File

@@ -7,7 +7,7 @@ import androidx.annotation.ColorInt;
import org.autojs.autojs.util.ColorUtils;
/**
* Created by Stardust on 2017/12/31.
* Created by Stardust on Dec 31, 2017.
*/
public class Colors {

View File

@@ -18,7 +18,7 @@ import java.io.FileOutputStream
import java.lang.ref.WeakReference
/**
* Created by Stardust on 2017/11/25.
* Created by Stardust on Nov 25, 2017.
* Modified by SuperMonster003 as of May 16, 2023.
* Transformed by SuperMonster003 on May 16, 2023.
*/

View File

@@ -20,9 +20,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* Created by Stardust on 2017/11/25.
* Created by Stardust on Nov 25, 2017.
*/
public class TemplateMatching {

View File

@@ -12,7 +12,7 @@ import org.autojs.autojs.app.OnActivityResultDelegate;
import org.autojs.autojs.tool.IntentExtras;
/**
* Created by Stardust on 2017/5/22.
* Created by Stardust on May 22, 2017.
*/
public class ScreenCaptureRequestActivity extends Activity {

View File

@@ -8,7 +8,7 @@ import android.media.projection.MediaProjectionManager;
import org.autojs.autojs.app.OnActivityResultDelegate;
/**
* Created by Stardust on 2017/5/17.
* Created by Stardust on May 17, 2017.
*/
public interface ScreenCaptureRequester {

View File

@@ -33,7 +33,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
/**
* Created by Stardust on 2017/5/17.
* Created by Stardust on May 17, 2017.
* Modified by SuperMonster003 as of May 19, 2022.
*/
public class ScreenCapturer {

View File

@@ -45,7 +45,7 @@ public class ScreenCapturerForegroundService extends Service {
ForegroundServiceCreator foregroundServiceCreator = new ForegroundServiceCreator.Builder(this)
.setClassName(sClassName)
.setIntent(
// @Reference to TonyJiangWJ/Auto.js (https://github.com/TonyJiangWJ/Auto.js) on Apr 10, 2022
// @Reference to TonyJiangWJ/Auto.js (https://github.com/TonyJiangWJ/Auto.js) on Apr 10, 2022.
ScreenCaptureRequestActivity.getIntent(this)
)
.setNotificationId(NOTIFICATION_ID)
@@ -64,8 +64,8 @@ public class ScreenCapturerForegroundService extends Service {
@Override
public void onDestroy() {
stopForeground(STOP_FOREGROUND_REMOVE);
super.onDestroy();
stopForeground(true);
}
}

Some files were not shown because too many files have changed in this diff Show More