mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-26 00:06:02 +00:00
Stores: the EOS overlay is removed; sign-in goes through the browser
Device-proven on bf81104: Metalstorm's EOS corrective action fell back to
a browser, the hand-off opened it in Android's browser, the user approved,
and the game signed in. With the overlay pointer set the game exited
while loading on every launch, so the overlay goes: no switch on the
Epic card, no download, no OverlayPath. A launch removes a pointer an
earlier build wrote, and the app deletes an earlier 656 MB download once;
an overlay field in an older sidecar is read past. The work is parked on
park/epic-eos-overlay. The browser hand-off, the Epic card's sign-in,
offline and Resolve actions, and BL_DEBUG_BROWSER stay.
This commit is contained in:
1 parent
bf811040ae
commit
935b70c585
11 files changed
+85
-190
No files matched your search
@@ -60,7 +60,7 @@ class StoreGameSidecar(
|
||||
put("title", title)
|
||||
if (exe.isNotEmpty()) put("exe", exe)
|
||||
if (state != STATE_INSTALLED) put("state", state)
|
||||
if (store == Store.EPIC) put("epic", JSONObject().put("v", EpicOptions.VERSION).put("eos", epic.eos).put("offline", epic.offline).put("overlay", epic.overlay))
|
||||
if (store == Store.EPIC) put("epic", JSONObject().put("eos", epic.eos).put("offline", epic.offline))
|
||||
if (!launcher.isNullOrEmpty()) put("launcher", launcher)
|
||||
if (args.isNotEmpty()) put("args", JSONArray(args))
|
||||
if (env.isNotEmpty()) put("env", JSONObject(env as Map<*, *>))
|
||||
@@ -133,12 +133,8 @@ class StoreGameSidecar(
|
||||
hero = o.optString("hero", "").ifEmpty { null },
|
||||
extra = extra,
|
||||
state = state,
|
||||
epic = o.optJSONObject("epic")?.let { e ->
|
||||
// Before v2 the overlay was on by default and written so without anyone choosing
|
||||
// it; the overlay crashed games, so those read as off. From v2 it is a choice.
|
||||
val chosen = e.optInt("v", 1) >= EpicOptions.VERSION
|
||||
EpicOptions(eos = e.optBoolean("eos", true), offline = e.optBoolean("offline", false), overlay = chosen && e.optBoolean("overlay", false))
|
||||
} ?: EpicOptions(),
|
||||
// An "overlay" (or "v") field from an earlier build is read past: there is no overlay.
|
||||
epic = o.optJSONObject("epic")?.let { e -> EpicOptions(eos = e.optBoolean("eos", true), offline = e.optBoolean("offline", false)) } ?: EpicOptions(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -151,15 +147,8 @@ class StoreGameSidecar(
|
||||
/**
|
||||
* An Epic game's launch choices. [eos]: pass a fresh exchange code (Epic sign-in). [offline]: start
|
||||
* with the Epic identity arguments only, no code - for a game that will not start when sign-in fails.
|
||||
* [overlay]: point the game's prefix at Epic's EOS overlay - off by default: with it on, a game can
|
||||
* exit while loading on this stack (Metalstorm did, twice; off, it signs in and runs).
|
||||
*/
|
||||
data class EpicOptions(val eos: Boolean = true, val offline: Boolean = false, val overlay: Boolean = false) {
|
||||
data class EpicOptions(val eos: Boolean = true, val offline: Boolean = false) {
|
||||
/** Whether a launch asks for a code at all. */
|
||||
val wantsCode: Boolean get() = eos && !offline
|
||||
|
||||
companion object {
|
||||
/** v2: the overlay is off unless chosen (Metalstorm exits while loading with it on). */
|
||||
const val VERSION = 2
|
||||
}
|
||||
}
|
||||
@@ -60,13 +60,7 @@ object StoreLaunchRequests {
|
||||
if (id.isEmpty()) JSONObject().put("ok", false).put("reason", "no-id")
|
||||
else {
|
||||
val code = StoreLaunch.epicCode(app, id)
|
||||
// The overlay is placed once and shared; the launch writes the prefix's pointer.
|
||||
val overlay = com.droiddeck.launcher.stores.epic.EpicOverlay.installedVersion(app)
|
||||
val wanted = StoreInstallRoot.gameFolders(app).firstNotNullOfOrNull { f -> StoreGameSidecar.read(f)?.takeIf { it.store == Store.EPIC && it.id == id } }?.epic?.overlay == true
|
||||
Log.i(TAG, "epic overlay installed=${overlay ?: "no"} wanted=$wanted prefix=${request.optString("prefix").ifEmpty { "?" }}")
|
||||
// Fetched only for a game that has the overlay on (656 MB; off by default).
|
||||
if (overlay == null && wanted) com.droiddeck.launcher.stores.epic.EpicOverlay.ensureAsync(app)
|
||||
JSONObject().put("ok", true).put("code", code.written).put("reason", code.reason).put("overlay", overlay ?: "")
|
||||
JSONObject().put("ok", true).put("code", code.written).put("reason", code.reason)
|
||||
}
|
||||
}
|
||||
// A browser a game opens inside the session (an EOS device sign-in, a store page):
|
||||
|
||||
@@ -226,6 +226,9 @@ object StoresState {
|
||||
fun init(context: Context) {
|
||||
appContext = context.applicationContext
|
||||
StoreLogFiles.prune(context)
|
||||
// The EOS overlay an earlier build downloaded (656 MB) is gone with the feature.
|
||||
val overlay = java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.local/share/droiddeck/epic-overlay")
|
||||
if (overlay.exists()) Thread({ overlay.deleteRecursively(); Log.i(TAG, "removed the old EOS overlay download") }, "epic-overlay-cleanup").start()
|
||||
}
|
||||
|
||||
internal fun post(block: () -> Unit) = main.post(block)
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Epic Online Services (EOS) overlay provisioning for DroidDeck.
|
||||
*
|
||||
* Credits: the provisioning MECHANISM - download Epic's own overlay component
|
||||
* ("EpicOnlineServicesOverlay") and point a game's bundled EOS SDK at it through a single HKCU
|
||||
* registry value - comes from Legendary's legendary/lfs/eos.py, by way of The GameNative Team's
|
||||
* work (https://github.com/utkarshdalal/GameNative) and Bannerlator's EpicOverlayManager. The Epic
|
||||
* app identifiers, the registry key and the EOSOVH-Win64-Shipping.dll name are public facts from
|
||||
* Epic / Legendary. Original implementation.
|
||||
*
|
||||
* Reference: https://github.com/derrod/legendary - legendary/lfs/eos.py
|
||||
* Reference: https://github.com/utkarshdalal/GameNative
|
||||
*
|
||||
* Provision only: Epic's signed component is placed once, shared by every prefix, and each Epic
|
||||
* game's prefix gets the one pointer (written by droiddeck-store-launch before Proton starts, where
|
||||
* the prefix is known). The game's EOS SDK loads it itself - which is what lets a "corrective
|
||||
* action" (a consent Epic wants once per product) show in game instead of waiting on a browser.
|
||||
*/
|
||||
package com.droiddeck.launcher.stores.epic
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import java.io.File
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
object EpicOverlay {
|
||||
private const val TAG = "EpicOverlay"
|
||||
|
||||
// Epic's "EpicOnlineServicesOverlay" app (public, from Legendary).
|
||||
private const val OVERLAY_APP = "98bc04bc842e4906993fd6d6644ffb8d"
|
||||
private const val OVERLAY_NAMESPACE = "302e5ede476149b1bc3e4fe6ae45e50e"
|
||||
private const val OVERLAY_CATALOG_ITEM = "cc15684f44d849e89e9bf4cec0508b68"
|
||||
const val OVERLAY_DLL = "EOSOVH-Win64-Shipping.dll"
|
||||
|
||||
/** Inside the session: `/root/.local/share/droiddeck/epic-overlay`, which every prefix reaches as Z:. droiddeck-store-launch names the same path. */
|
||||
const val GUEST_DIR = "/root/.local/share/droiddeck/epic-overlay"
|
||||
private const val VERSION_FILE = "droiddeck-version"
|
||||
|
||||
private val busy = AtomicBoolean(false)
|
||||
|
||||
fun dir(context: Context): File = File(LinuxRuntime.rootDir(context), GUEST_DIR.removePrefix("/"))
|
||||
|
||||
/** The installed overlay's build, or null when it is not there. */
|
||||
fun installedVersion(context: Context): String? {
|
||||
val d = dir(context)
|
||||
if (!File(d, OVERLAY_DLL).let { it.isFile && it.length() > 0 }) return null
|
||||
return runCatching { File(d, VERSION_FILE).readText().trim() }.getOrNull()?.ifEmpty { null } ?: "unknown"
|
||||
}
|
||||
|
||||
/** Starts the download in the background when the overlay is missing; nothing when it is there or under way. */
|
||||
fun ensureAsync(context: Context) {
|
||||
val app = context.applicationContext
|
||||
if (installedVersion(app) != null || !busy.compareAndSet(false, true)) return
|
||||
Thread({
|
||||
try { ensure(app) } finally { busy.set(false) }
|
||||
}, "epic-overlay").start()
|
||||
}
|
||||
|
||||
/** Blocking: downloads Epic's overlay component when it is missing. True when it is in place afterwards. */
|
||||
fun ensure(context: Context): Boolean {
|
||||
val app = context.applicationContext
|
||||
if (installedVersion(app) != null) return true
|
||||
return try {
|
||||
val token = EpicCredentialStore.getValidAccessToken(app) ?: return false.also { Log.i(TAG, "overlay: not signed in") }
|
||||
val manifest = EpicApiClient.getManifestApiJson(token, OVERLAY_NAMESPACE, OVERLAY_CATALOG_ITEM, OVERLAY_APP)
|
||||
?: return false.also { Log.w(TAG, "overlay: manifest not fetched") }
|
||||
val target = dir(app).apply { mkdirs() }
|
||||
StoresState.logLine("epic: fetching the EOS overlay")
|
||||
val result = EpicDownloadManager.install(app, manifest, target.path, "", null, AtomicBoolean(false), object : EpicDownloadManager.Callback {
|
||||
override fun onProgress(message: String, pct: Int) {}
|
||||
override fun onLog(line: String) { StoresState.logLine(line) }
|
||||
})
|
||||
val ok = result != null && File(target, OVERLAY_DLL).isFile
|
||||
if (ok) File(target, VERSION_FILE).writeText(result!!.buildVersion.ifEmpty { "unknown" })
|
||||
Log.i(TAG, "overlay: " + if (ok) "installed ${result!!.buildVersion}" else "install did not produce $OVERLAY_DLL")
|
||||
ok
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "overlay: ${e.javaClass.simpleName}: ${e.message}")
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -508,7 +508,7 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
|
||||
/** Epic's account page behind its sign-in: signing in there presents any step the account still owes. */
|
||||
private const val EPIC_RESOLVE_URL = "https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Faccount%2Fpersonal"
|
||||
|
||||
/** The Epic card: sign-in, offline and overlay switches, read from and written to the game's sidecar. */
|
||||
/** The Epic card: the sign-in and offline switches, read from and written to the game's sidecar, and Resolve Epic sign-in. */
|
||||
@Composable
|
||||
private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) {
|
||||
val appContext = androidx.compose.ui.platform.LocalContext.current.applicationContext
|
||||
@@ -517,7 +517,6 @@ private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) {
|
||||
val value = buildList {
|
||||
if (options.offline) add(stringResource(R.string.epic_card_offline))
|
||||
else if (options.eos) add(stringResource(R.string.epic_card_eos))
|
||||
if (options.overlay) add(stringResource(R.string.epic_card_overlay))
|
||||
}.ifEmpty { listOf(stringResource(R.string.epic_card_none)) }.joinToString(" · ")
|
||||
// Each switch goes straight to the sidecar on disk - both launch paths read it there - and the
|
||||
// card shows what was read back, so a write that did not take is never shown as done.
|
||||
@@ -525,8 +524,7 @@ private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) {
|
||||
Thread({
|
||||
val written = runCatching { com.droiddeck.launcher.stores.StoreGameSidecar.updateEpic(folder, change) }
|
||||
.onFailure { android.util.Log.w("EpicLaunchCard", "could not write ${folder.name}: ${it.message}") }.getOrNull()
|
||||
if (written != null) android.util.Log.i("EpicLaunchCard", "epic options ${written.id} eos=${written.epic.eos} offline=${written.epic.offline} overlay=${written.epic.overlay}")
|
||||
if (written?.epic?.overlay == true) com.droiddeck.launcher.stores.epic.EpicOverlay.ensureAsync(appContext)
|
||||
if (written != null) android.util.Log.i("EpicLaunchCard", "epic options ${written.id} eos=${written.epic.eos} offline=${written.epic.offline}")
|
||||
else android.util.Log.w("EpicLaunchCard", "epic options not saved for ${folder.name}")
|
||||
com.droiddeck.launcher.stores.StoresState.post { sidecar = written ?: com.droiddeck.launcher.stores.StoreGameSidecar.read(folder) }
|
||||
}, "epic-options").start()
|
||||
@@ -537,7 +535,6 @@ private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) {
|
||||
AnchoredMenu(host.open == "epic", onDismiss = { if (host.open == "epic") host.open = null }, title = stringResource(R.string.epic_card_title)) { first ->
|
||||
MenuItem(stringResource(R.string.epic_eos), checked = options.eos, focusRequester = first) { set { it.copy(eos = !it.eos) } }
|
||||
MenuItem(stringResource(R.string.epic_offline), checked = options.offline) { set { it.copy(offline = !it.offline) } }
|
||||
MenuItem(stringResource(R.string.epic_overlay), checked = options.overlay) { set { it.copy(overlay = !it.overlay) } }
|
||||
// Epic asks some accounts to accept something once (privacy policy, EULA) before a game may
|
||||
// sign in - EOS's "corrective action". Signing in on Epic's site shows it.
|
||||
MenuItem(stringResource(R.string.epic_resolve), checked = false) {
|
||||
|
||||
@@ -2015,11 +2015,9 @@
|
||||
<string name="epic_card_title">Epic</string>
|
||||
<string name="epic_card_eos">EOS</string>
|
||||
<string name="epic_card_offline">Offline</string>
|
||||
<string name="epic_card_overlay">Overlay</string>
|
||||
<string name="epic_card_none">Off</string>
|
||||
<string name="epic_eos">Epic sign-in (EOS)</string>
|
||||
<string name="epic_offline">Launch offline</string>
|
||||
<string name="epic_overlay">Epic overlay</string>
|
||||
<string name="epic_resolve">Resolve Epic sign-in</string>
|
||||
<string name="stores_eyebrow_installed">installed</string>
|
||||
<string name="stores_eyebrow_library">in your library</string>
|
||||
|
||||
@@ -47,31 +47,28 @@ class StoreGameSidecarTest {
|
||||
|
||||
@Test fun epicLaunchChoicesRoundTripAndDefaultOn() {
|
||||
val plain = StoreGameSidecar.parse(StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "M.exe").toJson().toString())!!
|
||||
assertEquals(EpicOptions(eos = true, offline = false, overlay = false), plain.epic)
|
||||
assertEquals(EpicOptions(eos = true, offline = false), plain.epic)
|
||||
assertTrue(plain.epic.wantsCode)
|
||||
val set = StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "M.exe", epic = EpicOptions(eos = true, offline = true, overlay = false))
|
||||
val set = StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "M.exe", epic = EpicOptions(eos = true, offline = true))
|
||||
val back = StoreGameSidecar.parse(set.toJson().toString())!!
|
||||
assertEquals(EpicOptions(eos = true, offline = true, overlay = false), back.epic)
|
||||
assertEquals(EpicOptions(eos = true, offline = true), back.epic)
|
||||
assertFalse(back.epic.wantsCode)
|
||||
// A sidecar from before the choices existed reads as the defaults: sign-in on, overlay off.
|
||||
// A sidecar from before the choices existed reads as the defaults.
|
||||
assertEquals(EpicOptions(), StoreGameSidecar.parse("""{"store":"epic","id":"m","title":"M","exe":"M.exe"}""")!!.epic)
|
||||
// The old default wrote overlay=true without a version: nobody chose it, so it reads as off.
|
||||
assertFalse(StoreGameSidecar.parse("""{"store":"epic","id":"m","title":"M","exe":"M.exe","epic":{"eos":true,"offline":false,"overlay":true}}""")!!.epic.overlay)
|
||||
// Chosen from v2 on, it stays.
|
||||
val on = StoreGameSidecar.parse(StoreGameSidecar(Store.EPIC, "m", "M", "M.exe", epic = EpicOptions(overlay = true)).toJson().toString())!!
|
||||
assertTrue(on.epic.overlay)
|
||||
// An earlier build's overlay field is read past.
|
||||
assertEquals(EpicOptions(), StoreGameSidecar.parse("""{"store":"epic","id":"m","title":"M","exe":"M.exe","epic":{"v":2,"eos":true,"offline":false,"overlay":true}}""")!!.epic)
|
||||
}
|
||||
|
||||
@Test fun aSwitchOnTheEpicCardChangesTheSidecarOnDisk() {
|
||||
val folder = java.io.File(org.robolectric.RuntimeEnvironment.getApplication().filesDir, "Games/Stores/Epic/Metalstorm").apply { mkdirs() }
|
||||
StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "Metalstorm.exe", launcher = ".droiddeck-launch.bat").write(folder)
|
||||
val written = StoreGameSidecar.updateEpic(folder) { it.copy(overlay = true) }!!
|
||||
assertTrue(written.epic.overlay)
|
||||
val written = StoreGameSidecar.updateEpic(folder) { it.copy(offline = true) }!!
|
||||
assertTrue(written.epic.offline)
|
||||
// What the Steam-launch helper reads: the file itself.
|
||||
val onDisk = org.json.JSONObject(java.io.File(folder, StoreGameSidecar.FILE_NAME).readText())
|
||||
assertTrue(onDisk.getJSONObject("epic").getBoolean("overlay"))
|
||||
assertEquals(EpicOptions.VERSION, onDisk.getJSONObject("epic").getInt("v"))
|
||||
assertTrue(onDisk.getJSONObject("epic").getBoolean("offline"))
|
||||
assertTrue(onDisk.getJSONObject("epic").getBoolean("eos"))
|
||||
assertFalse(onDisk.getJSONObject("epic").has("overlay"))
|
||||
// Everything else in it stays.
|
||||
assertEquals(".droiddeck-launch.bat", StoreGameSidecar.read(folder)!!.launcher)
|
||||
assertEquals(null, StoreGameSidecar.updateEpic(java.io.File(folder, "missing")) { it })
|
||||
|
||||
Reference in new issue
Block a user