mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 15:26:04 +00:00
fix(xbox): read a GameCore package from its config beside the generated AppxManifest (#3029)
This commit is contained in:
1 parent
5df25c77ca
commit
f683e97172
3 files changed
+34
-3
No files matched your search
@@ -103,7 +103,9 @@ internal class XboxInstaller(private val app: Context, private val item: Catalog
|
||||
XboxContent.complete(app, item, folder)
|
||||
return folder.path
|
||||
}
|
||||
val exe = executable(folder)
|
||||
val exe = runCatching { executable(folder) }.onFailure {
|
||||
StoresState.logLine("Xbox: install folder holds ${folder.list().orEmpty().sorted().take(MAX_ERROR_LINES).joinToString()}")
|
||||
}.getOrThrow()
|
||||
StoreInstalls.complete(app, folder, StoreGameSidecar(Store.XBOX, item.id, item.title, exe,
|
||||
installVersion = XboxManifest.read(folder).version, installedAt = System.currentTimeMillis(), cover = item.tallImageUrl, hero = item.imageUrl,
|
||||
extra = item.extra + mapOf("contentId" to selected, "market" to market)))
|
||||
|
||||
@@ -21,8 +21,9 @@ internal object XboxManifest {
|
||||
val files = folder.listFiles().orEmpty()
|
||||
val config = files.filter { it.name.equals(GAME_CONFIG, true) && it.isFile }
|
||||
val legacy = files.filter { it.name.equals(APPX_MANIFEST, true) && it.isFile }
|
||||
require(config.size + legacy.size == 1) { "Missing or ambiguous game manifest." }
|
||||
val manifest = (config + legacy).single()
|
||||
val manifests = config.ifEmpty { legacy }
|
||||
require(manifests.size == 1) { "Missing or ambiguous game manifest." }
|
||||
val manifest = manifests.single()
|
||||
val rootTag = if (config.isEmpty()) "Package" else "Game"
|
||||
require(manifest.length() <= 1_048_576)
|
||||
val parser = android.util.Xml.newPullParser().apply { setFeature(XmlPullParser.FEATURE_PROCESS_DOCDECL, false) }
|
||||
|
||||
@@ -87,6 +87,34 @@ class XboxManifestTest {
|
||||
assertEquals(listOf("Retail.exe"), info.executables)
|
||||
assertEquals("Retail.exe", XboxManifest.executable(root))
|
||||
}
|
||||
@Test fun aGameCorePackageIsReadFromItsConfigBesideTheGeneratedAppxManifest() {
|
||||
val root = temporary.newFolder()
|
||||
java.io.File(root, "Game.exe").writeText("encrypted")
|
||||
java.io.File(root, "Other.exe").writeText("encrypted")
|
||||
java.io.File(root, "MicrosoftGame.config").writeText("""<Game configVersion="1"><Identity Name="Test.Game" Publisher="CN=Test" Version="1.2.3.0"/>
|
||||
<ExecutableList><Executable Name="Game.exe" TargetDeviceFamily="PC"/></ExecutableList><StoreId>9AAAAAAAAAAA</StoreId></Game>""")
|
||||
java.io.File(root, "appxmanifest.xml").writeText("""<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10">
|
||||
<Identity Name="Generated.Game" Publisher="CN=Generated" Version="9.9.9.0"/>
|
||||
<Applications><Application Id="Game" Executable="Other.exe" EntryPoint="Game.App"/></Applications></Package>""")
|
||||
val info = XboxManifest.read(root)
|
||||
assertEquals("Test.Game", info.name)
|
||||
assertEquals("1.2.3.0", info.version)
|
||||
assertEquals("9AAAAAAAAAAA", info.storeId)
|
||||
assertEquals("Game.exe", XboxInstaller.executable(root))
|
||||
assertFalse(XboxManifest.needsAppModel(root))
|
||||
}
|
||||
@Test fun aFolderWithoutOneManifestIsStillRefused() {
|
||||
val empty = temporary.newFolder()
|
||||
java.io.File(empty, "Game.exe").writeText("encrypted")
|
||||
assertThrows(IllegalArgumentException::class.java) { XboxManifest.read(empty) }
|
||||
val twice = temporary.newFolder()
|
||||
java.io.File(twice, "Game.exe").writeText("encrypted")
|
||||
java.io.File(twice, "MicrosoftGame.config").writeText("<Game><Executable Name=\"Game.exe\"/></Game>")
|
||||
java.io.File(twice, "microsoftgame.CONFIG").writeText("<Game><Executable Name=\"Game.exe\"/></Game>")
|
||||
org.junit.Assume.assumeTrue(twice.list().orEmpty().size == 3)
|
||||
assertThrows(IllegalArgumentException::class.java) { XboxManifest.read(twice) }
|
||||
}
|
||||
@Test fun legacyPackageManifestNamesItsExecutableTheSameWay() {
|
||||
// A legacy EAppx package carries AppxManifest.xml and has no config; the
|
||||
// launcher must still find the identity and the launch path, or an install
|
||||
|
||||
Reference in new issue
Block a user