Skip to content

Commit

Permalink
perf: skipMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 17, 2024
1 parent e7604fb commit a307c83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/src/main/kotlin/li/songe/gkd/service/A11yService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private fun A11yService.useMatchRule() {
}
}
val activityRule = getAndUpdateCurrentRules()
if (activityRule.currentRules.isEmpty() || !storeFlow.value.enableMatch) {
if (activityRule.skipMatch) {
if (META.debuggable) {
Log.d("queryEvents", "没有规则或者禁用匹配")
}
Expand Down Expand Up @@ -448,8 +448,8 @@ private fun A11yService.useMatchRule() {
updateTopActivity(TopActivity(rightAppId))
}
}

if (getAndUpdateCurrentRules().currentRules.isEmpty() || !storeFlow.value.enableMatch || evAppId != rightAppId) {
val activityRule = getAndUpdateCurrentRules()
if (evAppId != rightAppId || activityRule.skipMatch) {
// 放在 evAppId != rightAppId 的前面使得 TopActivity 能借助 lastTopActivity 恢复
return@launchEvent
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/kotlin/li/songe/gkd/service/A11yState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class ActivityRule(
} else {
currentRules
}
val skipMatch: Boolean
get() {
return !currentRules.any { r -> r.status.ok } || !storeFlow.value.enableMatch
}
}

val activityRuleFlow by lazy { MutableStateFlow(ActivityRule()) }
Expand Down

0 comments on commit a307c83

Please sign in to comment.