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)
|
private var parentCache = LruCache<AccessibilityNodeInfo, AccessibilityNodeInfo>(MAX_CACHE_SIZE)
|
||||||
var rootCache: AccessibilityNodeInfo? = null
|
var rootCache: AccessibilityNodeInfo? = null
|
||||||
|
|
||||||
private fun clearNodeCache() {
|
private fun clearNodeCache(t: Long = System.currentTimeMillis()) {
|
||||||
if (META.debuggable) {
|
if (META.debuggable) {
|
||||||
val sizeList = listOf(childCache.size(), parentCache.size(), indexCache.size())
|
val sizeList = listOf(childCache.size(), parentCache.size(), indexCache.size())
|
||||||
if (sizeList.any { it > 0 }) {
|
if (sizeList.any { it > 0 }) {
|
||||||
Log.d("cache", "clear cache -> $sizeList")
|
Log.d("cache", "clear cache -> $sizeList")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rootCache = null
|
lastClearTime = t
|
||||||
|
if (rootCache?.packageName != topActivityFlow.value.appId) {
|
||||||
|
rootCache = null
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
childCache.evictAll()
|
childCache.evictAll()
|
||||||
parentCache.evictAll()
|
parentCache.evictAll()
|
||||||
|
@ -61,14 +64,12 @@ class A11yContext(
|
||||||
private fun clearNodeCacheIfTimeout() {
|
private fun clearNodeCacheIfTimeout() {
|
||||||
if (appChangeTime != lastAppChangeTime) {
|
if (appChangeTime != lastAppChangeTime) {
|
||||||
lastAppChangeTime = appChangeTime
|
lastAppChangeTime = appChangeTime
|
||||||
lastClearTime = System.currentTimeMillis()
|
|
||||||
clearNodeCache()
|
clearNodeCache()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val t = System.currentTimeMillis()
|
val t = System.currentTimeMillis()
|
||||||
if (t - lastClearTime > 30_000L) {
|
if (t - lastClearTime > 30_000L) {
|
||||||
lastClearTime = t
|
clearNodeCache(t)
|
||||||
clearNodeCache()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ class A11yContext(
|
||||||
if (interruptInnerKey == interruptKey) return
|
if (interruptInnerKey == interruptKey) return
|
||||||
interruptInnerKey = interruptKey
|
interruptInnerKey = interruptKey
|
||||||
val rule = currentRule ?: return
|
val rule = currentRule ?: return
|
||||||
if (!activityRuleFlow.value.currentRules.contains(rule)) return
|
if (!activityRuleFlow.value.currentRules.any { it === rule }) return
|
||||||
if (rule.isPriority()) return
|
if (rule.isPriority()) return
|
||||||
if (META.debuggable) {
|
if (META.debuggable) {
|
||||||
Log.d("guardInterrupt", "中断 rule=${rule.statusText()}")
|
Log.d("guardInterrupt", "中断 rule=${rule.statusText()}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user