From 9fd358deef4e0cbe65ff0e910a79be4fbda9c519 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Thu, 21 May 2026 16:41:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(sdk-license):=20HTTP=20=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=B8=8D=E5=9B=9E=E9=80=80=E7=BC=93=E5=AD=98=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E5=B7=B2=E5=90=8A=E9=94=80=E8=AE=BE=E5=A4=87=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit verify 返回 false 后 SDK 会尝试 register,服务端对已吊销设备返回 403。 原 catch 块将 HttpException 与网络错误同等处理,导致 cachedStatus=="ok" 时依然返回 Success。修复:HttpException(4xx/5xx)直接写入 DENIED, 只有真正的网络错误(IOException/超时)才允许离线缓存回退。 Co-Authored-By: Claude Sonnet 4.6 --- .../src/main/java/com/xuqm/sdk/license/LicenseSDK.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk-license/src/main/java/com/xuqm/sdk/license/LicenseSDK.kt b/sdk-license/src/main/java/com/xuqm/sdk/license/LicenseSDK.kt index 2635886..4126b39 100644 --- a/sdk-license/src/main/java/com/xuqm/sdk/license/LicenseSDK.kt +++ b/sdk-license/src/main/java/com/xuqm/sdk/license/LicenseSDK.kt @@ -15,6 +15,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import retrofit2.HttpException object LicenseSDK { @@ -147,10 +148,12 @@ object LicenseSDK { persistStatus(STATUS_DENIED) return@withContext LicenseResult.Error(result.data?.message ?: "Registration denied") } catch (e: Exception) { - // Network error: use cached status if available - if (cachedStatus == STATUS_OK) { + // HTTP errors (4xx/5xx) are explicit server rejections — never fall back to cache. + // Only genuine network errors (IOException, timeout) allow the offline cache path. + if (e !is HttpException && cachedStatus == STATUS_OK) { return@withContext LicenseResult.Success("Offline - using cached status") } + persistStatus(STATUS_DENIED) return@withContext LicenseResult.Error(e.message ?: "Network error") } }