feat: OTA四层架构 — manifest.json统一+渠道默认stable
- manifest.json: stable/beta/nightly三渠道H5+APK统一 - version.txt: 指向manifest.json URL - v5嵌入页: channel默认stable, localStorage.channel可切换 - Bridge.fetchManifest: 自动读manifest.json解析对应渠道 - index-stable/beta/nightly: 业务页(开发期beta/nightly→stable) - 删除旧版index-v6/v7 - 构建成功
This commit is contained in:
Binary file not shown.
@@ -62,21 +62,21 @@ class MainActivity : AppCompatActivity() {
|
||||
return digest.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
/** Fetch manifest JSON from Gitea — proxy to avoid CORS in WebView */
|
||||
/** Fetch manifest JSON from Gitea and return channel's section */
|
||||
@android.webkit.JavascriptInterface
|
||||
fun fetchManifest(channel: String): String {
|
||||
val url = "https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5-manifest-$channel.json"
|
||||
Log.i(TAG, "Bridge fetching $url")
|
||||
val manifestUrl = "https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/manifest.json"
|
||||
Log.i(TAG, "Bridge fetching $manifestUrl → $channel")
|
||||
return try {
|
||||
val conn = URL(url).openConnection() as HttpURLConnection
|
||||
conn.connectTimeout = 10_000
|
||||
conn.readTimeout = 10_000
|
||||
val conn = URL(manifestUrl).openConnection() as HttpURLConnection
|
||||
conn.connectTimeout = 10_000; conn.readTimeout = 10_000
|
||||
conn.instanceFollowRedirects = true
|
||||
val code = conn.responseCode
|
||||
if (code != 200) throw Exception("HTTP $code")
|
||||
conn.inputStream.bufferedReader().readText()
|
||||
if (conn.responseCode != 200) throw Exception("HTTP ${conn.responseCode}")
|
||||
val raw = conn.inputStream.bufferedReader().readText()
|
||||
val json = org.json.JSONObject(raw)
|
||||
json.getJSONObject(channel).toString()
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Bridge fetch failed: ${e.message}")
|
||||
Log.e(TAG, "Bridge fetchManifest($channel) failed: ${e.message}")
|
||||
"""{"error":"${e.message}"}"""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user