fix(update): surface API errors instead of silently returning null
- Log exception details (url/appKey/versionCode/userId) when checkUpdate fails - Log warning + debug messages around awaitInitialization - Helps diagnose SDK vs old private-server API incompatibilities Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
父节点
e10deeb4ff
当前提交
a574ecdead
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.core.content.FileProvider
|
||||
import com.xuqm.sdk.XuqmSDK
|
||||
import com.xuqm.sdk.file.FileSDK
|
||||
@ -152,6 +153,7 @@ object UpdateSDK {
|
||||
packageInfo.versionCode
|
||||
}
|
||||
val userId = resolveUserId()
|
||||
val url = ServiceEndpointRegistry.updateBaseUrl
|
||||
runCatching {
|
||||
api.checkUpdate(XuqmSDK.appKey, "ANDROID", versionCode, userId).data?.let { info ->
|
||||
val normalized = info.copy(downloadUrl = normalizeDownloadUrl(info.downloadUrl) ?: info.downloadUrl)
|
||||
@ -171,16 +173,24 @@ object UpdateSDK {
|
||||
afterIgnore
|
||||
}
|
||||
}
|
||||
}.onFailure { e ->
|
||||
Log.e("UpdateSDK", "checkUpdate failed [url=$url appKey=${XuqmSDK.appKey} versionCode=$versionCode userId=$userId]: ${e.message}", e)
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
private suspend fun awaitInitialization() {
|
||||
if (XuqmSDK.isInitialized()) return
|
||||
Log.w("UpdateSDK", "XuqmSDK not yet initialized, waiting up to 15s...")
|
||||
kotlinx.coroutines.withTimeoutOrNull(15_000L) {
|
||||
while (!XuqmSDK.isInitialized()) {
|
||||
kotlinx.coroutines.delay(100)
|
||||
}
|
||||
} ?: throw IllegalStateException("XuqmSDK not initialized. Check that config.xuqm is present and valid.")
|
||||
} ?: run {
|
||||
val msg = "XuqmSDK init timeout (15s). Check that config.xuqm is present and package name matches."
|
||||
Log.e("UpdateSDK", msg)
|
||||
throw IllegalStateException(msg)
|
||||
}
|
||||
Log.d("UpdateSDK", "XuqmSDK initialized, proceeding with update check")
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户