fix: use Blizzard's China hosts for Battle.net installs and update checks

The Agent's install request pointed at http://cn.patch.battle.net:1119/<product>.
That host only 301-redirects to the country's version service today; Blizzard's
China client asks cn.patch.battlenet.com.cn:1119 directly.

The update check built <branch>.version.battle.net, so a China install (branch
cn) asked cn.version.battle.net, which does not answer; the China service is
cn.version.battlenet.com.cn.

Only region cn changes.
This commit is contained in:
visail authored and Kurt Himebauch committed 2026-11-05 09:56:40 -05:00
1 parent 26c562c174
commit a0a7a66470
4 files changed
+20 -3

No files matched your search

@@ -34,11 +34,16 @@ object BattleNetInstall {
internal const val STATE = "BNET_STATE "
internal const val DONE = "BNET_DONE "
internal const val ERROR = "BNET_ERROR "
private const val VERSIONS = "https://%s.version.battle.net/v2/products/%s/versions"
private const val CN = "cn"
private const val BUILD_INFO = ".build.info"
private const val CHECK_AGAIN_MS = 30 * 60_000L
private const val START_WAIT_MS = 60_000L
/** Blizzard serves China from battlenet.com.cn; its global version hostnames do not answer for that region. */
internal fun versionsUrl(region: String, product: String): String =
"https://" + (if (region == CN) "cn.version.battlenet.com.cn" else "$region.version.battle.net") +
"/v2/products/$product/versions"
internal val LOCALES = listOf(
"enUS", "enGB", "esMX", "esES", "ptBR", "ptPT", "frFR", "deDE", "itIT", "ruRU", "jaJP", "koKR", "plPL", "trTR",
"zhTW", "zhCN", "thTH", "arSA",
@@ -187,7 +192,7 @@ object BattleNetInstall {
checks.execute {
val local = runCatching { buildKey(File(folder, BUILD_INFO).readText()) }.getOrNull()
?: return@execute retryLater()
val latest = runCatching { latestBuild(fetch(VERSIONS.format(Locale.ROOT, local.first, product)), local.first) }
val latest = runCatching { latestBuild(fetch(versionsUrl(local.first, product)), local.first) }
.onFailure { Log.w(TAG, "versions of $product: ${it.javaClass.simpleName}") }.getOrNull()
?: return@execute retryLater()
val behind = latest != local.second