Compare commits

...
Author SHA1 Message Date
MaxsTechReview aff81a13e3 perf(session): read process command lines in one call in the zRAM watcher (#3302)
Read process command lines in one call in the zRAM watcher

The watcher read every /proc/<pid>/cmdline one byte per system call, costing about 390 ms of CPU per scan every 5 s (every second under memory pressure). mapfile reads in blocks and yields the same argument list, cutting a scan to about 17 ms.
2026-11-26 18:04:24 -05:00
MaxsTechReview 3dbcefc14c fix(fex): x86 .NET guests suspend threads without injected signals (#3291)
* fix(fex): x86 .NET guests suspend threads without injected signals

* fix(fex): keep a COMPlus_ thread-suspend override and cover older .NET guests

* fix(fex): treat empty ThreadSuspendInjection values as unset
2026-11-26 17:51:25 -05:00
The412Banner 9cbad0b1ac feat: full Xbox cloud library, launch art + Cancel, stereo stream audio; Pocket FIT and Duo chip names; ignore Xiaomi uinput pad (#3232)
Xbox cloud
- Audio: WebRTC's JavaAudioDeviceModule defaults to voice-call audio
  (mono, speaker/earpiece only), so HDMI, USB and Bluetooth stayed silent.
  Use USAGE_GAME + CONTENT_TYPE_MOVIE and stereo output. From Bannerlator
  eac4a3bb (same WebRTC 125.6422.07), proven there over HDMI.
- Library: GET /v2/titles marks every title the account may play
  (details.hasEntitlement or isFreeInStore, as Greenlight's xcloud.ts by
  UnknownSKL, MIT); those not in the PC list are added (gamepass when on
  the Game Pass cloud list, else owned). Catalog in batches of 25, up to 4
  at a time, mapped per batch. One card per title: cloud-only editions
  fold into the PC card (owned when the cloud edition is owned), same-title
  cloud-only editions become one card (matched on every Unicode letter
  and digit, so non-Latin titles stay apart). Without the Game Pass
  lists no cloud titles are added. On one account: All 459 -> 677,
  Owned 9 -> 53, Game Pass 450 -> 624, Cloud 325 -> 569.
- Players: when the title list lacks the product, look it up by product id
  (POST /v2/titles with alternateIds, as Better xCloud's getTitleInfo by
  redphx, MIT), then by the game's name against the list.
- Launch art: both players show the game's art as a slow slideshow with the
  title until the first video frame (store-images hosts only, up to 12).
  Native: XboxNativeVideo.onFirstFrame, plus 6 s after connect for
  zero-copy. Web: a script waits for the video element's first decoded
  frame (or 6 s) and calls DDCloud.firstFrame().
- Cancel: until the first frame, B or Back, or a tap on the B Cancel
  button (button role + accessibility action, not focusable), closes the
  player and ends the session; afterwards B and Back
  work as before. A session started after the player closed is stopped
  right away.
From Even Better Xcloud (BannerCloud) ef61b2b, fc68d26, a4d2d1e, 559e17b,
7ec2a75 (the web-player launch art is new).

Chip names
- The AYANEO Pocket FIT (SG8350P, pineapple) showed "Snapdragon 8 Gen 3
  family" and the Retroid Pocket Duo (CQ7790S, sun) "Snapdragon 8 Elite
  family". Add SG8350P (Snapdragon G3 Gen 3), CQ7790S (Dragonwing Q-7790),
  SM8635, SM8735, SM7675 and platform canoe; use the platform family only
  for an empty model or an "SM" phone part. Model matching stays exact.
  From Bannerlator 59c49bfa (without its suffix stripping and Galaxy
  naming). plainName (#3231) now names the Duo's chip too; its test uses
  an unknown model for the maker + model fallback.

Input
- Xiaomi's system uinput device "ui-input-xiaomi" reports gamepad sources
  and could take a player slot. From Bannerlator fbe0233e, ported there
  from Winlator Ludashi e104c8d3 by StevenMXZ (GPL-3.0).
2026-11-26 17:46:05 -05:00
16 changed files with 457 additions and 48 deletions

No files matched your search

@@ -7,17 +7,21 @@ object SocNames {
"SM8150" to "Snapdragon 855", "SM8250" to "Snapdragon 865", "SM8250-AC" to "Snapdragon 870",
"SM8350" to "Snapdragon 888", "SM8450" to "Snapdragon 8 Gen 1", "SM8475" to "Snapdragon 8+ Gen 1",
"SM8550" to "Snapdragon 8 Gen 2", "QCS8550" to "Snapdragon 8 Gen 2", "SM8650" to "Snapdragon 8 Gen 3",
"SM8635" to "Snapdragon 8s Gen 3", "SM8735" to "Snapdragon 8s Gen 4",
"SM8750" to "Snapdragon 8 Elite", "SM8750P" to "Snapdragon 8 Elite",
"SM8850" to "Snapdragon 8 Elite Gen 5",
"SM8975" to "Snapdragon 8 Elite Extreme Gen 6",
"SM7325" to "Snapdragon 778G", "SM7450" to "Snapdragon 7 Gen 1", "SM7550" to "Snapdragon 7 Gen 3",
"SM7675" to "Snapdragon 7+ Gen 3",
"SM6375" to "Snapdragon 695",
// Handheld parts: AYANEO Pocket FIT (SG8350P), Retroid Pocket Duo (CQ7790S).
"SG8350P" to "Snapdragon G3 Gen 3", "CQ7790S" to "Dragonwing Q-7790",
)
private val PLATFORMS = mapOf(
"msmnile" to "Snapdragon 855/860", "kona" to "Snapdragon 865/870", "lahaina" to "Snapdragon 888",
"taro" to "Snapdragon 8 Gen 1", "cape" to "Snapdragon 8+ Gen 1", "kalama" to "Snapdragon 8 Gen 2",
"pineapple" to "Snapdragon 8 Gen 3", "sun" to "Snapdragon 8 Elite",
"pineapple" to "Snapdragon 8 Gen 3", "sun" to "Snapdragon 8 Elite", "canoe" to "Snapdragon 8 Elite Gen 5",
)
fun model(prop: (String) -> String = GpuInfo::systemProperty): String {
@@ -30,8 +34,16 @@ object SocNames {
internal fun normalizedModel(model: String): String = model.trim().uppercase().removePrefix("QTI ").trim()
fun name(model: String, platform: String = GpuInfo.systemProperty("ro.board.platform")): String? =
MODELS[normalizedModel(model)] ?: PLATFORMS[platform.lowercase()]?.let { "$it family" }
/**
* The exact model's name; the board platform's family only for an empty model or a phone "SM" part, since
* different chips share a platform (the Retroid Pocket Duo's CQ7790S and the Snapdragon 8 Elite are both "sun").
*/
fun name(model: String, platform: String = GpuInfo.systemProperty("ro.board.platform")): String? {
val m = normalizedModel(model)
MODELS[m]?.let { return it }
if (m.isNotEmpty() && !m.startsWith("SM")) return null
return PLATFORMS[platform.lowercase()]?.let { "$it family" }
}
// Without label's platform-family guess: a rebadged chip such as the Duo's CQ7790S reports a platform it is not.
fun plainName(model: String = model(), maker: String = manufacturer()): String =
@@ -273,7 +273,8 @@ public final class PadBridge {
static boolean isSystemVirtualInputName(String name) {
if (name == null) return false;
String lower = name.trim().toLowerCase(java.util.Locale.ROOT);
return lower.startsWith("uinput-") || lower.startsWith("uinput_");
// Xiaomi's "ui-input-xiaomi" is a system uinput device that also reports gamepad sources.
return lower.startsWith("uinput-") || lower.startsWith("uinput_") || lower.equals("ui-input-xiaomi");
}
public static boolean isFromController(InputDevice device) {
@@ -58,17 +58,30 @@ object XboxBackend : StoreBackend {
if (cached != null && !cached.needsRefresh(force)) { XboxGamertag.ensure(app); return@Thread }
val response = Xodus.run(app, listOf("library", "--json", "--market", market))
val licenses = XboxCatalog.access(response, account, market, report = { StoresState.logLine("Xbox: $it") })
val products = XboxCatalog.rawProducts(licenses.keys.toList(), market)
val cloud = runCatching { XboxCatalog.cloudCatalog(market) }
.onFailure { StoresState.logLine("Xbox: cloud lists unavailable (${it.javaClass.simpleName})") }.getOrNull()
val games = mergeEditions(products.mapNotNull { XboxCatalog.product(it, licenses, cloud) }).sortedBy { it.title.lowercase() }
StoresState.logLine("Xbox: library catalog requested=${licenses.size} returned=${products.size} supported=${games.size} " +
"filtered=${products.size - games.size} backend-skipped=${response.optInt("skippedEntitlements")} " +
// The PC entitlement list leaves out console purchases and free games; the streaming service lists them.
val titles = runCatching { XboxCloudSession.titleList(XboxCloudSession.get(app, account), fresh = true) }
.onFailure { StoresState.logLine("Xbox: cloud titles unavailable (${it.javaClass.simpleName})") }.getOrNull()
// Without the Game Pass lists an entitled title cannot be told apart from a purchase, so none are added.
val added = if (cloud == null) emptyMap<String, String>() else titles?.entitled.orEmpty().filter { it !in licenses }
.associateWith { if (it in cloud.gamePass) "gamepass" else "owned" }
StoresState.logLine("Xbox: cloud titles=${titles?.ids?.size ?: -1} entitled=${titles?.entitled?.size ?: -1} " +
"added=${added.size} (owned ${added.values.count { it == "owned" }}, gamepass ${added.values.count { it == "gamepass" }})")
val entitlements = licenses + added
val returned = java.util.concurrent.atomic.AtomicInteger()
val supported = XboxCatalog.productBatches(entitlements.keys.toList(), market) { batch ->
returned.addAndGet(batch.size)
batch.mapNotNull { XboxCatalog.product(it, entitlements, cloud) }
}
val games = mergeEditions(supported).sortedBy { it.title.lowercase() }
StoresState.logLine("Xbox: library catalog requested=${entitlements.size} returned=${returned.get()} supported=${supported.size} " +
"shown=${games.size} backend-skipped=${response.optInt("skippedEntitlements")} " +
"pc=${games.count { it.xboxPc }} cloud=${games.count { it.xboxCloud }} cloud-only=${games.count { !it.xboxPc }} " +
"cloud-lists=${cloud?.gamePass?.size ?: -1}/${cloud?.all?.size ?: -1}")
synchronized(this) {
if (current != generation || StoreAccounts.signedInAs(app, store) != account) return@Thread
access = licenses
access = entitlements
runCatching { XboxLibraryCache.write(app, account, market, games) }
.onFailure { StoresState.logLine("Xbox: library cache could not be saved") }
}
@@ -84,10 +84,42 @@ internal object XboxCatalog {
return rawProducts(ids, market).mapNotNull { product(it, access) }
}
fun rawProducts(ids: List<String>, market: String = Xodus.market()): List<JSONObject> {
return ids.map { it.uppercase() }.filter { productId.matches(it) }.distinct().chunked(25).flatMap { batch ->
fun launchArt(id: String, market: String = Xodus.market()): List<String> =
rawProducts(listOf(id.uppercase()), market).firstOrNull()?.let(::launchArtUrls).orEmpty()
internal fun launchArtUrls(json: JSONObject): List<String> {
val images = objects(objects(json.optJSONArray("LocalizedProperties")).firstOrNull()?.optJSONArray("Images"))
val order = listOf("SuperHeroArt", "TitledHeroArt", "Screenshot", "Hero")
return images.filter { it.optString("ImagePurpose") in order }
.sortedBy { order.indexOf(it.optString("ImagePurpose")) }
.mapNotNull { image ->
val raw = image.optString("Uri")
val url = if (raw.startsWith("//")) "https:$raw" else raw
runCatching { java.net.URI(url) }.getOrNull()?.takeIf {
it.scheme == "https" && it.host in setOf("store-images.s-microsoft.com", "store-images.microsoft.com") && it.userInfo == null && it.port == -1
}?.toString()
}.distinct().take(12)
}
fun rawProducts(ids: List<String>, market: String = Xodus.market()): List<JSONObject> = productBatches(ids, market) { it }
// 25 ids per request, up to 4 requests at a time; each batch is mapped as it arrives (a whole library of raw entries is large).
fun <T> productBatches(ids: List<String>, market: String = Xodus.market(), map: (List<JSONObject>) -> List<T>): List<T> {
val batches = ids.map { it.uppercase() }.filter { productId.matches(it) }.distinct().chunked(25)
fun fetchBatch(batch: List<String>): List<T> {
val body = get("https://displaycatalog.mp.microsoft.com/v7.0/products?bigIds=${batch.joinToString(",")}&market=$market&languages=en-us,neutral")
objects(body.optJSONArray("Products")).filter { it.optString("ProductId").uppercase() in batch }
return map(objects(body.optJSONArray("Products")).filter { it.optString("ProductId").uppercase() in batch })
}
if (batches.size <= 1) return batches.flatMap(::fetchBatch)
val pool = java.util.concurrent.Executors.newFixedThreadPool(4)
try {
val tasks = batches.map { batch -> pool.submit(java.util.concurrent.Callable { fetchBatch(batch) }) }
return tasks.flatMap { task ->
try { task.get(60, java.util.concurrent.TimeUnit.SECONDS) }
catch (e: java.util.concurrent.ExecutionException) { throw e.cause ?: e }
}
} finally {
pool.shutdownNow()
}
}
@@ -180,16 +212,28 @@ val CatalogItem.xboxPc: Boolean get() = extra["pc"] != "0"
val CatalogItem.xboxCloud: Boolean get() = extra["cloud"] == "1"
val CatalogItem.xboxCloudId: String get() = extra["cloudId"]?.takeIf { it.isNotEmpty() } ?: id
// One card per title: a cloud-only edition folds into the PC card (which then streams, and counts as owned when
// the cloud edition is); cloud-only editions with the same title become one card, owned first.
internal fun mergeEditions(games: List<CatalogItem>): List<CatalogItem> {
fun key(title: String) = title.lowercase().replace(Regex("[^a-z0-9]+"), "")
fun key(title: String): String {
val lower = title.lowercase()
val letters = StringBuilder().apply { lower.codePoints().filter { Character.isLetterOrDigit(it) }.forEach { appendCodePoint(it) } }
return letters.toString().ifEmpty { lower.trim() }
}
val pcKeys = games.filter { it.xboxPc }.map { key(it.title) }.toSet()
val cloudOnly = games.filter { !it.xboxPc && it.xboxCloud }.groupBy { key(it.title) }
val folded = HashSet<String>()
val merged = games.map { game ->
if (!game.xboxPc || game.xboxCloud) game
else cloudOnly[key(game.title)]?.firstOrNull()?.let { console ->
folded.add(console.id)
game.copy(extra = game.extra + mapOf("cloud" to "1", "cloudId" to console.id))
} ?: game
.mapValues { (_, list) -> list.sortedByDescending { it.owned }.first() }
return games.mapNotNull { game ->
val console = cloudOnly[key(game.title)]
when {
!game.xboxPc -> game.takeIf { key(game.title) !in pcKeys && (console == null || console === game) }
console == null -> game
else -> {
val cloudId = if (game.xboxCloud) game.extra["cloudId"].orEmpty() else console.id
val merged = game.copy(extra = game.extra + mapOf("cloud" to "1", "cloudId" to cloudId))
if (console.owned && !game.owned) merged.copy(owned = true, subscription = false, extra = merged.extra + ("access" to "owned"))
else merged
}
}
}
return merged.filter { it.id !in folded }
}
@@ -6,6 +6,7 @@ import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.KeyEvent
import android.view.WindowManager
import android.webkit.JavascriptInterface
@@ -47,6 +48,8 @@ class XboxCloudPlayerActivity : ComponentActivity() {
private lateinit var root: FrameLayout
private var web: WebView? = null
private var notice: LinearLayout? = null
private lateinit var art: XboxLaunchArt
private lateinit var artStatus: TextView
private val worker = Executors.newSingleThreadExecutor()
private val signalling = Executors.newCachedThreadPool()
@Volatile private var session: XboxCloudSession.Session? = null
@@ -68,15 +71,24 @@ class XboxCloudPlayerActivity : ComponentActivity() {
root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) }
setContentView(root)
val requested = intent.getStringExtra("product").orEmpty()
art = XboxLaunchArt(this) { diag("cloud player $it") }
root.addView(art.view(intent.getStringExtra("title").orEmpty()) { cancelLaunch() }, FrameLayout.LayoutParams(-1, -1))
artStatus = TextView(this).apply {
setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER; setShadowLayer(10f, 0f, 0f, Color.BLACK); visibility = View.GONE
}
root.addView(artStatus, FrameLayout.LayoutParams(-1, -2, Gravity.BOTTOM).apply { bottomMargin = 120 })
art.load(requested)
showNotice("Signing in to Xbox Cloud Gaming…", withButtons = false)
worker.execute {
val result = runCatching {
val account = StoreAccounts.signedInAs(applicationContext, Store.XBOX) ?: error("Sign in to the Xbox store first.")
val cached = XboxLibraryCache.read(applicationContext, account, Xodus.market())?.games?.firstOrNull { it.id == requested }
val product = cached?.extra?.get("cloudId")?.takeIf { it.isNotEmpty() } ?: requested
webUrl = XboxCatalog.cloudUrl(requested, cached?.title ?: intent.getStringExtra("title").orEmpty(), product)
val name = cached?.title ?: intent.getStringExtra("title").orEmpty()
webUrl = XboxCatalog.cloudUrl(requested, name, product)
val active = XboxCloudSession.get(applicationContext, account)
val title = XboxCloudSession.titles(active)[product] ?: error("This game can't be streamed with this account here.")
val title = XboxCloudSession.titleFor(active, product, name) { diag("cloud player: $it") }
?: error("This game can't be streamed with this account here.")
settings = XboxCloudSettings.load(applicationContext)
startedWith = settings
session = active.forStream(settings.region, settings.osName); titleId = title
@@ -86,6 +98,7 @@ class XboxCloudPlayerActivity : ComponentActivity() {
if (closed) return@runOnUiThread
result.onSuccess { openPlayer() }.onFailure {
diag("cloud player not started: ${it.javaClass.simpleName}: ${it.message?.take(160)}")
hideArt()
showNotice(it.message ?: "Xbox Cloud Gaming could not start.", withButtons = true)
}
}
@@ -130,6 +143,12 @@ class XboxCloudPlayerActivity : ComponentActivity() {
fun call(id: Int, op: String, arg: String) {
signalling.execute {
val reply = runCatching { handle(op, arg) }.getOrElse { XboxCloudSession.Reply(0, it.javaClass.simpleName) }
if (closed && op == "start") {
val active = session; val path = sessionPath
if (active != null && path != null) runCatching { XboxCloudSession.request(active, "DELETE", "/$path") }
.onSuccess { diag("cloud player cancelled: session closed ${it.status}") }
return@execute
}
if (reply.status !in 200..299) diag("cloud player $op: ${reply.status} ${reply.body.take(300)}")
else if (op != "state" && op != "keepalive") diag("cloud player $op: ${reply.status}")
runOnUiThread { web?.evaluateJavascript("window.__ddResolve($id, ${reply.status}, ${JSONObject.quote(reply.body)})", null) }
@@ -137,12 +156,24 @@ class XboxCloudPlayerActivity : ComponentActivity() {
}
@JavascriptInterface
fun status(text: String) { android.util.Log.i("XboxCloudPlayer", "status: ${text.take(120)}") }
fun status(text: String) {
android.util.Log.i("XboxCloudPlayer", "status: ${text.take(120)}")
if (art.shown) runOnUiThread { if (art.shown) { artStatus.text = text; artStatus.visibility = if (text.isEmpty()) View.GONE else View.VISIBLE } }
}
@JavascriptInterface
fun playing() {
diag("cloud player streaming")
runOnUiThread { web?.requestFocus() }
runOnUiThread {
web?.requestFocus()
if (art.shown) { web?.evaluateJavascript(FIRST_FRAME_JS, null); root.postDelayed({ hideArt() }, 6000) }
}
}
@JavascriptInterface
fun firstFrame() {
if (art.shown) diag("cloud player first frame")
hideArt()
}
@JavascriptInterface
@@ -154,6 +185,7 @@ class XboxCloudPlayerActivity : ComponentActivity() {
@JavascriptInterface
fun failed(stage: String, detail: String) {
diag("cloud player failed at ${stage.take(40)}: ${detail.take(300)}")
hideArt()
runOnUiThread { if (!closed) showNotice("The stream could not start ($stage).", withButtons = true) }
}
}
@@ -164,6 +196,13 @@ class XboxCloudPlayerActivity : ComponentActivity() {
return signals.op(op, arg).also { sessionPath = signals.path }
}
private fun hideArt() {
art.hide()
runOnUiThread { artStatus.visibility = View.GONE }
}
private fun cancelLaunch() { if (!isFinishing) { diag("cloud player launch cancelled"); finish() } }
private fun showNotice(text: String, withButtons: Boolean) {
notice?.let { root.removeView(it) }
val box = LinearLayout(this).apply {
@@ -264,6 +303,10 @@ class XboxCloudPlayerActivity : ComponentActivity() {
}
return super.dispatchKeyEvent(event)
}
if (art.shown && (event.keyCode == KeyEvent.KEYCODE_BUTTON_B || event.keyCode == KeyEvent.KEYCODE_BACK)) {
if (event.action == KeyEvent.ACTION_UP) cancelLaunch()
return true
}
if (notice == null && guideKey(event)) return true
if (event.keyCode == KeyEvent.KEYCODE_BACK) {
if (event.action == KeyEvent.ACTION_UP) { if (notice == null) openMenu() else finish() }
@@ -379,6 +422,10 @@ class XboxCloudPlayerActivity : ComponentActivity() {
companion object {
private const val DOUBLE_PRESS_MS = 350L
// Calls DDCloud.firstFrame() once the page's video has decoded a frame (or after 6 s).
private const val FIRST_FRAME_JS = "(function(){var t=Date.now();(function poll(){var v=document.querySelector('video');" +
"var n=v&&v.getVideoPlaybackQuality?v.getVideoPlaybackQuality().totalVideoFrames:0;" +
"if(n>0||(v&&v.currentTime>0)||Date.now()-t>6000){DDCloud.firstFrame();return;}setTimeout(poll,100);})();})()"
fun intent(context: Context, productId: String, title: String): Intent = Intent(context, XboxCloudPlayerActivity::class.java)
.putExtra("product", productId.uppercase()).putExtra("title", title)
@@ -35,7 +35,7 @@ internal object XboxCloudSession {
json.optString("userToken").takeIf { !json.isNull("userToken") && it.isNotEmpty() }, System.currentTimeMillis() + seconds * 1000).also { cached = it }
}
fun clear() { cached = null; titleIds = null }
fun clear() { cached = null; titleList = null; looked = null }
fun fromMainProcess(app: Context, account: String, timeoutSeconds: Long = 90): Session? {
cached?.takeIf { it.account == account && it.fresh }?.let { return it }
@@ -61,21 +61,64 @@ internal object XboxCloudSession {
b.getString("baseUri").orEmpty(), regions, b.getString("userToken"), b.getLong("expiresAt"))
}
@Volatile private var titleIds: Pair<String, Map<String, String>>? = null
class Titles(val ids: Map<String, String>, val entitled: Set<String>)
fun titles(session: Session): Map<String, String> {
titleIds?.takeIf { it.first == session.account }?.let { return it.second }
@Volatile private var titleList: Pair<String, Titles>? = null
fun titles(session: Session): Map<String, String> = titleList(session).ids
// Entitled = details.hasEntitlement or isFreeInStore, as Greenlight's xcloud.ts by unknownskl (MIT).
fun titleList(session: Session, fresh: Boolean = false): Titles {
if (!fresh) titleList?.takeIf { it.first == session.account }?.let { return it.second }
val reply = request(session, "GET", "/v2/titles")
check(reply.status == 200) { "Xbox Cloud Gaming answered ${reply.status}" }
val results = JSONObject(reply.body).optJSONArray("results") ?: JSONArray()
val map = (0 until results.length()).mapNotNull { index ->
val row = results.optJSONObject(index) ?: return@mapNotNull null
val product = row.optJSONObject("details")?.optString("productId")?.uppercase().orEmpty()
val ids = LinkedHashMap<String, String>()
val entitled = LinkedHashSet<String>()
for (index in 0 until results.length()) {
val row = results.optJSONObject(index) ?: continue
val details = row.optJSONObject("details")
val product = details?.optString("productId")?.uppercase().orEmpty()
val title = row.optString("titleId")
if (product.matches(Regex("[A-Z0-9]{12}")) && title.isNotBlank() && title.length <= 64) product to title else null
}.toMap()
titleIds = session.account to map
return map
if (!product.matches(Regex("[A-Z0-9]{12}")) || title.isBlank() || title.length > 64) continue
ids.putIfAbsent(product, title)
if (details?.optBoolean("hasEntitlement") == true || details?.optBoolean("isFreeInStore") == true) entitled += product
}
return Titles(ids, entitled).also { titleList = session.account to it }
}
@Volatile private var looked: Pair<String, MutableMap<String, String>>? = null
// Lookup by product id (POST /v2/titles with alternateIds) as Better xCloud's getTitleInfo (MIT).
fun titleFor(session: Session, productId: String, name: String = "", log: (String) -> Unit = {}): String? {
val product = productId.uppercase()
val list = titles(session)
list[product]?.let { return it }
val cache = looked?.takeIf { it.first == session.account }?.second ?: HashMap<String, String>().also { looked = session.account to it }
cache[product]?.let { return it }
val body = JSONObject().put("alternateIds", JSONArray().put(product)).put("alternateIdType", "productId").toString()
val reply = runCatching { request(session, "POST", "/v2/titles", body) }.getOrNull()
val rows = reply?.takeIf { it.status == 200 }?.let { runCatching { JSONObject(it.body).optJSONArray("results") }.getOrNull() }
val row = rows?.optJSONObject(0)
val title = row?.optString("titleId").orEmpty()
val rowProduct = row?.optJSONObject("details")?.optString("productId")?.uppercase().orEmpty()
log("title lookup $product: http ${reply?.status ?: -1}, results ${rows?.length() ?: -1}, title ${title.ifEmpty { "-" }}, product ${rowProduct.ifEmpty { "-" }}")
if (title.isNotBlank() && title.length <= 64) { cache[product] = title; return title }
val key = nameKey(name)
if (key.length >= 4) {
val byName = list.values.filter { it.uppercase() == key }.distinct()
log("title by name $key: ${byName.joinToString().ifEmpty { "none" }}")
if (byName.size == 1) { cache[product] = byName[0]; return byName[0] }
}
return null
}
private val EDITION_WORDS = Regex("(STANDARD|DELUXE|PREMIUM|ULTIMATE|GOLD|COMPLETE|DEFINITIVE|ENHANCED|ANNIVERSARY|GAMEOFTHEYEAR|GOTY)?EDITION$|GAMEPREVIEW$|FORWINDOWS(10)?$|XBOXSERIESXS$|XBOXONE$|PC$")
internal fun nameKey(name: String): String {
var key = name.uppercase().replace(Regex("[^A-Z0-9]"), "")
repeat(3) { key = key.replace(EDITION_WORDS, "") }
return key
}
class Reply(val status: Int, val body: String)
@@ -0,0 +1,142 @@
package com.droiddeck.launcher.stores.xbox
import android.app.Activity
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.onClick
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.droiddeck.launcher.R
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreAccounts
import com.droiddeck.launcher.ui.DroidDeckTheme
import kotlinx.coroutines.delay
// The game's art as a slow slideshow while a cloud stream connects, until the first video frame.
// From Even Better Xcloud (BannerCloud) 7ec2a75.
internal class XboxLaunchArt(private val activity: Activity, private val log: (String) -> Unit) {
private val urls = mutableStateListOf<String>()
private var visible by mutableStateOf(true)
@Volatile var shown = true
private set
fun view(title: String, onCancel: () -> Unit): ComposeView = ComposeView(activity).apply {
setContent { DroidDeckTheme { LaunchArt(urls, title, visible, onCancel) } }
}
fun load(product: String) {
if (product.isEmpty()) return
val app = activity.applicationContext
Thread({
runCatching {
val account = StoreAccounts.signedInAs(app, Store.XBOX) ?: return@runCatching
val game = XboxLibraryCache.read(app, account, Xodus.market())?.games?.firstOrNull { it.id == product }
game?.imageUrl?.let { url -> activity.runOnUiThread { if (urls.isEmpty()) urls.add(url) } }
val more = XboxCatalog.launchArt(product)
if (more.isNotEmpty()) activity.runOnUiThread { urls.addAll(more.filter { it !in urls }) }
}.onFailure { log("launch art: ${it.javaClass.simpleName}") }
}, "launch-art").start()
}
fun hide() {
shown = false
activity.runOnUiThread { visible = false }
}
}
@Composable
private fun LaunchArt(images: List<String>, title: String, visible: Boolean, onCancel: () -> Unit) {
AnimatedVisibility(visible, enter = fadeIn(tween(400)), exit = fadeOut(tween(700))) {
Box(Modifier.fillMaxSize().background(Color.Black)) {
var index by remember { mutableIntStateOf(0) }
LaunchedEffect(images.size) {
while (true) {
delay(SLIDE_MS)
if (images.size > 1) index = (index + 1) % images.size
}
}
Crossfade(targetState = images.getOrNull(index % images.size.coerceAtLeast(1)), animationSpec = tween(1400),
label = "launch-art") { url ->
if (url != null) Slide(url, index)
}
Box(Modifier.fillMaxSize().background(Brush.verticalGradient(
0f to Color(0x66000000), 0.45f to Color(0x22000000), 0.78f to Color(0xB3000000), 1f to Color(0xF2000000))))
Text(title, style = MaterialTheme.typography.headlineSmall, color = Color.White, maxLines = 2,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.align(Alignment.BottomStart).padding(start = 40.dp, end = 220.dp, bottom = 34.dp))
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp),
modifier = Modifier.align(Alignment.BottomEnd).padding(end = 40.dp, bottom = 30.dp)
.clip(RoundedCornerShape(50)).background(Color(0x99000000))
.pointerInput(Unit) { detectTapGestures { onCancel() } }
.semantics(mergeDescendants = true) { role = Role.Button; onClick { onCancel(); true } }
.padding(start = 8.dp, end = 18.dp, top = 8.dp, bottom = 8.dp)) {
Box(Modifier.size(28.dp).clip(CircleShape).background(Color(0xFFE5484D)), contentAlignment = Alignment.Center) {
Text("B", color = Color.White, fontWeight = FontWeight.Bold, fontSize = 15.sp)
}
Text(stringResource(R.string.common_cancel), color = Color.White, fontSize = 16.sp, fontWeight = FontWeight.SemiBold)
}
}
}
}
@Composable
private fun Slide(url: String, index: Int) {
val ctx = LocalContext.current
val progress = remember(url) { Animatable(0f) }
LaunchedEffect(url) { progress.animateTo(1f, tween((SLIDE_MS + 1600).toInt(), easing = LinearEasing)) }
val dir = if (index % 2 == 0) 1f else -1f
AsyncImage(
model = ImageRequest.Builder(ctx).data(url).crossfade(500).build(),
contentDescription = null, contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize().graphicsLayer {
val p = progress.value
val s = 1.06f + 0.10f * p
scaleX = s; scaleY = s
translationX = dir * (p - 0.5f) * size.width * 0.04f
})
}
private const val SLIDE_MS = 5200L
@@ -5,6 +5,7 @@ import com.droiddeck.launcher.ui.focusGlide
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.media.AudioAttributes
import android.os.Build
import android.os.Bundle
import android.os.VibrationEffect
@@ -75,6 +76,7 @@ class XboxNativePlayerActivity : ComponentActivity() {
@Volatile private var connectedOnce = false
@Volatile private var endedInBackground = false
private var backgroundEnd: Runnable? = null
private lateinit var art: XboxLaunchArt
private var notice: androidx.compose.ui.platform.ComposeView? = null
@Volatile private var regionNames = emptyList<String>()
@Volatile private var serverName: String? = null
@@ -103,7 +105,10 @@ class XboxNativePlayerActivity : ComponentActivity() {
root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) }
surfaceView = SurfaceView(this)
root.addView(surfaceView, FrameLayout.LayoutParams(-1, -1))
status = TextView(this).apply { setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER }
art = XboxLaunchArt(this) { log(it) }
root.addView(art.view(intent.getStringExtra("title").orEmpty()) { cancelLaunch() }, FrameLayout.LayoutParams(-1, -1))
art.load(intent.getStringExtra("product").orEmpty())
status = TextView(this).apply { setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER; setShadowLayer(10f, 0f, 0f, Color.BLACK) }
root.addView(status, FrameLayout.LayoutParams(-1, -2, Gravity.BOTTOM).apply { bottomMargin = 120 })
overlay = TextView(this).apply {
setTextColor(Color.WHITE); textSize = 12f; typeface = android.graphics.Typeface.MONOSPACE
@@ -118,6 +123,7 @@ class XboxNativePlayerActivity : ComponentActivity() {
val egl = EglBase.create().also { eglBase = it }
val nativeVideo = XboxNativeVideo(this, egl) { log(it) }.also { video = it }
nativeVideo.onFirstFrame = { hideArt() }
surfaceView.holder.addCallback(object : SurfaceHolder.Callback {
override fun surfaceCreated(holder: SurfaceHolder) {}
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
@@ -137,9 +143,12 @@ class XboxNativePlayerActivity : ComponentActivity() {
private fun log(text: String) = com.droiddeck.launcher.stores.StoresState.logLine("Xbox: native player: ${text.take(240)}")
private fun show(text: String) = runOnUiThread { status.text = text; status.visibility = if (text.isEmpty()) android.view.View.GONE else android.view.View.VISIBLE }
private fun hideArt() { if (art.shown) { art.hide(); show("") } }
private fun cancelLaunch() { if (!isFinishing) { log("launch cancelled"); finish() } }
private fun fail(stage: String, detail: String) {
log("failed at $stage: $detail")
art.hide()
if (closed) return
if (connectedOnce) showNotice("The connection to the cloud console was lost",
"The stream stopped reaching this device ($detail). Restart the stream to play again: the game starts over, " +
@@ -232,12 +241,14 @@ class XboxNativePlayerActivity : ComponentActivity() {
val active = (shared ?: XboxCloudSession.get(applicationContext, account)).forStream(settings.region, settings.osName)
regionNames = active.regionList.map { it.name }
serverName = active.regionList.firstOrNull { it.baseUri == active.baseUri }?.name
val title = XboxCloudSession.titles(active)[product] ?: error("This game can't be streamed with this account here.")
val title = XboxCloudSession.titleFor(active, product, cached?.title ?: intent.getStringExtra("title").orEmpty()) { log(it) }
?: error("This game can't be streamed with this account here.")
val signals = XboxCloudSignalling(active, title, settings).also { signalling = it }
log("$product -> $title, region ${java.net.URI(active.baseUri).host}, frame gen ${settings.frameGen}")
show("Starting the game on Xbox Cloud Gaming…")
expect("start", signals.start())
if (closed) { runCatching { signals.stop() }.onSuccess { log("cancelled: session closed ${it?.status}") }; return }
var connected = false
var waited = 0
while (!closed) {
@@ -270,7 +281,15 @@ class XboxNativePlayerActivity : ComponentActivity() {
log("latency: instant input ${settings.instantInput}, small buffer ${settings.smallBuffer}, fast decoder ${settings.fastDecoder}, " +
"zero-copy ${zeroSurface != null}")
val f = PeerConnectionFactory.builder()
.setAudioDeviceModule(JavaAudioDeviceModule.builder(applicationContext).createAudioDeviceModule())
// WebRTC defaults to voice-call audio (mono, speaker/earpiece only); game audio follows
// the normal output (HDMI, USB, Bluetooth) and keeps the stream's stereo.
.setAudioDeviceModule(JavaAudioDeviceModule.builder(applicationContext)
.setAudioAttributes(AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_GAME)
.setContentType(AudioAttributes.CONTENT_TYPE_MOVIE)
.build())
.setUseStereoOutput(true)
.createAudioDeviceModule())
.setVideoDecoderFactory(org.webrtc.DroidDeckLowLatencyDecoderFactory(egl.eglBaseContext, settings.fastDecoder, zeroSurface) { zeroCopyFrames++ }
.also { decoders = it })
.setVideoEncoderFactory(DefaultVideoEncoderFactory(egl.eglBaseContext, true, true))
@@ -365,7 +384,7 @@ class XboxNativePlayerActivity : ComponentActivity() {
when (state) {
PeerConnection.PeerConnectionState.CONNECTED -> {
connectedOnce = true
show("")
if (art.shown) root.postDelayed({ hideArt() }, 6000) else show("")
video?.setFpsTarget(settings.fpsTarget)
video?.setFrameGeneration(effectiveFrameGen())
}
@@ -427,6 +446,10 @@ class XboxNativePlayerActivity : ComponentActivity() {
}
return super.dispatchKeyEvent(event)
}
if (art.shown && (event.keyCode == KeyEvent.KEYCODE_BUTTON_B || event.keyCode == KeyEvent.KEYCODE_BACK)) {
if (event.action == KeyEvent.ACTION_UP) cancelLaunch()
return true
}
if (isGuide(event)) {
if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
val pending = pendingNexus
@@ -54,6 +54,7 @@ internal class XboxNativeVideo(private val context: Context, eglBase: EglBase, p
private var nextDueNs = 0L
@Volatile var frames = 0L
private set
@Volatile var onFirstFrame: (() -> Unit)? = null
fun setSurface(target: Surface?, width: Int, height: Int, displayRefreshHz: Float) = synchronized(lock) {
refreshHz = displayRefreshHz
@@ -126,7 +127,10 @@ internal class XboxNativeVideo(private val context: Context, eglBase: EglBase, p
if (nextDueNs == 0L || now - nextDueNs > interval) nextDueNs = now
if (now + 4_000_000L < nextDueNs) true else { nextDueNs += interval; false }
}
if (attached && buffer != null && !skip) { WaylandCompositor.nativeStreamFrame(buffer); frames++ }
if (attached && buffer != null && !skip) {
WaylandCompositor.nativeStreamFrame(buffer); frames++
onFirstFrame?.let { onFirstFrame = null; it() }
}
buffer?.close()
held.addLast(image)
while (held.size > 2) held.removeFirst().close()
@@ -16,12 +16,20 @@ class SocNamesTest {
@Test fun knownModelsAndPlatformsGetTheirNames() {
assertEquals("Snapdragon 8 Gen 2", SocNames.name("QCS8550", ""))
assertEquals("Snapdragon 8 Gen 3 family", SocNames.name("SG8350P", "pineapple"))
assertEquals("Snapdragon G3 Gen 3", SocNames.name("SG8350P", "pineapple"))
assertNull(SocNames.name("XYZ123", "nowhere"))
assertEquals("Snapdragon 8 Gen 2 (QCS8550)", SocNames.label("QCS8550", ""))
assertEquals("Snapdragon 8 Gen 3 family (SG8350P)", SocNames.label("SG8350P", "pineapple"))
assertEquals("Snapdragon G3 Gen 3 (SG8350P)", SocNames.label("SG8350P", "pineapple"))
assertEquals("XYZ123", SocNames.label("XYZ123", ""))
}
@Test fun platformFamilyOnlyForPhonePartsOrNoModel() {
assertEquals("Dragonwing Q-7790", SocNames.name("CQ7790S", "sun"))
assertNull(SocNames.name("CQ1234X", "sun"))
assertEquals("Snapdragon 8 Elite family", SocNames.name("SM9999", "sun"))
assertEquals("Snapdragon 8 Elite family", SocNames.name("", "sun"))
assertEquals("Snapdragon 8 Elite Gen 5 family", SocNames.name("", "canoe"))
}
@Test fun qtiPrefixIsNormalizedWithoutGuessingOtherModelVariants() {
assertEquals("Snapdragon 8 Elite Extreme Gen 6", SocNames.name("SM8975", ""))
assertEquals("Snapdragon 8 Elite Extreme Gen 6", SocNames.name("QTI SM8975", ""))
@@ -34,7 +42,8 @@ class SocNamesTest {
}
@Test fun plainNameNeverGuessesFromThePlatform() {
assertEquals("Snapdragon 8 Gen 2 (SM8550)", SocNames.plainName("SM8550", "QTI"))
assertEquals("Moorechip CQ7790S", SocNames.plainName("CQ7790S", "Moorechip"))
assertEquals("CQ7790S", SocNames.plainName("CQ7790S", ""))
assertEquals("Dragonwing Q-7790 (CQ7790S)", SocNames.plainName("CQ7790S", "Moorechip"))
assertEquals("Moorechip CQ1234X", SocNames.plainName("CQ1234X", "Moorechip"))
assertEquals("CQ1234X", SocNames.plainName("CQ1234X", ""))
}
}
@@ -71,7 +71,7 @@ class PadBridgeRoutingTest {
InputDevice.KEYBOARD_TYPE_NONE, id = -1)
assertTrue(virtual.isVirtual)
assertFalse(PadBridge.isFromController(virtual))
for (uinputName in listOf("uinput-xiaomi", "uinput-fpc", "uinput_nav")) {
for (uinputName in listOf("uinput-xiaomi", "uinput-fpc", "uinput_nav", "ui-input-xiaomi")) {
val phantom = device(
InputDevice.SOURCE_GAMEPAD or InputDevice.SOURCE_JOYSTICK,
InputDevice.KEYBOARD_TYPE_NONE,
@@ -208,4 +208,53 @@ class XboxCatalogTest {
val merged = mergeEditions(listOf(pc, console)).single()
assertEquals(game, merged.id); assertTrue(merged.xboxPc); assertTrue(merged.xboxCloud); assertEquals(parent, merged.xboxCloudId)
}
@Test fun anOwnedCloudEditionMakesTheGamePassPcCardOwned() {
val cloud = XboxCloudCatalog(gamePass = setOf(game), all = setOf(game, parent))
val pc = XboxCatalog.product(product(game, "Windows.Desktop"), mapOf(game to "gamepass"), cloud)!!
val console = XboxCatalog.product(product(parent, "Xbox.One"), mapOf(parent to "owned"), cloud)!!
val merged = mergeEditions(listOf(pc, console)).single()
assertEquals(game, merged.id); assertTrue(merged.owned); assertFalse(merged.subscription); assertEquals("owned", merged.extra["access"])
assertTrue(merged.xboxCloud); assertEquals(game, merged.xboxCloudId)
}
@Test fun launchArtIsHeroArtThenScreenshotsFromStoreImagesOnly() {
fun img(purpose: String, uri: String) = JSONObject().put("ImagePurpose", purpose).put("Uri", uri)
val json = JSONObject().put("LocalizedProperties", JSONArray().put(JSONObject().put("Images", JSONArray()
.put(img("Screenshot", "//store-images.s-microsoft.com/image/shot1"))
.put(img("BoxArt", "https://store-images.s-microsoft.com/image/box"))
.put(img("SuperHeroArt", "https://store-images.s-microsoft.com/image/hero"))
.put(img("Screenshot", "https://evil.example/shot2"))
.put(img("Screenshot", "https://store-images.s-microsoft.com/image/shot1")))))
assertEquals(listOf("https://store-images.s-microsoft.com/image/hero", "https://store-images.s-microsoft.com/image/shot1"),
XboxCatalog.launchArtUrls(json))
assertEquals(emptyList<String>(), XboxCatalog.launchArtUrls(JSONObject()))
}
@Test fun cloudOnlyEditionsWithTheSameTitleBecomeOneOwnedCard() {
val third = "9CCCCCCCCCCC"
val cloud = XboxCloudCatalog(gamePass = setOf(game), all = setOf(game, third))
val pass = XboxCatalog.product(product(game, "Xbox.One"), mapOf(game to "gamepass"), cloud)!!
val owned = XboxCatalog.product(product(third, "Xbox.One"), mapOf(third to "owned"), cloud)!!
val merged = mergeEditions(listOf(pass, owned)).single()
assertEquals(third, merged.id); assertTrue(merged.owned)
}
@Test fun nonLatinTitlesStaySeparateEditions() {
val third = "9CCCCCCCCCCC"
val cloud = XboxCloudCatalog(gamePass = setOf(game, parent, third), all = setOf(game, parent, third))
val first = XboxCatalog.product(product(game, "Xbox.One"), mapOf(game to "gamepass"), cloud)!!.copy(title = "原神")
val second = XboxCatalog.product(product(parent, "Xbox.One"), mapOf(parent to "gamepass"), cloud)!!.copy(title = "逆転裁判")
val pc = XboxCatalog.product(product(third, "Windows.Desktop"), mapOf(third to "gamepass"), cloud)!!.copy(title = "鉄拳")
val merged = mergeEditions(listOf(first, second, pc))
assertEquals(setOf(game, parent, third), merged.map { it.id }.toSet())
assertFalse(merged.single { it.id == third }.extra["cloudId"] in setOf(game, parent))
}
@Test fun supplementaryPlaneLettersKeepEditionsApart() {
val cloud = XboxCloudCatalog(gamePass = setOf(game, parent), all = setOf(game, parent))
val first = XboxCatalog.product(product(game, "Xbox.One"), mapOf(game to "gamepass"), cloud)!!.copy(title = "\uD840\uDC00 2")
val second = XboxCatalog.product(product(parent, "Xbox.One"), mapOf(parent to "gamepass"), cloud)!!.copy(title = "\uD840\uDC01 2")
assertEquals(2, mergeEditions(listOf(first, second)).size)
}
}
@@ -46,4 +46,11 @@ class XboxCloudTest {
@Test fun cloudLaunchUrlUsesTheStreamingEdition() {
assertEquals("https://www.xbox.com/play/launch/ball-x-pit/9BBBBBBBBBBB", XboxCatalog.cloudUrl("9AAAAAAAAAAA", "BALL x PIT", "9BBBBBBBBBBB"))
}
@Test fun titleNameKeyDropsEditionWords() {
assertEquals("FORZAHORIZON6", XboxCloudSession.nameKey("Forza Horizon 6 Standard Edition"))
assertEquals("FORTNITE", XboxCloudSession.nameKey("Fortnite"))
assertEquals("HALOINFINITE", XboxCloudSession.nameKey("Halo Infinite (Xbox Series X|S)"))
assertEquals("STARFIELD", XboxCloudSession.nameKey("Starfield Premium Edition for Windows"))
}
}
@@ -682,6 +682,10 @@ def guest_environment(fex, env):
if "aarch64" in result.get("GCONV_PATH", ""):
result["GCONV_PATH"] = ""
result.setdefault("GC_DISABLE_INCREMENTAL", "1")
if not result.get("COMPlus_INTERNAL_ThreadSuspendInjection"):
if not result.get("DOTNET_INTERNAL_ThreadSuspendInjection"):
result["DOTNET_INTERNAL_ThreadSuspendInjection"] = "0"
result["COMPlus_INTERNAL_ThreadSuspendInjection"] = result["DOTNET_INTERNAL_ThreadSuspendInjection"]
if fex["portable"]:
result["FEX_PORTABLE"] = "1"
else:
@@ -778,7 +778,7 @@ case $mode in
for _d in /proc/[0-9]*; do
[ "${_d##*/}" != "$BASHPID" ] || continue
_args=()
while IFS= read -r -d '' _c; do _args+=("$_c"); done 2>/dev/null < "$_d/cmdline" || true
mapfile -d '' -t _args 2>/dev/null < "$_d/cmdline" || true
[ "${#_args[@]}" -gt 0 ] || continue
_name=${_args[0]} _fex=0
if [ "${#_args[@]}" -gt 1 ]; then
+12 -1
View File
@@ -1161,9 +1161,20 @@ class LaunchTest(FexTestCase):
self.assertTrue(guest["FEX_APP_CONFIG_LOCATION"].endswith("/config/"))
self.assertEqual((guest["FEX_SILENTLOG"], guest["FEX_OUTPUTLOG"]), ("0", "stderr"))
self.assertEqual(guest["GC_DISABLE_INCREMENTAL"], "1")
self.assertEqual(guest["DOTNET_INTERNAL_ThreadSuspendInjection"], "0")
self.assertEqual(guest["COMPlus_INTERNAL_ThreadSuspendInjection"], "0")
legacy = FEX["guest_environment"]({"portable": False}, {"COMPlus_INTERNAL_ThreadSuspendInjection": "1"})
self.assertEqual(legacy["COMPlus_INTERNAL_ThreadSuspendInjection"], "1")
self.assertNotIn("DOTNET_INTERNAL_ThreadSuspendInjection", legacy)
blank = FEX["guest_environment"]({"portable": False}, {"COMPlus_INTERNAL_ThreadSuspendInjection": "",
"DOTNET_INTERNAL_ThreadSuspendInjection": ""})
self.assertEqual(blank["DOTNET_INTERNAL_ThreadSuspendInjection"], "0")
self.assertEqual(blank["COMPlus_INTERNAL_ThreadSuspendInjection"], "0")
guest = FEX["guest_environment"]({"portable": False}, {"LD_PRELOAD": str(arm), "FEX_PORTABLE": "1", "FEX_OUTPUTLOG": "/tmp/fex.log",
"GC_DISABLE_INCREMENTAL": "0"})
"GC_DISABLE_INCREMENTAL": "0", "DOTNET_INTERNAL_ThreadSuspendInjection": "1"})
self.assertEqual((guest["FEX_OUTPUTLOG"], guest["GC_DISABLE_INCREMENTAL"]), ("/tmp/fex.log", "0"))
self.assertEqual(guest["DOTNET_INTERNAL_ThreadSuspendInjection"], "1")
self.assertEqual(guest["COMPlus_INTERNAL_ThreadSuspendInjection"], "1")
self.assertNotIn("LD_PRELOAD", guest)
self.assertNotIn("FEX_PORTABLE", guest)