Skip to content

Commit 4753494

Browse files
committed
忽略更多UI界面
1 parent 5852157 commit 4753494

File tree

10 files changed

+14
-3
lines changed

10 files changed

+14
-3
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.

app/src/main/java/com/zmal/sleepy/AppChangeDetectorService.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@ class AppChangeDetectorService : AccessibilityService() {
7070
}
7171

7272
override fun onAccessibilityEvent(event: AccessibilityEvent) {
73-
if (event.eventType != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || event.className == "android.widget.FrameLayout" || event.className == "android.widget.ScrollView") {
73+
val ignoredClassNames = setOf(
74+
"android.widget.FrameLayout",
75+
"android.widget.ScrollView",
76+
"android.widget.LinearLayout",
77+
"android.view.View",
78+
"android.view.ViewGroup",
79+
"com.android.internal.policy.DecorView" // 系统窗口容器
80+
)
81+
82+
if (event.eventType != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED ||
83+
event.className in ignoredClassNames
84+
) {
7485
logs(
7586
LogLevel.VERBOSE,
7687
"忽略无关事件: eventType=${event.eventType}, className=${event.className}"
@@ -89,7 +100,7 @@ class AppChangeDetectorService : AccessibilityService() {
89100

90101
isUsing = currentIsUsing
91102

92-
logs(LogLevel.DEBUG, "处理包名: $pkgName,类名:${event.className}")
103+
logs(LogLevel.DEBUG, "处理包名: $pkgName,类名:${event.className},亮屏:${isUsing}")
93104

94105
pkgName?.takeIf { it.isNotEmpty() }?.let { packageName ->
95106
handlePackageChange(packageName)
@@ -182,7 +193,7 @@ class AppChangeDetectorService : AccessibilityService() {
182193
val request = Request.Builder().url(config.url)
183194
.post(createRequestBody(appName, config.secret, config.id, config.showName))
184195
.addHeader("User-Agent", USER_AGENT).build()
185-
logs(LogLevel.INFO, appName)
196+
logs(LogLevel.INFO, "${appName}[${isUsing}]")
186197

187198
httpClient.newCall(request).enqueue(ServerCallback())
188199
}

0 commit comments

Comments
 (0)