fix: 通知栏快照丢失 activityId

This commit is contained in:
lisonge 2023-11-23 15:04:41 +08:00
parent bfd7f590ab
commit 473f386d37
2 changed files with 6 additions and 5 deletions

View File

@ -5,8 +5,8 @@ import com.blankj.utilcode.util.ScreenUtils
import kotlinx.serialization.Serializable
import li.songe.gkd.BuildConfig
import li.songe.gkd.service.GkdAbService
import li.songe.gkd.service.getCurrentRules
import li.songe.gkd.service.safeActiveWindow
import li.songe.gkd.service.topActivityFlow
@Serializable
data class ComplexSnapshot(
@ -33,7 +33,7 @@ data class ComplexSnapshot(
fun createComplexSnapshot(): ComplexSnapshot {
val currentAbNode = GkdAbService.service?.safeActiveWindow
val appId = currentAbNode?.packageName?.toString()
val currentActivityId = topActivityFlow.value?.activityId
val currentActivityId = getCurrentRules().topActivity?.activityId
val appInfo = if (appId == null) null else AppUtils.getAppInfo(appId)
return ComplexSnapshot(

View File

@ -3,6 +3,7 @@ package li.songe.gkd.debug
import android.accessibilityservice.AccessibilityService
import android.service.quicksettings.TileService
import com.blankj.utilcode.util.ToastUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import li.songe.gkd.appScope
import li.songe.gkd.debug.SnapshotExt.captureSnapshot
@ -18,9 +19,9 @@ class SnapshotTileService : TileService() {
ToastUtils.showShort("无障碍没有开启")
return
}
val oldAppId = service.safeActiveWindow?.packageName
?: return ToastUtils.showShort("获取界面信息根节点失败")
appScope.launchTry {
appScope.launchTry(Dispatchers.IO) {
val oldAppId = service.safeActiveWindow?.packageName
?: return@launchTry ToastUtils.showShort("获取界面信息根节点失败")
val interval = 500L
val waitTime = 3000L
var i = 0