feat(recomps): Linux recomps become non-Steam games, and Android installs explain failures

Each Linux recomp gets a play script and becomes a native non-Steam
shortcut: written to the session's shortcut listing next to the Epic
launcher, added to a running Steam client at once, and removed with the
recomp. They also show in a Recomps chip in the Library and always start
as the Linux app. Windows recomps were already added games.

An APK without code for the device's CPUs (a 64-bit-only device and a
32-bit-only port) is stopped before Android's prompt, remembered as not
for this device, and skipped when choosing a build. Install failures say
what went wrong, name the game and stay on its page.

Also finds AppImage recomps again: the scan looked one folder too high.
This commit is contained in:
Kurt Himebauch committed 2026-12-01 14:35:07 -05:00
1 parent ed6b123984
commit a56d4e38be
17 files changed
+370 -31

No files matched your search

@@ -1038,6 +1038,28 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
onHandled()
return
}
// A Linux recomp starts as the Linux app it is, whether or not Steam would launch it.
if (game.source == com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE) {
launchCoordinator.releaseHandling(request)
onHandled()
val key = game.storeId
Thread({
val app = com.droiddeck.launcher.store.UserAppsState.items.firstOrNull { it.key == key }
?: runCatching { com.droiddeck.launcher.runtime.UserApps.list(this).firstOrNull { it.key == key } }.getOrNull()
ui.post {
if (app == null) android.widget.Toast.makeText(this, R.string.recomps_launch_missing, android.widget.Toast.LENGTH_SHORT).show()
else {
Library.recordPlayed(this, game)
startActivity(Intent(this, SessionActivity::class.java)
.putExtra(SessionService.EXTRA_MODE, SessionService.MODE_RUN)
.putExtra(SessionService.EXTRA_PROGRAM, app.program)
.putExtra(SessionService.EXTRA_PROGRAM_ARGS, app.args.toTypedArray()))
onSettled()
}
}
}, "recomp-launch").start()
return
}
val files = game.gameFiles
if (game.source != com.droiddeck.launcher.stores.Store.XBOX.id || files == null) {
if (startGame(game, returnHome, onHandled, request)) onSettled()
@@ -586,7 +586,8 @@ object AddedGames {
}.getOrNull()
fun writeListing(context: Context, games: List<Game>,
extra: List<JSONObject> = listOfNotNull(com.droiddeck.launcher.stores.epic.EpicClient.steamListing(context))): File {
extra: List<JSONObject> = listOfNotNull(com.droiddeck.launcher.stores.epic.EpicClient.steamListing(context)) +
com.droiddeck.launcher.runtime.RecompShortcuts.listing(context)): File {
val file = listingFile(context).apply { parentFile?.mkdirs() }
val json = StringBuilder("[")
games.forEachIndexed { i, g ->
@@ -248,11 +248,14 @@ object Library {
AddedGames.guestPath(context, g.folder).let { it == null || it !in claimed })
}
val played = shortcutsLastPlayed(SessionPrefs.steamRoot(context, arch))
return (steam + own.map { g -> addedGame(context, g, roots, played[g.appId] ?: 0L) }).distinctBy { it.gameId }
val recomps = com.droiddeck.launcher.runtime.RecompShortcuts.library(context) { appId, gameId ->
maxOf(played[appId] ?: 0L, recordedPlay(context, gameId))
}
return (steam + own.map { g -> addedGame(context, g, roots, played[g.appId] ?: 0L) } + recomps).distinctBy { it.gameId }
}
fun recordPlayed(context: Context, game: SteamGame) {
if (game.library == ADDED) recordPlayed(context, game.gameIdString)
if (game.library == ADDED || game.library == com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE) recordPlayed(context, game.gameIdString)
}
fun recordPlayed(context: Context, gameId: String) {
@@ -18,8 +18,33 @@ object RecompAndroid {
const val ACTION_STATUS = "com.droiddeck.launcher.recomps.INSTALL_STATUS"
private const val RECORDS = "recomps-android"
private const val INCOMPATIBLE = "incompatible"
@Volatile private var registered = false
@Volatile var onChanged: () -> Unit = {}
// Why the last install of each package failed, in words for the player.
@Volatile var onFailed: (pkg: String, message: String) -> Unit = { _, _ -> }
private val sessions = java.util.concurrent.ConcurrentHashMap<Int, Pair<String, String>>()
private fun incompatibleFile(context: Context) = File(File(context.filesDir, RECORDS).apply { mkdirs() }, INCOMPATIBLE)
// Packages whose APK has no code for this device's CPUs, found when one was downloaded or refused.
fun incompatible(context: Context): Set<String> =
FileUtils.readString(incompatibleFile(context))?.lines()?.map { it.trim() }?.filter { it.isNotEmpty() }?.toSet().orEmpty()
private fun markIncompatible(context: Context, pkg: String) {
val now = incompatible(context) + pkg
FileUtils.writeString(incompatibleFile(context), now.joinToString("\n"))
}
// The CPUs an APK has native code for, from its lib/<abi>/ folders; empty when it has none (Java only).
internal fun apkAbis(apk: File): Set<String> = runCatching {
java.util.zip.ZipFile(apk).use { zip ->
zip.entries().asSequence().map { it.name }.filter { it.startsWith("lib/") }.mapNotNull { it.split('/').getOrNull(1)?.takeIf { a -> a.isNotEmpty() } }.toSet()
}
}.getOrDefault(emptySet())
internal fun fits(abis: Set<String>, device: List<String>): Boolean = abis.isEmpty() || abis.any { it in device }
private fun record(context: Context, pkg: String) = File(File(context.filesDir, RECORDS), pkg)
@@ -38,6 +63,12 @@ object RecompAndroid {
// names, so a replaced release asset cannot install as, or over, a different app.
fun install(context: Context, entry: RecompCatalog.Entry, build: RecompCatalog.Build, release: RecompInstaller.Release, apk: File): String? {
val pkg = build.pkg ?: return context.getString(R.string.recomps_apk_mismatch)
val abis = apkAbis(apk)
val device = Build.SUPPORTED_ABIS.toList()
if (!fits(abis, device)) {
markIncompatible(context, pkg)
return context.getString(R.string.recomps_apk_wrong_cpu, abis.sorted().joinToString(", "), device.joinToString(", "))
}
if (!SelfInstaller.canInstall(context)) {
context.startActivity(SelfInstaller.permissionIntent(context).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
return context.getString(R.string.recomps_allow_installs)
@@ -48,7 +79,7 @@ object RecompAndroid {
if (build.signer != null && build.signer !in SelfInstaller.archiveSignerDigests(info)) return context.getString(R.string.recomps_apk_mismatch)
listen(context)
FileUtils.writeString(record(context, pkg).apply { parentFile?.mkdirs() }, "${release.tag}\n${release.published}\n")
SelfInstaller.install(context, apk, pkg, ACTION_STATUS)
SelfInstaller.install(context, apk, pkg, ACTION_STATUS) { id -> sessions[id] = pkg to entry.name }
return null
}
@@ -70,7 +101,11 @@ object RecompAndroid {
val app = context.applicationContext
val receiver = object : BroadcastReceiver() {
override fun onReceive(c: Context, intent: Intent) {
when (val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE)) {
val session = intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1)
val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE)
val (pkg, name) = (if (status == PackageInstaller.STATUS_PENDING_USER_ACTION) sessions[session] else sessions.remove(session))
?: (intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME).orEmpty() to "")
when (status) {
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
val confirm = if (Build.VERSION.SDK_INT >= 33) intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)
else @Suppress("DEPRECATION") intent.getParcelableExtra(Intent.EXTRA_INTENT)
@@ -78,8 +113,12 @@ object RecompAndroid {
}
PackageInstaller.STATUS_SUCCESS -> onChanged()
else -> {
val message = SelfInstaller.describeFailure(app, status, intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE))
Toast.makeText(app, message, Toast.LENGTH_LONG).show()
val raw = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)
if (raw?.contains("NO_MATCHING_ABIS") == true && pkg.isNotEmpty()) markIncompatible(app, pkg)
val message = failure(app, status, raw)
Toast.makeText(app, if (name.isNotEmpty()) app.getString(R.string.recomps_apk_failed_named, name, message) else message,
Toast.LENGTH_LONG).show()
if (pkg.isNotEmpty()) onFailed(pkg, message)
onChanged()
}
}
@@ -89,4 +128,18 @@ object RecompAndroid {
if (Build.VERSION.SDK_INT >= 33) app.registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED)
else app.registerReceiver(receiver, filter)
}
// What went wrong, in words: Android's own status message names the cause but not what to do about it.
internal fun failure(context: Context, status: Int, message: String?): String = when {
message?.contains("NO_MATCHING_ABIS") == true || status == PackageInstaller.STATUS_FAILURE_INCOMPATIBLE ->
context.getString(R.string.recomps_apk_fail_cpu, Build.SUPPORTED_ABIS.joinToString(", "))
message?.contains("UPDATE_INCOMPATIBLE") == true || status == PackageInstaller.STATUS_FAILURE_CONFLICT ->
context.getString(R.string.recomps_apk_fail_conflict)
message?.contains("VERSION_DOWNGRADE") == true -> context.getString(R.string.recomps_apk_fail_downgrade)
status == PackageInstaller.STATUS_FAILURE_STORAGE -> context.getString(R.string.recomps_apk_fail_storage)
status == PackageInstaller.STATUS_FAILURE_ABORTED -> context.getString(R.string.recomps_apk_fail_cancelled)
status == PackageInstaller.STATUS_FAILURE_BLOCKED -> context.getString(R.string.recomps_apk_fail_blocked)
status == PackageInstaller.STATUS_FAILURE_INVALID -> context.getString(R.string.recomps_apk_fail_invalid)
else -> context.getString(R.string.recomps_apk_fail_other, message ?: status.toString())
}
}
@@ -78,6 +78,10 @@ object RecompCatalog {
fun preferred(): Build? = PREFERENCE.firstNotNullOfOrNull { build(it) }
// The preferred build, passing over an Android one whose package cannot install on this device.
fun preferred(incompatible: Set<String>): Build? =
PREFERENCE.firstNotNullOfOrNull { p -> build(p)?.takeIf { it.pkg == null || it.pkg !in incompatible } }
val android get() = build(Platform.ANDROID)
val pc get() = origin in PC_ORIGINS
@@ -35,7 +35,7 @@ object RecompInstaller {
out[id] = Installed(id, "$prefix:${dir.name}", read(dir, META_TAG), read(dir, META_PUBLISHED), read(dir, META_PLATFORM), dir, read(dir, META_REPO))
}
scan(UserApps.root(context), "script")
AppImageManager.dir(context, "").parentFile?.let { scan(it, "appimage") }
AppImageManager.dir(context, "x").parentFile?.let { scan(it, "appimage") }
windowsRoots(context).forEach { scan(it, "added") }
return out
}
@@ -186,6 +186,9 @@ object RecompInstaller {
if (previous.platform != platform.key) uninstall(context, previous)
else if (previous.dir != windowsTarget(context, entry)) FileUtils.delete(previous.dir)
}
if (problem == null && platform != RecompCatalog.Platform.WINDOWS_X64) {
installed(context)[entry.id]?.let { runCatching { RecompShortcuts.prepare(entry, it) } }
}
return problem
} catch (e: Exception) {
return e.message ?: context.getString(R.string.user_apps_failed)
@@ -0,0 +1,101 @@
package com.droiddeck.launcher.runtime
import android.content.Context
import android.system.Os
import android.util.Log
import com.droiddeck.launcher.core.Downloader
import com.droiddeck.launcher.core.FileUtils
import com.droiddeck.launcher.frontend.Library
import com.droiddeck.launcher.stores.SteamLiveShortcuts
import org.json.JSONObject
import java.io.File
import java.util.zip.CRC32
// Each Linux recomp (a script app or an AppImage) is also a non-Steam game: a native shortcut, without a
// compatibility tool, to a small `play` script beside the install. Windows recomps are added games, so Steam
// already has them; Android apps cannot be Steam shortcuts.
object RecompShortcuts {
private const val TAG = "RecompShortcuts"
const val SOURCE = "recomp"
private const val PLAY = "play"
private const val COVER = "cover"
private const val ICON = "icon.png"
class Shortcut(
val id: String, val name: String, val appKey: String, val exe: String, val dir: String, val appId: Long,
val cover: File?, val icon: File?, val host: File,
) {
val gameId: Long get() = (appId shl 32) or 0x02000000L
}
// Steam's own ID for a non-Steam shortcut: a CRC32 of the quoted program and the name, with the top bit set.
fun appId(exe: String, name: String): Long = CRC32().apply { update("\"$exe\"$name".toByteArray()) }.value or 0x80000000L
private fun guestDir(inst: RecompInstaller.Installed): String? = when {
inst.appKey.startsWith("script:") -> "${UserApps.GUEST_DIR}/${inst.dir.name}"
inst.appKey.startsWith("appimage:") -> "${AppImageManager.GUEST_DIR}/${inst.dir.name}"
else -> null
}
internal fun playScript(inst: RecompInstaller.Installed, guest: String): String {
val launcher = if (inst.appKey.startsWith("appimage:")) AppImageManager.LAUNCHER else UserApps.SCRIPT_LAUNCHER
return "#!/bin/sh\nexec $launcher '$guest' \"\$@\"\n"
}
private fun writePlay(inst: RecompInstaller.Installed, guest: String): File? = runCatching {
File(inst.dir, PLAY).also { f ->
val text = playScript(inst, guest)
if (FileUtils.readString(f) != text) FileUtils.writeString(f, text)
runCatching { Os.chmod(f.path, 0b111_101_101) }
f.setExecutable(true, false)
}
}.onFailure { Log.w(TAG, "play ${inst.dir}: $it") }.getOrNull()
// Writes the play script and saves the catalog's art beside the install, for Steam's library and the Library tab.
fun prepare(entry: RecompCatalog.Entry, inst: RecompInstaller.Installed) {
val guest = guestDir(inst) ?: return
writePlay(inst, guest)
fun save(url: String?, name: String) {
if (url.isNullOrEmpty() || File(inst.dir, name).isFile) return
val tmp = File(inst.dir, "$name.part")
if (runCatching { Downloader.downloadFile(url, tmp, false) { } }.getOrDefault(false)) tmp.renameTo(File(inst.dir, name)) else tmp.delete()
}
save(entry.cover, COVER + "." + (entry.cover?.substringAfterLast('.')?.substringBefore('?')?.lowercase()?.takeIf { it in setOf("png", "jpg", "jpeg", "webp") } ?: "jpg"))
if (!File(inst.dir, ICON).isFile) save(entry.art, ICON)
}
fun all(context: Context): List<Shortcut> = RecompInstaller.installed(context).values.mapNotNull { inst ->
val guest = guestDir(inst) ?: return@mapNotNull null
val play = File(inst.dir, PLAY).takeIf { it.isFile } ?: writePlay(inst, guest) ?: return@mapNotNull null
val name = FileUtils.readString(File(inst.dir, "name"))?.trim()?.takeIf { it.isNotEmpty() } ?: inst.id
val exe = "$guest/${play.name}"
Shortcut(inst.id, name, inst.appKey, exe, guest, appId(exe, name),
inst.dir.listFiles()?.firstOrNull { it.name.startsWith("$COVER.") && it.isFile }, File(inst.dir, ICON).takeIf { it.isFile }, inst.dir)
}
// Entries for the session's shortcut listing (droiddeck-steam-shortcuts): native, so no compatibility tool.
fun listing(context: Context): List<JSONObject> = runCatching { all(context) }.getOrDefault(emptyList()).map { s ->
JSONObject().put("name", s.name).put("exe", s.exe).put("folder", s.dir).put("dir", s.dir).put("appid", s.appId)
.put("seen", 0).put("native", true).also { o ->
val art = JSONObject()
s.cover?.let { art.put("p", it.absolutePath) }
s.icon?.let { art.put("icon", it.absolutePath) }
if (art.length() > 0) o.put("art", art)
}
}
fun library(context: Context, lastPlayed: (appId: Long, gameId: Long) -> Long = { _, _ -> 0L }): List<Library.SteamGame> =
runCatching { all(context) }.getOrDefault(emptyList()).map { s ->
Library.SteamGame(
s.appId.toInt(), s.name, s.cover ?: s.icon, SOURCE, s.gameId, lastPlayed = lastPlayed(s.appId, s.gameId), icon = s.icon,
source = SOURCE, storeId = s.appKey, installedAt = s.host.lastModified(),
)
}
// Adds the shortcut to a running Steam client now; the listing covers the next session either way.
fun addLive(context: Context, id: String) {
all(context).firstOrNull { it.id == id }?.let { s -> SteamLiveShortcuts.ensure(context, s.name, s.exe, s.dir, compat = false, appId = s.appId) }
}
fun removeLive(context: Context, appId: Long) = runCatching { SteamLiveShortcuts.remove(context, appId) }
}
@@ -25,6 +25,11 @@ object RecompsState {
private set
var loading by mutableStateOf(false)
private set
var incompatible by mutableStateOf<Set<String>>(emptySet())
private set
// The last install failure of each recomp, kept on its page until the next attempt.
var errors by mutableStateOf<Map<String, String>>(emptyMap())
private set
private var seq = 0
private var checked = false
private var lastSteam: List<Pair<Int, String>> = emptyList()
@@ -44,6 +49,9 @@ object RecompsState {
val app = context.applicationContext
lastSteam = steamOwned.toList()
RecompAndroid.onChanged = { main.post { refresh(app, lastSteam) } }
RecompAndroid.onFailed = { pkg, message ->
main.post { entries.filter { it.android?.pkg == pkg }.forEach { errors = errors + (it.id to message) } }
}
val n = ++seq
loading = entries.isEmpty()
Thread({
@@ -60,9 +68,10 @@ object RecompsState {
val inputs = runCatching { RecompData.inputs(app, steamOwned, list) }.getOrNull()
val states = list.associate { e -> e.id to (inputs?.let { RecompData.resolve(e, it) } ?: RecompData.State.BringYourOwn(e.data)) }
inputs?.done?.invoke()
val apks = runCatching { RecompAndroid.incompatible(app) }.getOrDefault(emptySet())
main.post {
if (n != seq) return@post
entries = list; installed = have; data = states; loading = false
entries = list; installed = have; data = states; incompatible = apks; loading = false
}
if (!checked && have.isNotEmpty()) {
checked = true
@@ -83,15 +92,36 @@ object RecompsState {
context: Context, entry: RecompCatalog.Entry, steamOwned: Collection<Pair<Int, String>>, release: RecompInstaller.Release? = null,
chosen: RecompCatalog.Build? = null,
) {
val build = chosen ?: installed[entry.id]?.platform?.let { RecompCatalog.Platform.of(it) }?.let { buildFor(entry, it) } ?: entry.preferred() ?: return
val build = chosen ?: installed[entry.id]?.platform?.let { RecompCatalog.Platform.of(it) }?.let { buildFor(entry, it) }
?: entry.preferred(incompatible) ?: return
errors = errors - entry.id
val done = if (build.platform == RecompCatalog.Platform.ANDROID) R.string.recomps_android_started else R.string.recomps_installed
if (chosen != null) choose(context, entry.id, chosen.platform)
UserAppsState.run(context, entry.name, done, after = {
updates = updates - entry.id
UserAppsState.lastError?.takeIf { it.startsWith(entry.name + ":") }?.let { errors = errors + (entry.id to it.removePrefix(entry.name + ":").trim()) }
refresh(context, steamOwned)
com.droiddeck.launcher.frontend.AddedGamesPublisher.later(context) { com.droiddeck.launcher.runtime.RecompShortcuts.addLive(context.applicationContext, entry.id) }
}) { app, progress -> RecompInstaller.install(app, entry, build, release, progress, allowTwin = chosen == null) }
}
// Removes an installed recomp and, once it is gone, its non-Steam shortcut.
fun remove(context: Context, entry: RecompCatalog.Entry, steamOwned: Collection<Pair<Int, String>>, inst: RecompInstaller.Installed) {
val app = context.applicationContext
if (inst.appKey.startsWith("android:")) {
RecompAndroid.uninstall(app, inst.appKey.removePrefix("android:"))
return
}
val shortcut = runCatching { com.droiddeck.launcher.runtime.RecompShortcuts.all(app).firstOrNull { it.appKey == inst.appKey }?.appId }.getOrNull()
UserAppsState.run(app, entry.name, R.string.recomps_removed, after = {
refresh(app, steamOwned)
com.droiddeck.launcher.frontend.AddedGamesPublisher.later(app) { shortcut?.let { com.droiddeck.launcher.runtime.RecompShortcuts.removeLive(app, it) } }
}) { c, p ->
if (inst.appKey.startsWith("added:")) { RecompInstaller.remove(c, inst); null }
else com.droiddeck.launcher.runtime.UserApps.list(c).firstOrNull { it.key == inst.appKey }?.let { com.droiddeck.launcher.runtime.UserApps.remove(c, it, p) }
}
}
private fun choicesFile(context: Context) = java.io.File(java.io.File(context.filesDir, "recomps").apply { mkdirs() }, "choices.json")
private fun choices(context: Context): Map<String, String> = runCatching {
@@ -935,6 +935,7 @@ private fun LibraryFilters(sources: List<String>, source: String, onSource: (Str
val label = when (id) {
LIBRARY_ALL -> stringResource(R.string.stores_tab_all)
Library.ADDED -> stringResource(R.string.library_custom_games)
com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE -> stringResource(R.string.rail_recomps)
LIBRARY_FAVORITES -> stringResource(R.string.soundtracks_favorites)
LIBRARY_HIDDEN -> stringResource(R.string.apps_filter_hidden)
else -> store?.shortLabel ?: sourceLabel(id)
@@ -967,6 +968,7 @@ private fun LibraryFilters(sources: List<String>, source: String, onSource: (Str
private fun sourceTitle(src: String): String = when (src) {
LIBRARY_ALL -> stringResource(R.string.library_all_games)
Library.ADDED -> stringResource(R.string.library_custom_games)
com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE -> stringResource(R.string.rail_recomps)
LIBRARY_FAVORITES -> stringResource(R.string.soundtracks_favorites)
LIBRARY_HIDDEN -> stringResource(R.string.apps_filter_hidden)
else -> Store.byId(src)?.label ?: sourceLabel(src)
@@ -119,12 +119,12 @@ internal object StoreTabsState {
}
/** The Library tabs that are not stores but sort among them in Manage stores. Only Favorites, Custom games and Hidden can be turned off; Hidden starts off. */
internal val LIBRARY_OWN_TABS = listOf(LIBRARY_FAVORITES, Library.SOURCE_STEAM, Library.ADDED, LIBRARY_HIDDEN)
internal val LIBRARY_HIDEABLE_TABS = setOf(LIBRARY_FAVORITES, Library.ADDED, LIBRARY_HIDDEN)
internal val LIBRARY_OWN_TABS = listOf(LIBRARY_FAVORITES, Library.SOURCE_STEAM, Library.ADDED, com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE, LIBRARY_HIDDEN)
internal val LIBRARY_HIDEABLE_TABS = setOf(LIBRARY_FAVORITES, Library.ADDED, com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE, LIBRARY_HIDDEN)
/** Favorites, then Steam, ahead of the stores; Custom games and Hidden after them (null: the end). */
internal val DEFAULT_LIBRARY_PLACES: List<Pair<String, String?>> =
listOf(LIBRARY_FAVORITES to "", Library.SOURCE_STEAM to LIBRARY_FAVORITES, Library.ADDED to null, LIBRARY_HIDDEN to null)
listOf(LIBRARY_FAVORITES to "", Library.SOURCE_STEAM to LIBRARY_FAVORITES, Library.ADDED to null, com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE to Library.ADDED, LIBRARY_HIDDEN to null)
/**
* Puts the Library's own tabs into a store tab order. Each goes after the tab it follows ("" for first; null or a tab that is gone
@@ -339,6 +339,7 @@ private fun LibraryTabSortRow(id: String, held: Boolean, offset: Float, hint: St
val label = when (id) {
LIBRARY_FAVORITES -> stringResource(R.string.soundtracks_favorites)
Library.ADDED -> stringResource(R.string.library_custom_games)
com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE -> stringResource(R.string.rail_recomps)
LIBRARY_HIDDEN -> stringResource(R.string.apps_filter_hidden)
else -> stringResource(R.string.source_steam)
}
@@ -97,13 +97,16 @@ internal object RecompsView {
internal class RecompRow(
val entry: RecompCatalog.Entry, val data: RecompData.State, val installed: RecompInstaller.Installed?,
val update: RecompInstaller.Release?,
val update: RecompInstaller.Release?, val incompatible: Set<String> = emptySet(),
) {
val platform get() = installed?.platform?.let { RecompCatalog.Platform.of(it) } ?: entry.preferred()?.platform
val platform get() = installed?.platform?.let { RecompCatalog.Platform.of(it) } ?: entry.preferred(incompatible)?.platform
fun runs(build: RecompCatalog.Build) = build.pkg == null || build.pkg !in incompatible
}
internal fun recompRows(): List<RecompRow> = RecompsState.entries.map { e ->
RecompRow(e, RecompsState.data[e.id] ?: RecompData.State.BringYourOwn(e.data), RecompsState.installed[e.id], RecompsState.updates[e.id])
RecompRow(e, RecompsState.data[e.id] ?: RecompData.State.BringYourOwn(e.data), RecompsState.installed[e.id], RecompsState.updates[e.id],
RecompsState.incompatible)
}
private val NATIVE = setOf(RecompCatalog.Platform.LINUX_ARM64, RecompCatalog.Platform.ANDROID)
@@ -166,7 +169,7 @@ internal fun RecompsPage(s: FrontEndState, a: FrontEndActions, onSelect: (String
lifecycle.addObserver(observer)
onDispose { lifecycle.removeObserver(observer) }
}
val rows = remember(RecompsState.entries, RecompsState.data, RecompsState.installed, RecompsState.updates) { recompRows() }
val rows = remember(RecompsState.entries, RecompsState.data, RecompsState.installed, RecompsState.updates, RecompsState.incompatible) { recompRows() }
val opened = RecompsView.open?.let { id -> rows.firstOrNull { it.entry.id == id } }
if (opened != null) {
BackHandler { RecompsView.open = null }
@@ -459,6 +462,7 @@ private fun RecompDetail(
else Row(horizontalArrangement = Arrangement.spacedBy(22.dp), modifier = Modifier.padding(top = 8.dp)) {
cover(); Box(Modifier.weight(1f)) { heading() }
}
RecompsState.errors[e.id]?.let { Box(Modifier.padding(top = 12.dp).testTag("recomp-error")) { Note(it) } }
if (UserAppsState.working == e.name && UserAppsState.stage != null) {
Text(UserAppsState.stage.orEmpty(), fontSize = 12.sp, color = pal.signal, modifier = Modifier.padding(top = 10.dp))
}
@@ -478,6 +482,7 @@ private fun RecompDetail(
e.builds.sortedBy { RecompCatalog.PREFERENCE.indexOf(it.platform).let { i -> if (i < 0) 99 else i } }.forEach { b ->
val status = when {
installedAs == b.platform -> stringResource(R.string.recomps_build_installed)
!row.runs(b) -> stringResource(R.string.recomps_not_for_device)
installedAs == RecompCatalog.Platform.LINUX_ARM64 && b.platform == RecompCatalog.Platform.LINUX_X64 &&
e.build(RecompCatalog.Platform.LINUX_ARM64) == null -> stringResource(R.string.recomps_build_installed_arm)
else -> b.tag
@@ -550,17 +555,7 @@ private fun RecompActions(
}
SecondaryButton(stringResource(R.string.recomps_project)) { open(e.homepage) }
if (inst != null) SecondaryButton(stringResource(R.string.recomps_remove), enabled = busy == null) {
when {
inst.appKey.startsWith("android:") -> RecompAndroid.uninstall(ctx, inst.appKey.removePrefix("android:"))
inst.appKey.startsWith("added:") -> UserAppsState.run(ctx, e.name, R.string.recomps_removed, after = { RecompsState.refresh(ctx, steamOwned) }) { app, _ ->
RecompInstaller.remove(app, inst); null
}
else -> UserAppsState.items.firstOrNull { it.key == inst.appKey }?.let { app ->
UserAppsState.run(ctx, e.name, R.string.recomps_removed, after = { RecompsState.refresh(ctx, steamOwned) }) { c, p ->
com.droiddeck.launcher.runtime.UserApps.remove(c, app, p)
}
}
}
RecompsState.remove(ctx, e, steamOwned, inst)
}
}
}
@@ -49,6 +49,7 @@ internal fun sourceColours(source: String): SourceColours = when (source) {
internal fun sourceLabel(source: String): String = when (source) {
Library.SOURCE_STEAM, Store.STEAM.id -> stringResource(R.string.source_steam)
Library.SOURCE_COLLECTION -> stringResource(R.string.soundtracks_collections)
com.droiddeck.launcher.runtime.RecompShortcuts.SOURCE -> stringResource(R.string.rail_recomps)
Store.GOG.id -> Store.GOG.label
Store.EPIC.id -> Store.EPIC.label
Store.AMAZON.id -> Store.AMAZON.label
+12
View File
@@ -4469,6 +4469,18 @@
<string name="recomps_unpack_failed">Unpacking failed (exit %1$d)</string>
<string name="recomps_entry_missing">The download has no %1$s</string>
<string name="recomps_android_started">%1$s downloaded. Confirm the install.</string>
<string name="recomps_apk_wrong_cpu">This Android build only has code for %1$s, and this device needs %2$s. Pick another build.</string>
<string name="recomps_apk_failed_named">%1$s didn\'t install: %2$s</string>
<string name="recomps_apk_fail_cpu">it has no code for this device\'s processor (%1$s). Pick another build.</string>
<string name="recomps_apk_fail_conflict">another copy of this app, signed by someone else, is installed. Remove it first.</string>
<string name="recomps_apk_fail_downgrade">a newer version is already installed.</string>
<string name="recomps_apk_fail_storage">there isn\'t enough free space.</string>
<string name="recomps_apk_fail_cancelled">the install was cancelled.</string>
<string name="recomps_apk_fail_blocked">Android blocked the install.</string>
<string name="recomps_apk_fail_invalid">the APK is damaged or isn\'t a valid app.</string>
<string name="recomps_apk_fail_other">Android said %1$s.</string>
<string name="recomps_launch_missing">This recomp\'s files are gone. Install it again from Recomps.</string>
<string name="recomps_not_for_device">Not for this device</string>
<string name="recomps_apk_mismatch">The APK isn\'t the app the catalog lists, so it wasn\'t installed</string>
<string name="recomps_allow_installs">Allow DroidDeck to install apps, then press Install again</string>
<string name="recomps_build_android">Android app</string>
@@ -0,0 +1,78 @@
package com.droiddeck.launcher.runtime
import android.content.Context
import android.content.pm.PackageInstaller
import androidx.test.core.app.ApplicationProvider
import com.droiddeck.launcher.frontend.Library
import java.io.File
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class RecompShortcutsTest {
private val ctx = ApplicationProvider.getApplicationContext<Context>()
private fun install(dir: String, id: String, name: String, root: String = UserApps.GUEST_DIR): File =
File(LinuxRuntime.rootDir(ctx), root.removePrefix("/") + "/" + dir).apply {
mkdirs()
File(this, RecompInstaller.META_ID).writeText(id)
File(this, "name").writeText(name)
File(this, RecompInstaller.META_PLATFORM).writeText("linux-arm64")
}
@Test fun theShortcutIdIsSteamsCrcOfTheQuotedProgramAndName() {
val crc = java.util.zip.CRC32().apply { update("\"/opt/droiddeck-apps/zelda/play\"Zelda 64".toByteArray()) }.value or 0x80000000L
assertEquals(crc, RecompShortcuts.appId("/opt/droiddeck-apps/zelda/play", "Zelda 64"))
}
@Test fun eachLinuxRecompIsANativeShortcutToItsPlayScript() {
val zelda = install("zelda-64", "zelda64recomp", "Zelda 64: Recompiled")
install("quake", "ironwail", "Ironwail", AppImageManager.GUEST_DIR).also { File(it, "app").mkdirs(); File(it, "app/AppRun").writeText("x") }
File(zelda, "icon.png").writeText("png")
val listing = RecompShortcuts.listing(ctx).associateBy { it.getString("name") }
val z = listing.getValue("Zelda 64: Recompiled")
assertEquals("/opt/droiddeck-apps/zelda-64/play", z.getString("exe"))
assertTrue(z.getBoolean("native"))
assertEquals(RecompShortcuts.appId(z.getString("exe"), z.getString("name")), z.getLong("appid"))
assertEquals(File(zelda, "icon.png").absolutePath, z.getJSONObject("art").getString("icon"))
assertEquals("#!/bin/sh\nexec ${UserApps.SCRIPT_LAUNCHER} '/opt/droiddeck-apps/zelda-64' \"\$@\"\n", File(zelda, "play").readText())
assertTrue(File(zelda, "play").canExecute())
val quake = listing.getValue("Ironwail")
assertEquals("${AppImageManager.GUEST_DIR}/quake/play", quake.getString("exe"))
val play = File(LinuxRuntime.rootDir(ctx), AppImageManager.GUEST_DIR.removePrefix("/") + "/quake/play").readText()
assertTrue(play.contains(AppImageManager.LAUNCHER))
}
@Test fun recompsJoinTheLibraryUnderTheirOwnSource() {
install("banjo", "banjorecomp", "Banjo: Recompiled")
val g = RecompShortcuts.library(ctx) { _, _ -> 42L }.single { it.name == "Banjo: Recompiled" }
assertEquals(RecompShortcuts.SOURCE, g.source)
assertEquals("script:banjo", g.storeId)
assertEquals(42L, g.lastPlayed)
val appId = RecompShortcuts.appId("/opt/droiddeck-apps/banjo/play", "Banjo: Recompiled")
assertEquals((appId shl 32) or 0x02000000L, g.gameId)
}
@Test fun anApkWithoutCodeForTheDevicesCpuIsCaughtBeforeAndroidRefusesIt() {
val apk = File(ctx.cacheDir, "t.apk")
ZipOutputStream(apk.outputStream()).use { z ->
listOf("AndroidManifest.xml", "lib/armeabi-v7a/libmain.so", "lib/x86/libmain.so").forEach { z.putNextEntry(ZipEntry(it)); z.write(1); z.closeEntry() }
}
assertEquals(setOf("armeabi-v7a", "x86"), RecompAndroid.apkAbis(apk))
assertTrue(!RecompAndroid.fits(setOf("armeabi-v7a", "x86"), listOf("arm64-v8a")))
assertTrue(RecompAndroid.fits(setOf("armeabi-v7a", "arm64-v8a"), listOf("arm64-v8a")))
assertTrue(RecompAndroid.fits(emptySet(), listOf("arm64-v8a")))
}
@Test fun installFailuresSayWhatHappened() {
assertTrue(RecompAndroid.failure(ctx, PackageInstaller.STATUS_FAILURE, "INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries").contains("processor"))
assertTrue(RecompAndroid.failure(ctx, PackageInstaller.STATUS_FAILURE_CONFLICT, null).contains("signed by someone else"))
assertTrue(RecompAndroid.failure(ctx, PackageInstaller.STATUS_FAILURE_STORAGE, null).contains("space"))
assertTrue(RecompAndroid.failure(ctx, 99, "odd").contains("odd"))
}
}
@@ -107,9 +107,9 @@ class LibraryEntriesTest {
}
@Test fun placesRoundTripThroughTheirOrder() {
val order = listOf("epic", "steam", "favorites", LIBRARY_HIDDEN, "gog", "xbox", "added")
val order = listOf("epic", "steam", "favorites", LIBRARY_HIDDEN, "gog", "xbox", "added", "recomp")
assertEquals(order, placeLibraryTabs(listOf("epic", "gog", "xbox"), libraryPlacesOf(order)))
assertEquals(listOf("favorites", "steam", "epic", "gog", "added", LIBRARY_HIDDEN), placeLibraryTabs(listOf("epic", "gog"), emptyList()))
assertEquals(listOf("favorites", "steam", "epic", "gog", "added", "recomp", LIBRARY_HIDDEN), placeLibraryTabs(listOf("epic", "gog"), emptyList()))
}
@Test fun librarySourcesIgnoreUnknownAndDuplicateOrderEntriesAndAppendNewStores() {
@@ -37,7 +37,7 @@ class LibraryHiddenTest {
}
@Test fun theHiddenTabSortsLastUnlessMoved() {
assertEquals(listOf(LIBRARY_FAVORITES, Library.SOURCE_STEAM, "epic", Library.ADDED, LIBRARY_HIDDEN), placeLibraryTabs(listOf("epic"), DEFAULT_LIBRARY_PLACES))
assertEquals(listOf(LIBRARY_FAVORITES, Library.SOURCE_STEAM, "epic", Library.ADDED, "recomp", LIBRARY_HIDDEN), placeLibraryTabs(listOf("epic"), DEFAULT_LIBRARY_PLACES))
val moved = placeLibraryTabs(listOf("epic"), listOf(LIBRARY_HIDDEN to "epic"))
assertEquals(listOf("epic", LIBRARY_HIDDEN), moved.filter { it == "epic" || it == LIBRARY_HIDDEN })
}
+33
View File
@@ -108,6 +108,39 @@ The build is chosen in the order linux-arm64 (native), android, linux-x64 (FEX),
with its id, or else its repo, since a higher-ranked catalog can rename an entry. An update installs the
new release first and then deletes the old folder.
## In Steam and the Library
- **Linux recomps** (script apps and AppImages) are non-Steam games (`RecompShortcuts`):
- Each install gets a `play` script beside it that runs `droiddeck-script-run` or the AppImage
launcher, and the catalog's cover and icon are saved there.
- The shortcut is native (no compatibility tool) and its ID is Steam's CRC of the quoted program and
name.
- It is written to the session's shortcut listing next to the Epic launcher, so the next Steam start
has it. It is also added to a running client at once, and removed when the recomp is.
- **Windows recomps** are added games, so they are already non-Steam games.
- **Android apps** cannot be Steam shortcuts and stay in Apps.
- **Library:** Linux recomps also show in a **Recomps** chip, after Custom; it can be hidden like Custom.
Starting one from the Library always runs it as the Linux app, even when DroidDeck launches without
Steam.
## Android installs
- **CPU check:** before Android's prompt, the APK's `lib/<abi>/` folders are checked against
`Build.SUPPORTED_ABIS`. Many newer handhelds (the Pocket FIT included) run 64-bit code only, so a
port that only ships `armeabi-v7a` can never install there. Such an APK is stopped with a sentence
naming both sets of CPUs.
- **Remembered:** the package is recorded in `files/recomps-android/incompatible` (as is one Android
refuses with `NO_MATCHING_ABIS`). Install then picks another build, "Runs natively" stops counting
it, and its build row says "Not for this device".
- **Failures in words, naming the game:**
- wrong CPU;
- another copy signed by someone else;
- a newer version installed;
- not enough space;
- cancelled, blocked, or a damaged APK.
The last failure stays on the recomp's page until the next attempt.
## Game data
PC ports need the original PC game's files, which a store sells. For these entries (Decomp Buddy's "PC