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