fix(android): APK包名统一gca-v0.1.0 + 应用名加版本 + Gitea manifest联调
- APK: app-debug.apk → gca-v0.1.0-debug.apk - App名: Yuzu GCA Test → Yuzu GCA v0.1.0 - MainActivity: 真实manifest拉取+JSON解析+SHA256真实比对 - Gitea Release #6: gca-v0.1.0.apk + manifest.json - 删除旧Expo modules/ 文件
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,8 @@
|
||||
apply plugin: "com.android.application"
|
||||
apply plugin: "org.jetbrains.kotlin.android"
|
||||
|
||||
archivesBaseName = "gca-v0.1.0"
|
||||
|
||||
android {
|
||||
namespace "dev.yuzu.gca"
|
||||
compileSdk 35
|
||||
@@ -9,7 +11,7 @@ android {
|
||||
applicationId "dev.yuzu.gca"
|
||||
minSdk 24
|
||||
targetSdk 35
|
||||
versionCode 5
|
||||
versionCode 6
|
||||
versionName "0.1.0"
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<application
|
||||
android:label="Yuzu GCA Test"
|
||||
android:label="Yuzu GCA v0.1.0"
|
||||
android:allowBackup="false"
|
||||
android:supportsRtl="true"
|
||||
android:usesCleartextTraffic="true"
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="Yuzu GCA Test"
|
||||
android:label="Yuzu GCA v0.1.0"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -60,7 +60,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
appendLog("[1/4] 拉取 manifest...")
|
||||
try {
|
||||
val manifestJson = httpGet("https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/releases/download/manifest/manifest.json")
|
||||
val manifestJson = httpGet("https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/releases/download/v0.1.0-dav-android-6/manifest.json")
|
||||
appendLog(" manifest: ${manifestJson.take(200)}...")
|
||||
} catch (e: Exception) {
|
||||
appendLog(" ⚠️ 网络不可用: ${e.message}")
|
||||
@@ -69,25 +69,50 @@ class MainActivity : AppCompatActivity() {
|
||||
return@withContext
|
||||
}
|
||||
|
||||
appendLog("[2/4] 解析版本")
|
||||
appendLog(" 远程: v0.2.0-dav-android-1 > 本地: 0.1.0 → 需要更新 ✅")
|
||||
appendLog("[2/4] 解析 manifest JSON...")
|
||||
var manifestSha256 = ""
|
||||
var manifestApkUrl = ""
|
||||
try {
|
||||
val manifestJson = httpGet("https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/releases/download/v0.1.0-dav-android-6/manifest.json")
|
||||
// 简易 JSON 解析(不用 Gson,直接字符串提取)
|
||||
val sha256Field = "\"sha256\": \""
|
||||
val sha256Start = manifestJson.indexOf(sha256Field) + sha256Field.length
|
||||
val sha256End = manifestJson.indexOf("\"", sha256Start)
|
||||
manifestSha256 = manifestJson.substring(sha256Start, sha256End)
|
||||
|
||||
appendLog("[3/4] 下载 APK...")
|
||||
val urlField = "\"url\": \""
|
||||
val urlStart = manifestJson.indexOf(urlField) + urlField.length
|
||||
val urlEnd = manifestJson.indexOf("\"", urlStart)
|
||||
manifestApkUrl = manifestJson.substring(urlStart, urlEnd)
|
||||
|
||||
appendLog(" SHA256: ${manifestSha256.take(16)}...")
|
||||
appendLog(" APK URL: ${manifestApkUrl.take(50)}...")
|
||||
appendLog(" 需要更新 ✅")
|
||||
} catch (e: Exception) {
|
||||
appendLog(" ⚠️ manifest 解析失败: ${e.message}")
|
||||
appendLog("=== OTA 测试中止 ===")
|
||||
return@withContext
|
||||
}
|
||||
|
||||
appendLog("[3/4] 下载 APK: ${manifestApkUrl.take(40)}...")
|
||||
val apkFile = File(cacheDir, "test-update.apk")
|
||||
try {
|
||||
val apkUrl = "https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/releases/download/v0.1.0-dav-android-1/app-debug.apk"
|
||||
downloadFile(apkUrl, apkFile)
|
||||
appendLog(" 下载完成: ${apkFile.length()} bytes")
|
||||
downloadFile(manifestApkUrl, apkFile)
|
||||
appendLog(" 下载完成: ${apkFile.length()} bytes ✅")
|
||||
} catch (e: Exception) {
|
||||
appendLog(" ⚠️ APK未上传: ${e.message}")
|
||||
appendLog(" 但下载+校验代码路径已验证")
|
||||
appendLog(" ❌ 下载失败: ${e.message}")
|
||||
return@withContext
|
||||
}
|
||||
|
||||
appendLog("[4/4] SHA256 校验...")
|
||||
if (apkFile.exists()) {
|
||||
val sha256 = computeSha256(apkFile)
|
||||
appendLog(" SHA256: $sha256")
|
||||
appendLog(" ✅ 校验通过(原始字节计算,与Kotlin MessageDigest一致)")
|
||||
val actualSha256 = computeSha256(apkFile)
|
||||
if (actualSha256 == manifestSha256) {
|
||||
appendLog(" ✅ SHA256 校验通过!")
|
||||
appendLog(" ${actualSha256.take(32)}...")
|
||||
} else {
|
||||
appendLog(" ❌ SHA256 校验失败!")
|
||||
appendLog(" 期望: ${manifestSha256.take(32)}...")
|
||||
appendLog(" 实际: ${actualSha256.take(32)}...")
|
||||
}
|
||||
|
||||
appendLog("=== OTA 测试完成 ===")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Yuzu GCA</string>
|
||||
<string name="app_name">Yuzu GCA v0.1.0</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user