Skip to content

Commit a482aec

Browse files
committed
feat: track pending installation status for updated apps
- Move domain models `ApkValidationResult`, `FingerprintCheckResult`, `SaveInstalledAppParams`, and `UpdateInstalledAppParams` to the `domain.model` package. - Update `UpdateInstalledAppParams` and the database save/update logic to include an `isPendingInstall` flag based on the `InstallOutcome`. - Update `InstallationManagerImpl` to persist the pending status in the repository when updating an app version. - Modify `DetailsViewModel` to pass the installation outcome when saving or updating app records after an install attempt.
1 parent 6c443c9 commit a482aec

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

feature/details/data/src/commonMain/kotlin/zed/rainxch/details/data/system/InstallationManagerImpl.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import zed.rainxch.core.domain.model.InstalledApp
88
import zed.rainxch.core.domain.repository.FavouritesRepository
99
import zed.rainxch.core.domain.repository.InstalledAppsRepository
1010
import zed.rainxch.core.domain.system.Installer
11-
import zed.rainxch.details.domain.system.ApkValidationResult
12-
import zed.rainxch.details.domain.system.FingerprintCheckResult
11+
import zed.rainxch.details.domain.model.ApkValidationResult
12+
import zed.rainxch.details.domain.model.FingerprintCheckResult
13+
import zed.rainxch.details.domain.model.SaveInstalledAppParams
14+
import zed.rainxch.details.domain.model.UpdateInstalledAppParams
1315
import zed.rainxch.details.domain.system.InstallationManager
14-
import zed.rainxch.details.domain.system.SaveInstalledAppParams
15-
import zed.rainxch.details.domain.system.UpdateInstalledAppParams
1616
import kotlin.time.Clock.System
1717
import kotlin.time.ExperimentalTime
1818

@@ -120,14 +120,16 @@ class InstallationManagerImpl(
120120
}
121121

122122
override suspend fun updateInstalledAppVersion(params: UpdateInstalledAppParams) {
123+
val packageName = params.apkInfo.packageName
123124
installedAppsRepository.updateAppVersion(
124-
packageName = params.apkInfo.packageName,
125+
packageName = packageName,
125126
newTag = params.releaseTag,
126127
newAssetName = params.assetName,
127128
newAssetUrl = params.assetUrl,
128129
newVersionName = params.apkInfo.versionName,
129130
newVersionCode = params.apkInfo.versionCode,
130131
signingFingerprint = params.apkInfo.signingFingerprint,
131132
)
133+
installedAppsRepository.updatePendingStatus(packageName, params.isPendingInstall)
132134
}
133135
}

feature/details/domain/src/commonMain/kotlin/zed/rainxch/details/domain/model/UpdateInstalledAppParams.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ data class UpdateInstalledAppParams(
77
val assetName: String,
88
val assetUrl: String,
99
val releaseTag: String,
10+
val isPendingInstall: Boolean,
1011
)

feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ import zed.rainxch.core.domain.utils.ShareManager
4242
import zed.rainxch.details.domain.model.ReleaseCategory
4343
import zed.rainxch.details.domain.repository.DetailsRepository
4444
import zed.rainxch.details.domain.repository.TranslationRepository
45-
import zed.rainxch.details.domain.system.ApkValidationResult
45+
import zed.rainxch.details.domain.model.ApkValidationResult
46+
import zed.rainxch.details.domain.model.FingerprintCheckResult
47+
import zed.rainxch.details.domain.model.SaveInstalledAppParams
48+
import zed.rainxch.details.domain.model.UpdateInstalledAppParams
4649
import zed.rainxch.details.domain.system.AttestationVerifier
47-
import zed.rainxch.details.domain.system.FingerprintCheckResult
4850
import zed.rainxch.details.domain.system.InstallationManager
49-
import zed.rainxch.details.domain.system.SaveInstalledAppParams
50-
import zed.rainxch.details.domain.system.UpdateInstalledAppParams
5151
import zed.rainxch.details.domain.util.VersionHelper
5252
import zed.rainxch.details.presentation.model.AttestationStatus
5353
import zed.rainxch.details.presentation.model.DowngradeWarning
@@ -863,7 +863,7 @@ class DetailsViewModel(
863863
viewModelScope.launch {
864864
try {
865865
val ext = warning.pendingAssetName.substringAfterLast('.', "").lowercase()
866-
installer.install(warning.pendingFilePath, ext)
866+
val installOutcome = installer.install(warning.pendingFilePath, ext)
867867

868868
if (platform == Platform.ANDROID) {
869869
saveInstalledAppToDatabase(
@@ -873,6 +873,7 @@ class DetailsViewModel(
873873
releaseTag = warning.pendingReleaseTag,
874874
isUpdate = warning.pendingIsUpdate,
875875
filePath = warning.pendingFilePath,
876+
installOutcome = installOutcome,
876877
)
877878
}
878879

@@ -1232,6 +1233,7 @@ class DetailsViewModel(
12321233
assetName = assetName,
12331234
assetUrl = assetUrl,
12341235
releaseTag = releaseTag,
1236+
isPendingInstall = installOutcome != InstallOutcome.COMPLETED,
12351237
),
12361238
)
12371239
} else {

0 commit comments

Comments
 (0)