mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 03:32:38 +08:00
This commit is contained in:
parent
5a2455a20e
commit
24c57a81f3
|
@ -35,14 +35,17 @@ class A11yContext(
|
|||
private var parentCache = LruCache<AccessibilityNodeInfo, AccessibilityNodeInfo>(MAX_CACHE_SIZE)
|
||||
var rootCache: AccessibilityNodeInfo? = null
|
||||
|
||||
private fun clearNodeCache() {
|
||||
private fun clearNodeCache(t: Long = System.currentTimeMillis()) {
|
||||
if (META.debuggable) {
|
||||
val sizeList = listOf(childCache.size(), parentCache.size(), indexCache.size())
|
||||
if (sizeList.any { it > 0 }) {
|
||||
Log.d("cache", "clear cache -> $sizeList")
|
||||
}
|
||||
}
|
||||
rootCache = null
|
||||
lastClearTime = t
|
||||
if (rootCache?.packageName != topActivityFlow.value.appId) {
|
||||
rootCache = null
|
||||
}
|
||||
try {
|
||||
childCache.evictAll()
|
||||
parentCache.evictAll()
|
||||
|
@ -61,14 +64,12 @@ class A11yContext(
|
|||
private fun clearNodeCacheIfTimeout() {
|
||||
if (appChangeTime != lastAppChangeTime) {
|
||||
lastAppChangeTime = appChangeTime
|
||||
lastClearTime = System.currentTimeMillis()
|
||||
clearNodeCache()
|
||||
return
|
||||
}
|
||||
val t = System.currentTimeMillis()
|
||||
if (t - lastClearTime > 30_000L) {
|
||||
lastClearTime = t
|
||||
clearNodeCache()
|
||||
clearNodeCache(t)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +84,7 @@ class A11yContext(
|
|||
if (interruptInnerKey == interruptKey) return
|
||||
interruptInnerKey = interruptKey
|
||||
val rule = currentRule ?: return
|
||||
if (!activityRuleFlow.value.currentRules.contains(rule)) return
|
||||
if (!activityRuleFlow.value.currentRules.any { it === rule }) return
|
||||
if (rule.isPriority()) return
|
||||
if (META.debuggable) {
|
||||
Log.d("guardInterrupt", "中断 rule=${rule.statusText()}")
|
||||
|
|
Loading…
Reference in New Issue
Block a user