Skip to content

Commit 5d8789e

Browse files
committed
feat: export AppJsonData to log
1 parent 360581d commit 5d8789e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

app/src/main/kotlin/li/songe/gkd/data/UserInfo.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package li.songe.gkd.data
22

33
import kotlinx.coroutines.flow.MutableStateFlow
4+
import kotlinx.serialization.Serializable
45

6+
@Serializable
57
data class UserInfo(
68
val id: Int,
79
val name: String,

app/src/main/kotlin/li/songe/gkd/util/FolderExt.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package li.songe.gkd.util
22

33
import android.text.format.DateUtils
4+
import androidx.annotation.WorkerThread
45
import com.blankj.utilcode.util.LogUtils
6+
import kotlinx.serialization.Serializable
57
import li.songe.gkd.META
68
import li.songe.gkd.app
9+
import li.songe.gkd.data.AppInfo
10+
import li.songe.gkd.data.UserInfo
11+
import li.songe.gkd.data.otherUserMapFlow
712
import li.songe.gkd.permission.allPermissionStates
13+
import li.songe.gkd.shizuku.currentUserId
814
import li.songe.gkd.shizuku.shizukuContextFlow
915
import java.io.File
1016

@@ -64,12 +70,21 @@ fun clearCache() {
6470
removeExpired(tempDir)
6571
}
6672

73+
@Serializable
74+
private data class AppJsonData(
75+
val userId: Int = currentUserId,
76+
val apps: List<AppInfo> = userAppInfoMapFlow.value.values.toList(),
77+
val otherUsers: List<UserInfo> = otherUserMapFlow.value.values.toList(),
78+
val othersApps: List<AppInfo> = otherUserAppInfoMapFlow.value.values.toList(),
79+
)
80+
81+
@WorkerThread
6782
fun buildLogFile(): File {
6883
val tempDir = createTempDir()
6984
val files = mutableListOf(dbFolder, storeFolder, subsFolder)
7085
LogUtils.getLogFiles().firstOrNull()?.parentFile?.let { files.add(it) }
71-
tempDir.resolve("appList.json").also {
72-
it.writeText(json.encodeToString(appInfoMapFlow.value.values.toList()))
86+
tempDir.resolve("apps.json").also {
87+
it.writeText(json.encodeToString(AppJsonData()))
7388
files.add(it)
7489
}
7590
tempDir.resolve("shizuku.txt").also {

0 commit comments

Comments
 (0)