mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 11:42:22 +08:00
fix: 主线程阻塞导致界面卡顿
This commit is contained in:
parent
fc99e3337e
commit
f40e8d4e35
|
@ -98,6 +98,7 @@ class GkdAbService : CompositionAbService({
|
|||
var lastContentEventTime = 0L
|
||||
var job: Job? = null
|
||||
val singleThread = Dispatchers.IO.limitedParallelism(1)
|
||||
val eventThread = Dispatchers.Default.limitedParallelism(1)
|
||||
onDestroy {
|
||||
singleThread.cancel()
|
||||
}
|
||||
|
@ -159,9 +160,11 @@ class GkdAbService : CompositionAbService({
|
|||
}
|
||||
lastContentEventTime = event.eventTime
|
||||
}
|
||||
val evAppId = event.packageName?.toString() ?: return@onAccessibilityEvent
|
||||
val evActivityId = event.className?.toString() ?: return@onAccessibilityEvent
|
||||
val rightAppId = safeActiveWindow?.packageName?.toString() ?: return@onAccessibilityEvent
|
||||
|
||||
scope.launch(eventThread) {
|
||||
val evAppId = event.packageName?.toString() ?: return@launch
|
||||
val evActivityId = event.className?.toString() ?: return@launch
|
||||
val rightAppId = safeActiveWindow?.packageName?.toString() ?: return@launch
|
||||
|
||||
if (rightAppId == evAppId) {
|
||||
if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
|
||||
|
@ -185,7 +188,6 @@ class GkdAbService : CompositionAbService({
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rightAppId != topActivityFlow.value?.appId) {
|
||||
// 从 锁屏,下拉通知栏 返回等情况, 应用不会发送事件, 但是系统组件会发送事件
|
||||
val shizukuTop = getShizukuTopActivity()
|
||||
|
@ -196,20 +198,21 @@ class GkdAbService : CompositionAbService({
|
|||
}
|
||||
}
|
||||
|
||||
if (getCurrentRules().rules.isEmpty()) {
|
||||
return@onAccessibilityEvent
|
||||
if (evAppId != rightAppId) {
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (evAppId != rightAppId) {
|
||||
return@onAccessibilityEvent
|
||||
if (getCurrentRules().rules.isEmpty()) {
|
||||
return@launch
|
||||
}
|
||||
if (!storeFlow.value.enableService) return@onAccessibilityEvent
|
||||
|
||||
if (!storeFlow.value.enableService) return@launch
|
||||
val jobVal = job
|
||||
if (jobVal?.isActive == true) {
|
||||
if (openAdOptimized == true) {
|
||||
jobVal.cancel()
|
||||
} else {
|
||||
return@onAccessibilityEvent
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,6 +220,7 @@ class GkdAbService : CompositionAbService({
|
|||
|
||||
newQueryTask()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var lastUpdateSubsTime = 0L
|
||||
|
|
Loading…
Reference in New Issue
Block a user