6.6.1 - Alpha3 - 提升浮动窗口当前包名及当前活动名的识别准确性
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
"UiObjectCollection 实例缺失自身方法及属性的问题"
|
||||
],
|
||||
"improvement": [
|
||||
"提升浮动窗口当前包名及当前活动名的识别准确性 (优先级: Shizuku > Root > A11Y)",
|
||||
"提升 currentPackage/currentActivity 识别准确性 (优先级: Shizuku > Root > A11Y)",
|
||||
"恢复日志活动窗口单个条目文本内容的双击或长按选择功能 _[`issue #280`](http://issues.autojs6.com/280)_",
|
||||
"脚本项目识别在 project.json 损坏情况下尽可能还原关键信息",
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.autojs.autojs.runtime.ScriptRuntime
|
||||
import org.autojs.autojs.runtime.accessibility.AccessibilityConfig
|
||||
import org.autojs.autojs.runtime.api.ScreenMetrics
|
||||
import org.autojs.autojs.runtime.api.ScriptPromiseAdapter
|
||||
import org.autojs.autojs.runtime.api.augment.global.Global
|
||||
import org.autojs.autojs.util.DeveloperUtils
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
@@ -52,7 +53,7 @@ class SimpleActionAutomator(private val accessibilityBridge: AccessibilityBridge
|
||||
}
|
||||
|
||||
private val isRunningPackageSelf
|
||||
get() = DeveloperUtils.isSelfPackage(accessibilityBridge.infoProvider.latestPackage)
|
||||
get() = DeveloperUtils.isSelfPackage(Global.currentPackage(scriptRuntime, emptyArray()))
|
||||
|
||||
private var mScreenMetrics: ScreenMetrics? = null
|
||||
private val mScriptRuntime = WeakReference(scriptRuntime)
|
||||
|
||||
@@ -117,6 +117,7 @@ object WrappedShizuku {
|
||||
false.also { if (e.message?.contains(Regex("binder .+n[o']t been received", RegexOption.IGNORE_CASE)) == false) e.printStackTrace() }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ScriptInterface
|
||||
fun isOperational(): Boolean = isRunning() && hasPermission()
|
||||
|
||||
|
||||
@@ -97,15 +97,23 @@ class Shell(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntim
|
||||
@JvmStatic
|
||||
@RhinoRuntimeFunctionInterface
|
||||
fun currentPackage(scriptRuntime: ScriptRuntime, args: Array<out Any?>): String = ensureArgumentsIsEmpty(args) {
|
||||
currentComponent(scriptRuntime, args).substringBefore("/")
|
||||
currentPackageRhino()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun currentPackageRhino(): String = currentComponentRhino().substringBefore("/")
|
||||
|
||||
@JvmStatic
|
||||
@RhinoRuntimeFunctionInterface
|
||||
fun currentActivity(scriptRuntime: ScriptRuntime, args: Array<out Any?>): String = ensureArgumentsIsEmpty(args) {
|
||||
val component = currentComponent(scriptRuntime, args)
|
||||
currentActivityRhino()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun currentActivityRhino(): String {
|
||||
val component = currentComponentRhino()
|
||||
val className = component.substringAfterLast("/")
|
||||
when {
|
||||
return when {
|
||||
className.startsWith(".") -> component
|
||||
else -> className
|
||||
}
|
||||
@@ -114,7 +122,12 @@ class Shell(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntim
|
||||
@JvmStatic
|
||||
@RhinoRuntimeFunctionInterface
|
||||
fun currentComponent(scriptRuntime: ScriptRuntime, args: Array<out Any?>): String = ensureArgumentsIsEmpty(args) {
|
||||
if (!RootUtils.isRootAvailable()) return@ensureArgumentsIsEmpty ""
|
||||
currentComponentRhino()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun currentComponentRhino(): String {
|
||||
if (!RootUtils.isRootAvailable()) return ""
|
||||
try {
|
||||
val process = Runtime.getRuntime().exec("su -c dumpsys activity activities")
|
||||
process.inputStream.bufferedReader().useLines { lines ->
|
||||
@@ -127,14 +140,14 @@ class Shell(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntim
|
||||
part.contains("/")
|
||||
}?.let { part ->
|
||||
Log.d(TAG, "current activity part: $part")
|
||||
return@ensureArgumentsIsEmpty part.replace("\\W+$".toRegex(), "")
|
||||
return part.replace("\\W+$".toRegex(), "")
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Error reading current component", e)
|
||||
}
|
||||
return@ensureArgumentsIsEmpty ""
|
||||
return ""
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.autojs.autojs.ui.floating;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
@@ -24,6 +25,8 @@ import org.autojs.autojs.core.record.Recorder;
|
||||
import org.autojs.autojs.model.explorer.ExplorerDirPage;
|
||||
import org.autojs.autojs.model.explorer.Explorers;
|
||||
import org.autojs.autojs.model.script.Scripts;
|
||||
import org.autojs.autojs.runtime.api.WrappedShizuku;
|
||||
import org.autojs.autojs.runtime.api.augment.shell.Shell;
|
||||
import org.autojs.autojs.tool.Func1;
|
||||
import org.autojs.autojs.ui.enhancedfloaty.FloatyService;
|
||||
import org.autojs.autojs.ui.enhancedfloaty.FloatyWindow;
|
||||
@@ -173,9 +176,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
mSettingsDialog.dismiss();
|
||||
}
|
||||
|
||||
ActivityInfoProvider infoProvider = AutoJs.getInstance().getInfoProvider();
|
||||
mRunningPackage = infoProvider.getLatestPackageByUsageStatsIfGranted();
|
||||
mRunningActivity = infoProvider.getLatestActivity();
|
||||
applyComponentInformation();
|
||||
|
||||
// noinspection CodeBlock2Expr
|
||||
mSettingsDialog = new CircularMenuOperationDialogBuilder(mContext)
|
||||
@@ -212,6 +213,26 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
});
|
||||
}
|
||||
|
||||
private void applyComponentInformation() {
|
||||
if (WrappedShizuku.isOperational() && WrappedShizuku.service != null) {
|
||||
try {
|
||||
mRunningPackage = WrappedShizuku.service.currentPackage();
|
||||
mRunningActivity = WrappedShizuku.service.currentActivity();
|
||||
return;
|
||||
} catch (RemoteException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
if (RootUtils.isRootAvailable()) {
|
||||
mRunningPackage = Shell.currentPackageRhino();
|
||||
mRunningActivity = Shell.currentActivityRhino();
|
||||
return;
|
||||
}
|
||||
ActivityInfoProvider infoProvider = AutoJs.getInstance().getInfoProvider();
|
||||
mRunningPackage = infoProvider.getLatestPackageByUsageStatsIfGranted();
|
||||
mRunningActivity = infoProvider.getLatestActivity();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private View.OnClickListener onCircularMenuItemClick(View.OnClickListener listener) {
|
||||
return v -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Wed Jan 01 11:40:23 CST 2025
|
||||
BUILD_TIME=1735702823631
|
||||
#Wed Jan 01 12:09:07 CST 2025
|
||||
BUILD_TIME=1735704547526
|
||||
COMPILE_SDK_VERSION=34
|
||||
JAVA_VERSION=23
|
||||
JAVA_VERSION_MIN_RADICAL=0
|
||||
|
||||
Reference in New Issue
Block a user