diff --git a/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt b/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt index d3d5cf2c74..9e0452771d 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt @@ -3,6 +3,7 @@ package com.droiddeck.launcher.core import android.content.Context import android.util.Log import com.droiddeck.launcher.BuildConfig +import com.droiddeck.launcher.lab.LabOverlay import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob @@ -16,6 +17,7 @@ import java.io.FileInputStream internal class AddonPack( val name: String, private val sha256: String, val size: Long, private val required: List, private val reuseDeviceCopy: Boolean = sha256.isEmpty() && !BuildConfig.CI_BUILD, + private val labBuild: Boolean = LabOverlay.active != null, private val bundle: (Context) -> java.io.InputStream = { it.assets.open("packs/$name.tar.zst") }, ) { sealed interface State { @@ -42,7 +44,8 @@ internal class AddonPack( fun installed(context: Context): Boolean = version(context).isNotEmpty() && File(dir(context), COMPLETE).isFile - private fun version(context: Context): String = if (!reuseDeviceCopy) sha256 else deviceCopy(context).orEmpty() + private fun version(context: Context): String = + if (reuseDeviceCopy || labBuild) deviceCopy(context) ?: sha256 else sha256 private fun deviceCopy(context: Context): String? = root(context).listFiles().orEmpty() .filter { dir -> diff --git a/app/src/test/java/com/droiddeck/launcher/core/AddonPackTest.kt b/app/src/test/java/com/droiddeck/launcher/core/AddonPackTest.kt index 80c6ebd328..c367c63ecc 100644 --- a/app/src/test/java/com/droiddeck/launcher/core/AddonPackTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/core/AddonPackTest.kt @@ -58,6 +58,22 @@ class AddonPackTest { assertFalse(AddonPack("sample", "", 0L, listOf("tool"), reuseDeviceCopy = false).installed(context)) } + @Test fun labBuildReusesInstalledPackDespiteDifferentSourcePin() { + installed("b".repeat(64)) + val pack = AddonPack("sample", "a".repeat(64), 1L, listOf("tool"), labBuild = true) + + assertTrue(pack.installed(context)) + assertEquals("b".repeat(64), pack.dir(context).name) + } + + @Test fun labBuildWithoutCompleteInstalledPackKeepsSourcePin() { + installed("b".repeat(64), complete = false) + val pack = AddonPack("sample", "a".repeat(64), 1L, listOf("tool"), labBuild = true) + + assertFalse(pack.installed(context)) + assertEquals("a".repeat(64), pack.dir(context).name) + } + @Test fun localBuildInstallsTheBundledPackWithoutDownloading() { val archive = tarZst("tool" to "x") val pack = AddonPack("sample", Hashes.sha256(archive), archive.length(), listOf("tool"), bundle = { archive.inputStream() }) diff --git a/docs/lab-builds.md b/docs/lab-builds.md index 177133e14d..2e01e3b9d8 100644 --- a/docs/lab-builds.md +++ b/docs/lab-builds.md @@ -5,6 +5,10 @@ or by hand, and loaded over the installed APK at the next start. Nothing is rein re-signed, so a tester on a release build keeps their games, sign-ins and settings while trying a change. +While a Lab build is active, add-on packs reuse the newest complete copy already installed on the +device, even when the checkout pins another version. This keeps helpers such as proot available +after restarting. If no complete copy exists, the pack uses the checkout's pin. + ## How it works - `tools/agent/dd-lab-build` builds the checkout with Gradle on the device (`processReleaseResources`