diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet index 0f426d9029..be1dfb6a18 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet @@ -135,6 +135,9 @@ function job(text) { return /"state"\s*:\s*\d+/.test(bare) || /"download_current"\s*:/.test(bare); } +var CHINA = {osi: "osic", s2: "s2_cn", anbs: "anbs_cn", diablo3: "d3cn"}; +var CHINA_PRODUCT = {osi: "osic", s2: "s2c", diablo3: "d3cn"}; + function install() { // Blizzard's China repository moved to cn.patch.battlenet.com.cn; cn.patch.battle.net only redirects away from it. var patch = zone == "cn" ? "cn.patch.battlenet.com.cn" : zone + ".patch.battle.net"; @@ -193,6 +196,15 @@ try { token = field(agent, "authorization"); zone = field(agent, "region") || "us"; if (!token) throw new Error("no authorization from the agent"); + // The China client installs these under uids of its own. s2_cn is served from s2c; anbs_cn shares anbs. + if (zone == "cn" && action == "install") { + country = "CHN"; + region = "CN"; + if (CHINA[uid]) { + product = CHINA_PRODUCT[uid] || product; + uid = CHINA[uid]; + } + } if (action == "install") install(); else if (action == "update") update(); else uninstall(); } catch (e) { save(".error", e.message || "the agent stopped answering"); diff --git a/tools/tests/test_battlenet.py b/tools/tests/test_battlenet.py index 06fdc779c4..8c737699ea 100644 --- a/tools/tests/test_battlenet.py +++ b/tools/tests/test_battlenet.py @@ -1493,6 +1493,14 @@ class AgentTest(Temp): self.assertIn('var patch = zone == "cn" ? "cn.patch.battlenet.com.cn" : zone + ".patch.battle.net";', script) self.assertIn("+ patch + ':1119/'", script) + def test_the_driver_installs_chinas_products_under_their_own_uids(self): + script = BNET["AGENT_SCRIPT"] + self.assertIn('var CHINA = {osi: "osic", s2: "s2_cn", anbs: "anbs_cn", diablo3: "d3cn"};', script) + self.assertIn('var CHINA_PRODUCT = {osi: "osic", s2: "s2c", diablo3: "d3cn"};', script) + self.assertIn('if (zone == "cn" && action == "install") {', script) + self.assertIn('country = "CHN";', script) + self.assertIn('region = "CN";', script) + class AgentJobTest(Harness): def setUp(self):