Skip to content

Commit

Permalink
fix: 通知栏快照丢失 activityId
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 23, 2023
1 parent bfd7f59 commit 473f386
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/li/songe/gkd/data/ComplexSnapshot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/li/songe/gkd/debug/SnapshotTileService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 473f386

Please sign in to comment.