feat(ea): start Steam's copies of EA games without the EA app (#3021)

This commit is contained in:
FryMcNugget authored and GitHub committed 2026-11-27 08:32:55 -05:00
1 parent 2dc74f7574
commit b08d8e8e19
5 files changed
+313 -19

No files matched your search

@@ -73,35 +73,72 @@ object EaLaunch {
/** Answers the guest's request right before an EA game starts: session, licence and the LSX endpoint. */
fun prepare(context: Context, request: JSONObject): JSONObject {
val app = context.applicationContext
request.optJSONObject("steam")?.let { return prepareSteam(app, request, it) }
val id = request.optString("id")
val reply = JSONObject().put("ok", false)
val (folder, recorded) = installed(app, id) ?: return reply.put("reason", "not-installed")
val (folder, recorded) = installed(app, id) ?: return JSONObject().put("ok", false).put("reason", "not-installed")
val sidecar = backfill(folder, recorded)
runCatching { com.droiddeck.launcher.stores.StoreLaunch.refreshLauncher(folder, sidecar) }
File(folder, ENV_FILE).delete()
val account = EaAuth.load(app) ?: return reply.put("reason", "signed-out")
val access = EaAuth.accessToken(app) ?: return reply.put("reason", "sign-in-expired")
val contentId = sidecar.extra["contentId"].orEmpty()
val locale = sidecar.extra["locale"].orEmpty().ifEmpty { "en_US" }
val core = EaOoa.coreDir(folder, sidecar.exe)
val known = (sidecar.extra["contentIds"].orEmpty().split(',') + sidecar.extra["multiplayerId"].orEmpty()).map { it.trim() }.filter { it.isNotEmpty() }.toSet()
val game = Started(folder, id, sidecar.extra["contentId"].orEmpty(), known, sidecar.extra["contentIds"].orEmpty().split(','),
sidecar.title, sidecar.installVersion, sidecar.extra["locale"].orEmpty().ifEmpty { "en_US" }, sidecar.exe)
val (reply, env) = start(app, game, request)
if (env != null) {
val tmp = File(folder, "$ENV_FILE.tmp")
tmp.writeText(env.entries.joinToString("\r\n", postfix = "\r\n") { "${it.key}=${it.value}" })
tmp.renameTo(File(folder, ENV_FILE))
}
return reply
}
private val OFFER = Regex("Origin\\.OFR\\.[0-9]+\\.[0-9]+")
private val CONTENT = Regex("[A-Za-z0-9._-]{1,64}")
/** Steam's copy of an EA game, which Steam would hand to the EA app; the env comes back in the reply. */
private fun prepareSteam(app: Context, request: JSONObject, steam: JSONObject): JSONObject {
val failed = JSONObject().put("ok", false)
val root = com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(app).canonicalFile
val folder = File(root, steam.optString("folder").removePrefix("/")).canonicalFile
if (!folder.path.startsWith(root.path + File.separator) || !folder.isDirectory) return failed.put("reason", "no-folder")
fun strings(name: String, pattern: Regex) = steam.optJSONArray(name)?.let { a -> (0 until a.length()).map { a.optString(it) } }
.orEmpty().filter { pattern.matches(it) }.distinct()
val offers = strings("offers", OFFER)
val contents = strings("contentIds", CONTENT)
if (offers.isEmpty() || contents.isEmpty()) return failed.put("reason", "no-offer")
val game = Started(folder, offers.first(), contents.first(), contents.toSet(), contents, steam.optString("title").ifEmpty { folder.name },
steam.optString("version"), steam.optString("locale").ifEmpty { "en_US" }, steam.optString("exe"))
val (reply, env) = start(app, game, request)
if (env != null) reply.put("id", game.offerId).put("env", JSONObject(env.toMap()))
return reply
}
private class Started(
val folder: File, val offerId: String, val contentId: String, val contentIds: Set<String>, val licenceIds: List<String>,
val title: String, val version: String, val locale: String, val exe: String,
)
private fun start(app: Context, game: Started, request: JSONObject): Pair<JSONObject, LinkedHashMap<String, String>?> {
val reply = JSONObject().put("ok", false)
val id = game.offerId
val account = EaAuth.load(app) ?: return reply.put("reason", "signed-out") to null
val access = EaAuth.accessToken(app) ?: return reply.put("reason", "sign-in-expired") to null
val contentId = game.contentId
val locale = game.locale
val core = EaOoa.coreDir(game.folder, game.exe)
val hashVersion = core?.let(EaOoa::activationVersion) ?: 1
val hardware = request.optJSONObject("hardware")?.let(EaOoa.Hardware::fromJson)?.takeIf { it.complete(hashVersion) }
val legacy = EaOoa.legacyCore(core)
val lifetime = if (legacy) 14400 else 550
val opaque = EaAuth.mint(app, EaAuth.CLIENT_ID, "token", EaAuth.OPAQUE_SCOPES, "OPAQUE", lifetime).orEmpty()
val known = (sidecar.extra["contentIds"].orEmpty().split(',') + sidecar.extra["multiplayerId"].orEmpty()).map { it.trim() }.filter { it.isNotEmpty() }.toSet()
val lsx = EaLsx.start(app, EaLsx.Game(id, contentId, sidecar.title, sidecar.installVersion, locale, hardware, hashVersion, opaque,
System.currentTimeMillis() + (lifetime - 30) * 1000L, known))
val lsx = EaLsx.start(app, EaLsx.Game(id, contentId, game.title, game.version, locale, hardware, hashVersion, opaque,
System.currentTimeMillis() + (lifetime - 30) * 1000L, game.contentIds))
val env = environment(id, contentId, locale, if (legacy && opaque.isNotEmpty()) opaque else access, access, opaque, EaAuth.load(app) ?: account)
val tmp = File(folder, "$ENV_FILE.tmp")
tmp.writeText(env.entries.joinToString("\r\n", postfix = "\r\n") { "${it.key}=${it.value}" })
tmp.renameTo(File(folder, ENV_FILE))
val licenses = JSONArray()
val notes = ArrayList<String>()
if (core != null) {
val ids = (listOf(contentId) + sidecar.extra["contentIds"].orEmpty().split(',')).map { it.trim() }.filter { it.isNotEmpty() }.distinct()
val ids = (listOf(contentId) + game.licenceIds).map { it.trim() }.filter { it.isNotEmpty() }.distinct()
if (hardware == null) notes += "no-hardware" else {
val hash = EaOoa.machineHash(hardware, hashVersion)
for (content in ids) {
@@ -125,7 +162,7 @@ object EaLaunch {
}
val licenseNote = if (core == null) "none-needed" else "v$hashVersion " + notes.joinToString(",")
Log.i(TAG, "prepared $id lsx=$lsx legacy=$legacy opaque=${opaque.isNotEmpty()} licence=$licenseNote")
return reply.put("ok", true).put("lsx", lsx).put("license", licenseNote).put("licenses", licenses)
return reply.put("ok", true).put("lsx", lsx).put("license", licenseNote).put("licenses", licenses) to env
}
}
+1 -1
View File
@@ -13,6 +13,7 @@ EA games install, update and start without the EA app. The research behind it is
| Downloads | Rust `src/ea/` in `libdroiddeckstores.so`, `EaInstaller.kt` | A build is one ZIP on EA's CDN. The engine reads its central directory with ranged reads, keeps files whose size and CRC match, and streams every other entry through inflate into place. `.droiddeck-ea-files` records what it placed, so a resume or update does not re-hash those files; files a new build drops are removed. |
| Updates | `EaUpdates` in `EaBackend.kt` | The game page compares the installed version with the offer's live `gameVersion` (every 30 minutes at most). Update runs the same install, which only fetches changed files. |
| Launch, guest | `droiddeck-store-launch` (`prepare_ea`) | Creates the prefix, reads the machine as Wine reports it (`wmic`, `vol`, `hostname`; cached in `pfx/.droiddeck-ea-hw.json`), writes EA app presence keys and the game's `Install Dir` keys in both registry views, runs the build's Touchup once per installed build, then asks the app for the session and writes any licence files. |
| Launch, Steam copy | `prepare_steam_ea` in `droiddeck-store-launch`, the Proton wrapper | Steam starts its EA titles with `steam2ea://`, which only the EA app handles, and the EA app does not install here. When the prefix has no EA app, the hook reads the game's `__Installer/installerdata.xml` and its offers (`__Installer/LOC/Origin.OFR.*.dat`), runs `prepare_ea` with a `steam` request (the app answers with the launch environment instead of a sidecar file), and writes `droiddeck-ea-steam.bat` in the game's compatdata. The wrapper runs that launcher in place of the link. Writing the EA app presence keys also satisfies the install script, so Steam stops running the EA app installer. |
| Launch, app | `EaLaunch.kt`, `EaOoa.kt`, `EaLsx.kt` | Answers `ea-prepare`: starts the LSX endpoint on `127.0.0.1:3216`, mints the short-lived opaque token, writes `.droiddeck-ea-env` (read once and deleted by the launcher `.bat`), and for games with a `Core` folder requests an online-activation licence for the machine hash. |
| LSX | `EaLsx.kt` | The local endpoint EA's SDK talks to instead of the EA app: challenge, AES session key, config, profile, settings, game info, auth codes for the game's own client ids, licences with Denuvo tokens, entitlements. Friends, presence and the overlay answer empty. |
@@ -26,6 +27,5 @@ WMI does not expose, so those use `00000000` unless the probe learns it.
## Not done yet
- Cloud saves (`cloudsync.juno.ea.com`).
- Steam copies of EA games still install the EA app (#2036).
- Pre-DiP games (no `installerdata.xml`) fall back to the exe picker.
- Javelin anti-cheat games do not run under Proton.
@@ -324,6 +324,16 @@ def cloud_on(sidecar):
def exited(argv, code=0):
found = find_store_game(argv)
launch_dir = os.environ.get("DD_LAUNCH_DIR", "")
compat_data = os.environ.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
if found is None and launch_dir and compat_data and steam_ea_link(argv):
try:
game = str(json.loads((Path(compat_data) / STEAM_EA_STATE).read_text()).get("id") or "")
except (OSError, ValueError, AttributeError):
game = ""
if game:
ask(Path(launch_dir) / "stores", {"op": "ea-exited", "store": "ea", "id": game}, timeout=1.0)
log("steam ea %s exited" % game)
return 0
if found is not None and launch_dir and str(found[1].get("store")) == "rockstar":
ask(Path(launch_dir) / "stores", {"op": "rockstar-exited", "store": "rockstar", "id": str(found[1].get("id"))}, timeout=1.0)
compat_data = os.environ.get("STEAM_COMPAT_DATA_PATH")
@@ -1552,7 +1562,7 @@ def write_licenses(compat_data, licenses):
return written
def prepare_ea(folder, sidecar, compat_data, launch_dir):
def prepare_ea(folder, sidecar, compat_data, launch_dir, steam=None):
game = str(sidecar.get("id"))
proton = os.environ.get("DD_STORE_PROTON", "")
made = create_prefix(compat_data, proton)
@@ -1561,16 +1571,149 @@ def prepare_ea(folder, sidecar, compat_data, launch_dir):
hardware, probe = ea_hardware(compat_data, proton) if ready else ({}, "no-prefix")
answer = None
if launch_dir:
answer = ask(Path(launch_dir) / "stores", {"op": "ea-prepare", "store": "ea", "id": game, "hardware": hardware}, timeout=40.0)
request = {"op": "ea-prepare", "store": "ea", "id": game, "hardware": hardware}
if steam is not None:
request["steam"] = steam
answer = ask(Path(launch_dir) / "stores", request, timeout=40.0)
sidecar = sidecar_at(Path(folder)) or sidecar
log("ea %s prefix=%s stub=%s hardware=%s registry=%s touchup=%s" % (
game, made, stub, probe, ea_registry(folder, sidecar, compat_data, proton), ea_touchup(folder, sidecar, compat_data, proton)))
if answer is None:
log("ea %s session=no reason=%s" % (game, "timeout" if launch_dir else "no-channel"))
return
return None
written = write_licenses(compat_data, answer.get("licenses"))
log("ea %s session=%s reason=%s lsx=%s licence=%s files=%d" % (
game, "yes" if answer.get("ok") else "no", answer.get("reason", ""), answer.get("lsx"), answer.get("license", ""), written))
return answer
STEAM_EA_LINK = re.compile(r"(?i)^steam2ea://launchgame/([0-9]+)")
STEAM_EA_LAUNCHER = "droiddeck-ea-steam.bat"
STEAM_EA_ENV = ".droiddeck-ea-steam-env"
STEAM_EA_STATE = ".droiddeck-ea-steam.json"
STEAM_EA_CLIENT = "drive_c/Program Files/Electronic Arts/EA Desktop/EA Desktop/EADesktop.exe"
STEAM_EA_OFFER = re.compile(r"^(Origin\.OFR\.[0-9]+\.[0-9]+)\.dat$", re.IGNORECASE)
REPLACED = 13
def steam_ea_link(argv):
for raw in argv:
if STEAM_EA_LINK.match(raw.strip().strip('"')):
return raw
return None
def ea_manifest(folder):
path = find_case(folder, "__Installer/installerdata.xml")
if path is None or not path.is_file():
return None
import xml.etree.ElementTree as ET
try:
text = decode_output(path.read_bytes()).lstrip("\ufeff")
root = ET.fromstring(re.sub(r"^\s*<\?xml[^>]*\?>", "", text))
except (OSError, ET.ParseError):
return None
contents = [e.text.strip() for e in root.iter("contentID") if e.text and e.text.strip()]
launchers = []
for runtime in root.iter("runtime"):
for launcher in runtime.iter("launcher"):
path_text = (launcher.findtext("filePath") or "").strip()
if path_text:
launchers.append((path_text, (launcher.findtext("parameters") or "").strip(), (launcher.findtext("trial") or "0").strip() == "1"))
launcher = next((l for l in launchers if not l[2]), launchers[0] if launchers else None)
version = root.find("buildMetaData/gameVersion")
titles = {e.get("locale"): (e.text or "").strip() for e in root.iter("gameTitle") if e.get("locale")}
exe = None
if launcher is not None:
relative = re.sub(r"^\[[^\]]*\]", "", launcher[0]).replace("{installLocation}", "").lstrip("\\/")
exe = find_case(folder, relative)
return {
"contentIds": contents,
"exe": exe if exe is not None and exe.is_file() else None,
"parameters": launcher[1] if launcher else "",
"version": version.get("version", "") if version is not None else "",
"title": titles.get("en_US") or next(iter(titles.values()), "") or Path(folder).name,
}
def steam_ea_offers(folder):
loc = find_case(folder, "__Installer/LOC")
try:
names = sorted(p.name for p in loc.iterdir()) if loc is not None and loc.is_dir() else []
except OSError:
names = []
return [m.group(1) for m in map(STEAM_EA_OFFER.match, names) if m]
def batch_text(value):
return value.replace("%", "%%").replace('"', "")
def batch_arguments(value):
return re.sub(r"[\x00-\x1f]+", " ", value).replace("%", "%%")
def steam_ea_launcher(folder, exe, parameters, compat_data):
env = windows_path(str(Path(compat_data) / STEAM_EA_ENV))
lines = [
"@echo off",
"setlocal",
"rem Written by DroidDeck: starts Steam's copy of an EA game without the EA app.",
'cd /d "%s"' % batch_text(windows_path(str(exe.parent))),
'if not exist "%s" goto run' % batch_text(env),
'for /f "usebackq tokens=1,* delims==" %%%%a in ("%s") do set "%%%%a=%%%%b"' % batch_text(env),
'del "%s"' % batch_text(env),
":run",
'if exist "%s" start "" "%s"' % (EA_STUB, EA_STUB),
'"%s"%s %%*' % (batch_text(windows_path(str(exe))), " " + batch_arguments(parameters) if parameters else ""),
'set "DD_RC=%errorlevel%"',
"taskkill /f /im Origin.exe >nul 2>&1",
"exit /b %DD_RC%",
]
return "\r\n".join(lines) + "\r\n"
def prepare_steam_ea(argv, compat_data, launch_dir):
"""Steam's copies of EA games start through the EA app, which does not install here: start the game itself."""
folder = Path(os.environ.get("STEAM_COMPAT_INSTALL_PATH") or os.getcwd())
if not compat_data:
log("steam ea: no prefix, left to the EA app")
return 0
if (Path(compat_data) / "pfx" / STEAM_EA_CLIENT).is_file():
log("steam ea: the EA app is installed in this prefix, left to it")
return 0
manifest = ea_manifest(folder)
offers = steam_ea_offers(folder)
if manifest is None or manifest["exe"] is None or not manifest["contentIds"] or not offers:
log("steam ea: %s has no EA manifest, launcher or offer, left to the EA app" % folder)
return 0
if not launch_dir:
log("steam ea: no channel to DroidDeck, left to the EA app")
return 0
exe = manifest["exe"]
sidecar = {"store": "ea", "id": offers[0], "title": manifest["title"],
"extra": {"contentIds": ",".join(manifest["contentIds"]), "displayName": manifest["title"], "locale": "en_US"}}
steam = {"folder": str(folder), "offers": offers, "contentIds": manifest["contentIds"], "title": manifest["title"],
"version": manifest["version"], "locale": "en_US", "exe": str(exe.relative_to(folder))}
answer = prepare_ea(folder, sidecar, compat_data, launch_dir, steam)
env = answer.get("env") if answer and answer.get("ok") else None
if not isinstance(env, dict):
log("steam ea: no EA session (%s), left to the EA app" % ((answer or {}).get("reason") or "no answer"))
return 0
data = Path(compat_data)
try:
secret = data / (STEAM_EA_ENV + ".tmp")
secret.write_bytes("".join("%s=%s\r\n" % (k, v) for k, v in env.items()
if re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", str(k)) and "\n" not in str(v)).encode())
os.chmod(secret, 0o600)
os.replace(secret, data / STEAM_EA_ENV)
(data / STEAM_EA_LAUNCHER).write_bytes(steam_ea_launcher(folder, exe, manifest["parameters"], compat_data).encode())
(data / STEAM_EA_STATE).write_text(json.dumps({"id": str(answer.get("id") or offers[0])}))
except OSError as error:
log("steam ea: launcher not written (%s), left to the EA app" % type(error).__name__)
return 0
log("steam ea: %s starts %s directly as %s" % (manifest["title"], exe.name, answer.get("id") or offers[0]))
return REPLACED
def gog_support_actions(folder):
@@ -1705,6 +1848,8 @@ def main(argv):
return RAN if subprocess.call(command) == 0 else RAN_FAILED
found = find_store_game(argv)
if found is None:
if steam_ea_link(argv):
return prepare_steam_ea(argv, os.environ.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/"), os.environ.get("DD_LAUNCH_DIR", ""))
return 0
folder, sidecar = found
store, game = str(sidecar.get("store")), str(sidecar.get("id"))
@@ -79,6 +79,10 @@ dd_store_launch() {
/usr/local/bin/droiddeck-store-launch "$@"
rc=$?
[ $rc -eq 10 ] && DD_STORE_EXIT=1
if [ $rc -eq 13 ]; then
DD_STORE_EXIT=1
DD_STORE_REPLACE="${STEAM_COMPAT_DATA_PATH%/}/droiddeck-ea-steam.bat"
fi
[ $rc -eq 11 ] && exit 0
[ $rc -eq 12 ] && exit 1
return 0
@@ -88,6 +92,13 @@ dd_run() {
if [ -x /usr/local/bin/droiddeck-steamvr-flat ] && /usr/local/bin/droiddeck-steamvr-flat "${verb:-}"; then
set -- /usr/local/bin/droiddeck-steamvr-game "$@"
fi
if [ -n "${DD_STORE_REPLACE:-}" ]; then
local arg replaced=()
for arg in "$@"; do
case ${arg,,} in steam2ea://*) replaced+=("$DD_STORE_REPLACE") ;; *) replaced+=("$arg") ;; esac
done
set -- "${replaced[@]}"
fi
if [ -n "${DD_STORE_EXIT:-}" ]; then
trap : INT TERM HUP
"$@"
+101
View File
@@ -452,6 +452,107 @@ class Launchers(unittest.TestCase):
self.assertEqual(-2, rc)
def test_a_steam_ea_link_is_swapped_for_droiddecks_launcher_and_reports_its_exit(self):
with tempfile.TemporaryDirectory() as root:
hook = Path(root) / 'hook'
record = Path(root) / 'ran'
hook.write_text('#!/bin/sh\necho "$@" >> "%s"\n' % record)
hook.chmod(0o755)
setup = compat.DD_STORE_SETUP.replace('/usr/local/bin/droiddeck-store-launch', str(hook)).replace(
'[ -x %s ] || return 0' % hook, '[ -x %s ] || return 0; verb=waitforexitandrun' % hook)
setup = setup.replace(' %s "$@"\n rc=$?' % hook, ' %s "$@"\n rc=13' % hook)
script = setup + '\nverb=waitforexitandrun\ndd_store_launch steam2ea://launchgame/1237970 -dev\nDD_STORE_ARGS=(steam2ea://launchgame/1237970 -dev)\ndd_run %s proton waitforexitandrun Steam2EA://launchgame/1237970 -dev\n' % hook
done = subprocess.run(['bash', '-c', script], env=dict(os.environ, STEAM_COMPAT_DATA_PATH=root + '/'), timeout=20)
self.assertEqual(0, done.returncode)
lines = record.read_text().splitlines()
self.assertEqual('proton waitforexitandrun %s/droiddeck-ea-steam.bat -dev' % root, lines[1])
self.assertEqual('--exited --code 0 steam2ea://launchgame/1237970 -dev', lines[2])
MANIFEST = """<?xml version='1.0' encoding='utf-8'?>
<DiPManifest version="4.0">
<buildMetaData><gameVersion version="1.0.1.3" /></buildMetaData>
<contentIDs><contentID>1039093</contentID></contentIDs>
<runtime>
<launcher uid="1-2"><filePath>[HKEY_LOCAL_MACHINE\\SOFTWARE\\Respawn\\Titanfall2\\Install Dir]Titanfall2.exe</filePath><parameters /><trial>0</trial></launcher>
<launcher uid="2-2"><filePath>[HKEY_LOCAL_MACHINE\\SOFTWARE\\Respawn\\Titanfall2\\Install Dir]Titanfall2_trial.exe</filePath><parameters /><trial>1</trial></launcher>
</runtime>
<gameTitles><gameTitle locale="en_US">Titanfall 2</gameTitle></gameTitles>
</DiPManifest>
"""
class SteamEa(unittest.TestCase):
def steam_copy(self, root):
folder = Path(root) / 'steamapps/common/Titanfall2'
(folder / '__Installer/LOC').mkdir(parents=True)
(folder / '__Installer/installerdata.xml').write_bytes(b'\xff\xfe' + MANIFEST.encode('utf-16-le'))
(folder / '__Installer/LOC/Origin.OFR.50.0001456.dat').write_text('')
(folder / '__Installer/LOC/Origin.OFR.50.0001452.dat').write_text('')
(folder / 'Titanfall2.exe').write_text('')
(folder / 'Titanfall2_trial.exe').write_text('')
data = Path(root) / 'compatdata/1237970'
(data / 'pfx').mkdir(parents=True)
return folder, data
def test_the_manifest_names_the_full_game_its_content_and_version(self):
with tempfile.TemporaryDirectory() as root:
folder, _ = self.steam_copy(root)
manifest = store.ea_manifest(folder)
self.assertEqual(folder / 'Titanfall2.exe', manifest['exe'])
self.assertEqual(['1039093'], manifest['contentIds'])
self.assertEqual('1.0.1.3', manifest['version'])
self.assertEqual('Titanfall 2', manifest['title'])
self.assertEqual(['Origin.OFR.50.0001452', 'Origin.OFR.50.0001456'], store.steam_ea_offers(folder))
def test_a_steam_ea_launch_gets_a_session_and_a_launcher_that_reads_it_once(self):
with tempfile.TemporaryDirectory() as root:
folder, data = self.steam_copy(root)
asked = []
answer = {'ok': True, 'id': 'Origin.OFR.50.0001452', 'env': {'EALsxPort': '3216', 'ContentId': '1039093'}}
prepare = lambda *a: asked.append(a) or answer
env = {'STEAM_COMPAT_INSTALL_PATH': str(folder), 'STEAM_COMPAT_DATA_PATH': str(data), 'DD_LAUNCH_DIR': str(Path(root) / 'session')}
with patch.dict(os.environ, env), patch.object(store, 'prepare_ea', side_effect=prepare):
self.assertEqual(store.REPLACED, store.main(['steam2ea://launchgame/1237970?platform=steam&theme=tf2']))
steam = asked[0][4]
self.assertEqual(['Origin.OFR.50.0001452', 'Origin.OFR.50.0001456'], steam['offers'])
self.assertEqual(['1039093'], steam['contentIds'])
self.assertEqual('Titanfall2.exe', steam['exe'])
self.assertEqual(b'EALsxPort=3216\r\nContentId=1039093\r\n', (data / store.STEAM_EA_ENV).read_bytes())
bat = (data / store.STEAM_EA_LAUNCHER).read_text()
envfile = store.windows_path(str(data / store.STEAM_EA_ENV))
self.assertIn('cd /d "%s"' % store.windows_path(str(folder)), bat)
self.assertIn('for /f "usebackq tokens=1,* delims==" %%%%a in ("%s") do set "%%%%a=%%%%b"' % envfile, bat)
self.assertIn('del "%s"' % envfile, bat)
self.assertIn('"%s" %%*' % store.windows_path(str(folder / 'Titanfall2.exe')), bat)
self.assertEqual({'id': 'Origin.OFR.50.0001452'}, json.loads((data / store.STEAM_EA_STATE).read_text()))
asked.clear()
record = lambda channel, request, timeout=5.0, claim=False: asked.append(request)
with patch.dict(os.environ, env), patch.object(store, 'ask', side_effect=record):
self.assertEqual(0, store.main(['--exited', 'steam2ea://launchgame/1237970']))
self.assertEqual([{'op': 'ea-exited', 'store': 'ea', 'id': 'Origin.OFR.50.0001452'}], asked)
def test_the_manifests_launch_parameters_keep_their_quotes(self):
with tempfile.TemporaryDirectory() as root:
folder, data = self.steam_copy(root)
bat = store.steam_ea_launcher(folder, folder / 'Titanfall2.exe', '-config "game profile.cfg" -rate 50%', str(data))
self.assertIn('Titanfall2.exe" -config "game profile.cfg" -rate 50%% %*', bat)
def test_steam_keeps_the_link_when_droiddeck_cannot_start_the_game(self):
with tempfile.TemporaryDirectory() as root:
folder, data = self.steam_copy(root)
env = {'STEAM_COMPAT_INSTALL_PATH': str(folder), 'STEAM_COMPAT_DATA_PATH': str(data), 'DD_LAUNCH_DIR': str(Path(root) / 'session')}
link = ['steam2ea://launchgame/1237970']
with patch.dict(os.environ, env), patch.object(store, 'prepare_ea', return_value={'ok': False, 'reason': 'signed-out'}):
self.assertEqual(0, store.main(link))
client = data / 'pfx' / store.STEAM_EA_CLIENT
client.parent.mkdir(parents=True)
client.write_text('')
with patch.dict(os.environ, env), patch.object(store, 'prepare_ea', side_effect=AssertionError('the EA app is installed')):
self.assertEqual(0, store.main(link))
self.assertFalse((data / store.STEAM_EA_LAUNCHER).exists())
if __name__ == '__main__':
unittest.main()