fix: 流程对齐 iOS 严格 1:1(disconnect 不清 sn/firmwareUpgrade)

发现并修正以下 1:1 复刻偏离:

1. SDK:disconnect 行为
   - iOS:被动断开 / 主动 disconnect 都 **不清** sn / firmwareUpgrade
     · sn 仅在 unbind 成功 / fetchLatestFirmware 软绑失败回滚时清空
     · firmwareUpgrade 仅在 fetchLatestFirmware 成功时覆盖
   - 之前 Android 在两个 disconnect 入口都清,与 iOS 不一致;现已修正

2. Demo:otaFetchUserId / otaFetchSn 进入页面时的初始化
   - iOS:onAppear 时同步默认 userId / 当前 sdk.sn 到字段
   - Android:之前 bind 后才填,进入页面默认空;现已与 iOS 对齐

3. Demo:ConfigField 禁用自动大写 / 自动纠错
   - iOS 用 .autocapitalization(.none).disableAutocorrection(true)
   - Android 加 KeyboardOptions(autoCorrect=false, capitalization=None)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
km2023
2026-05-08 16:38:37 +08:00
parent 417012c49f
commit 0dbfab9519
2 changed files with 19 additions and 10 deletions

View File

@@ -84,14 +84,20 @@ fun DemoScreen(
var otaFetchVersion by remember(sdk) { mutableStateOf("") }
var otaFetchUserId by remember(sdk) { mutableStateOf("") }
// bind 完成 → 回填 OTA 入参
LaunchedEffect(isActivated, sn) {
if (isActivated && sn.isNotEmpty()) {
// 进入页面初次填充(对齐 iOS WrapperTestView onAppear
LaunchedEffect(sdk) {
if (otaFetchSn.isEmpty()) otaFetchSn = sn
if (otaFetchVersion.isEmpty()) otaFetchVersion = version
if (otaFetchUserId.isEmpty()) otaFetchUserId = userId
}
// bind 完成 → 自动回填 sn / currentVersion对齐 iOS onChange isActivated
LaunchedEffect(isActivated) {
if (isActivated) {
otaFetchSn = sn
if (version.isNotEmpty()) otaFetchVersion = version
if (otaFetchUserId.isEmpty()) otaFetchUserId = userId
otaFetchVersion = version
}
}
// getVersion 单独触发时也同步过来
LaunchedEffect(version) {
if (version.isNotEmpty()) otaFetchVersion = version
}
@@ -605,7 +611,11 @@ private fun ConfigField(label: String, value: String, onChange: (String) -> Unit
onValueChange = onChange,
modifier = Modifier.weight(1f),
singleLine = true,
textStyle = androidx.compose.ui.text.TextStyle(fontSize = 12.sp)
textStyle = androidx.compose.ui.text.TextStyle(fontSize = 12.sp),
keyboardOptions = androidx.compose.foundation.text.KeyboardOptions(
autoCorrect = false,
capitalization = androidx.compose.ui.text.input.KeyboardCapitalization.None
)
)
}
}