拓展无障碍事件回调参数

This commit is contained in:
抠脚本人
2023-07-11 00:29:11 +08:00
parent a59b46fd6e
commit 392a4b953d
3 changed files with 21 additions and 15 deletions

View File

@@ -56,9 +56,7 @@ open class AccessibilityService : android.accessibilityservice.AccessibilityServ
}
override fun onAccessibilityEvent(event: AccessibilityEvent) {
if (instance != this) {
instance = this
}
if (instance != this) instance = this
val type = event.eventType
eventBox[type]?.onAccessibilityEvent(AccessibilityEventWrapper(event))
if (containsAllEventTypes || eventTypes.contains(type)) {

View File

@@ -1,27 +1,35 @@
package org.autojs.autojs.core.automator
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
class AccessibilityEventWrapper(event: AccessibilityEvent) {
private val node = event.source
val raw = event
val packageName: CharSequence? = event.packageName
val eventType = event.eventType
val eventTime = event.eventTime
val action = event.action
val isFullScreen = event.isFullScreen
val className = event.className
val source = event.source?.let { UiObject(it, getDepth(it), getIndexInParent(it)) }
val source = if (node != null) UiObject(node, null, getDepth(), getIndexInParent()) else null
private fun getDepth(): Int {
private fun getDepth(node: AccessibilityNodeInfo): Int {
var depth = 0
if (node == null) return 0
while (node.parent != null) {
var father = node.parent
while (father != null) {
depth++
father = father.parent
}
return depth
}
private fun getIndexInParent(): Int {
val parent = node!!.parent
private fun getIndexInParent(node: AccessibilityNodeInfo): Int {
var index = 0
val parent = node.parent ?: return 0
while (parent.getChild(index) != node) {
index++
}
return index
}
}
}

View File

@@ -1,8 +1,8 @@
#Mon Jul 10 18:23:10 CST 2023
BUILD_TIME=1688984590330
#Tue Jul 11 00:23:06 CST 2023
BUILD_TIME=1689006186217
COMPILE_SDK_VERSION=33
JAVA_VERSION=20
MIN_SDK_VERSION=24
TARGET_SDK_VERSION=33
VERSION_BUILD=2006
VERSION_BUILD=2010
VERSION_NAME=6.3.2