mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
Stores: Epic games get the EOS overlay, and their web links open on Android
Metalstorm's EOS sign-in asked for a one-time consent, could not load an overlay to show it, and fell back to a browser flow that never finished. Epic's own overlay component (the mechanism from Legendary's lfs/eos.py; credits in EpicOverlay.kt) is now downloaded once with the account's token into the runtime, after an Epic library sync or at the first launch that finds it missing. At each launch droiddeck-store-launch writes the one pointer, HKCU Software\Epic Games\EOS OverlayPath, into the game's prefix, appended to user.reg as the DirectAudio key is, and the app logs epic overlay installed=<build> prefix=<appid>. Wine's browser is set to xdg-open, and on a game's PATH a small xdg-open hands http(s) addresses to the app, which opens them in Android's browser, so a device-code sign-in can be finished on the phone.
This commit is contained in:
1 parent
78e4cb8369
commit
97a0f1553f
9 files changed
+294
-3
No files matched your search
@@ -62,6 +62,8 @@ object SessionFiles {
|
||||
"usr/local/bin/droiddeck-steam-shortcuts" to "usr/local/bin/droiddeck-steam-shortcuts",
|
||||
// Asks the app for an Epic game's sign-in code at launch, from the compat tool (StoreLaunchRequests).
|
||||
"usr/local/bin/droiddeck-store-launch" to "usr/local/bin/droiddeck-store-launch",
|
||||
// A game's web links to Android's browser (winebrowser -> xdg-open), on game PATHs only.
|
||||
"usr/local/lib/droiddeck/browser/xdg-open" to "usr/local/lib/droiddeck/browser/xdg-open",
|
||||
"usr/local/bin/droiddeck-steam-games" to "usr/local/bin/droiddeck-steam-games",
|
||||
"usr/local/bin/droiddeck-pad-defaults" to "usr/local/bin/droiddeck-pad-defaults",
|
||||
// Flatpak: the bwrap stand-in, the store's helper and setup, and the front end's launcher.
|
||||
|
||||
@@ -58,7 +58,27 @@ object StoreLaunchRequests {
|
||||
"epic-code" -> {
|
||||
val id = request.optString("id")
|
||||
if (id.isEmpty()) JSONObject().put("ok", false).put("reason", "no-id")
|
||||
else StoreLaunch.epicCode(app, id).let { JSONObject().put("ok", true).put("code", it.written).put("reason", it.reason) }
|
||||
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)
|
||||
Log.i(TAG, "epic overlay installed=${overlay ?: "no"} prefix=${request.optString("prefix").ifEmpty { "?" }}")
|
||||
if (overlay == null) com.droiddeck.launcher.stores.epic.EpicOverlay.ensureAsync(app)
|
||||
JSONObject().put("ok", true).put("code", code.written).put("reason", code.reason).put("overlay", overlay ?: "")
|
||||
}
|
||||
}
|
||||
// A browser a game opens inside the session (an EOS device sign-in, a store page):
|
||||
// http(s) only, handed to Android's browser.
|
||||
"open-url" -> {
|
||||
val url = request.optString("url")
|
||||
if (!(url.startsWith("https://") || url.startsWith("http://"))) JSONObject().put("ok", false).put("reason", "not-http")
|
||||
else try {
|
||||
app.startActivity(android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url)).addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||
Log.i(TAG, "open-url: " + StoreLog.redactUrl(url))
|
||||
JSONObject().put("ok", true)
|
||||
} catch (e: Exception) {
|
||||
JSONObject().put("ok", false).put("reason", e.javaClass.simpleName)
|
||||
}
|
||||
}
|
||||
else -> JSONObject().put("ok", false).put("reason", "unknown-op")
|
||||
}
|
||||
|
||||
@@ -49,7 +49,11 @@ object EpicBackend : StoreBackend, EpicLaunchSupport {
|
||||
StoresState.post {
|
||||
StoresState.status.remove(store)
|
||||
when (result) {
|
||||
is EpicLibrary.SyncResult.Ok -> { StoresState.library[store] = result.games.map { EpicLibrary.toCatalogItem(app, it) }; StoresState.problems.remove(store) }
|
||||
is EpicLibrary.SyncResult.Ok -> {
|
||||
StoresState.library[store] = result.games.map { EpicLibrary.toCatalogItem(app, it) }; StoresState.problems.remove(store)
|
||||
// The EOS overlay, once, so a game's first launch already has it.
|
||||
EpicOverlay.ensureAsync(app)
|
||||
}
|
||||
is EpicLibrary.SyncResult.Failed -> StoresState.problems[store] = result.message
|
||||
EpicLibrary.SyncResult.NotLoggedIn -> StoresState.problems[store] = "Epic session expired: sign in again."
|
||||
EpicLibrary.SyncResult.Throttled -> if (!StoresState.library.containsKey(store)) StoresState.library[store] = cached.map { EpicLibrary.toCatalogItem(app, it) }
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user