Merge pull request #733 from grote/install-fixes

Two small fixes for app restore
This commit is contained in:
Torsten Grote 2024-09-05 09:27:00 -03:00 committed by GitHub
commit 0a7ce66bcf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 3 deletions

View file

@ -144,9 +144,6 @@ internal class AppSelectionAdapter(
fun bind(item: SelectableAppItem) {
v.background = clickableBackground
v.setOnClickListener {
checkBox.toggle()
}
checkBox.setOnCheckedChangeListener(null)
checkBox.isChecked = item.selected
@ -155,6 +152,11 @@ internal class AppSelectionAdapter(
}
checkBox.visibility = if (item.hasIcon == null) INVISIBLE else VISIBLE
progressBar.visibility = if (item.hasIcon == null) VISIBLE else INVISIBLE
if (item.hasIcon == null) {
v.setOnClickListener(null)
} else v.setOnClickListener {
checkBox.toggle()
}
val isSpecial = item.metadata.isInternalSystem
appIcon.scaleType = FIT_CENTER

View file

@ -153,6 +153,13 @@ internal class ApkRestore(
packageName: String,
metadata: PackageMetadata,
) {
// show that app is in progress, before we start downloading stuff
mInstallResult.update {
it.update(packageName) { result ->
result.copy(state = IN_PROGRESS)
}
}
// cache the APK and get its hash
val (cachedApk, sha256) = cacheApk(backup.version, backup.token, backup.salt, packageName)

View file

@ -194,6 +194,13 @@ internal class ApkBackupRestoreTest : TransportTest() {
assertEquals(IN_PROGRESS, it.installResults[packageName]?.state)
assertFalse(it.isFinished)
}
awaitItem().also {
assertFalse(it.hasFailed)
assertEquals(1, it.total)
assertEquals(1, it.list.size)
assertEquals(IN_PROGRESS, it.installResults[packageName]?.state)
assertFalse(it.isFinished)
}
awaitItem().also {
assertFalse(it.hasFailed)
assertEquals(1, it.total)

View file

@ -46,6 +46,7 @@ import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
@ -758,6 +759,14 @@ internal class ApkRestoreTest : TransportTest() {
}
private suspend fun TurbineTestContext<InstallResult>.awaitInProgressItem(): InstallResult {
awaitItem().also { item ->
val result = item[packageName]
assertEquals(IN_PROGRESS, result.state)
assertFalse(item.hasFailed)
assertEquals(1, item.total)
assertEquals(1, item.list.size)
assertNull(result.icon)
}
val item = awaitItem()
// name and icon are available now
val result = item[packageName]