|
1 | 1 | package li.songe.gkd.util |
2 | 2 |
|
3 | 3 | import android.text.format.DateUtils |
| 4 | +import androidx.annotation.WorkerThread |
4 | 5 | import com.blankj.utilcode.util.LogUtils |
| 6 | +import kotlinx.serialization.Serializable |
5 | 7 | import li.songe.gkd.META |
6 | 8 | 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 |
7 | 12 | import li.songe.gkd.permission.allPermissionStates |
| 13 | +import li.songe.gkd.shizuku.currentUserId |
8 | 14 | import li.songe.gkd.shizuku.shizukuContextFlow |
9 | 15 | import java.io.File |
10 | 16 |
|
@@ -64,12 +70,21 @@ fun clearCache() { |
64 | 70 | removeExpired(tempDir) |
65 | 71 | } |
66 | 72 |
|
| 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 |
67 | 82 | fun buildLogFile(): File { |
68 | 83 | val tempDir = createTempDir() |
69 | 84 | val files = mutableListOf(dbFolder, storeFolder, subsFolder) |
70 | 85 | 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())) |
73 | 88 | files.add(it) |
74 | 89 | } |
75 | 90 | tempDir.resolve("shizuku.txt").also { |
|
0 commit comments