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:
@@ -84,14 +84,20 @@ fun DemoScreen(
|
|||||||
var otaFetchVersion by remember(sdk) { mutableStateOf("") }
|
var otaFetchVersion by remember(sdk) { mutableStateOf("") }
|
||||||
var otaFetchUserId by remember(sdk) { mutableStateOf("") }
|
var otaFetchUserId by remember(sdk) { mutableStateOf("") }
|
||||||
|
|
||||||
// bind 完成 → 回填 OTA 入参
|
// 进入页面初次填充(对齐 iOS WrapperTestView onAppear)
|
||||||
LaunchedEffect(isActivated, sn) {
|
LaunchedEffect(sdk) {
|
||||||
if (isActivated && sn.isNotEmpty()) {
|
if (otaFetchSn.isEmpty()) otaFetchSn = sn
|
||||||
otaFetchSn = sn
|
if (otaFetchVersion.isEmpty()) otaFetchVersion = version
|
||||||
if (version.isNotEmpty()) otaFetchVersion = version
|
|
||||||
if (otaFetchUserId.isEmpty()) otaFetchUserId = userId
|
if (otaFetchUserId.isEmpty()) otaFetchUserId = userId
|
||||||
}
|
}
|
||||||
|
// bind 完成 → 自动回填 sn / currentVersion(对齐 iOS onChange isActivated)
|
||||||
|
LaunchedEffect(isActivated) {
|
||||||
|
if (isActivated) {
|
||||||
|
otaFetchSn = sn
|
||||||
|
otaFetchVersion = version
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// getVersion 单独触发时也同步过来
|
||||||
LaunchedEffect(version) {
|
LaunchedEffect(version) {
|
||||||
if (version.isNotEmpty()) otaFetchVersion = version
|
if (version.isNotEmpty()) otaFetchVersion = version
|
||||||
}
|
}
|
||||||
@@ -605,7 +611,11 @@ private fun ConfigField(label: String, value: String, onChange: (String) -> Unit
|
|||||||
onValueChange = onChange,
|
onValueChange = onChange,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
singleLine = true,
|
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
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,11 +100,12 @@ class DuooomiBleSDK(context: Context, val config: DuooomiBleConfig) {
|
|||||||
_deviceInfo.value = null
|
_deviceInfo.value = null
|
||||||
_version.value = ""
|
_version.value = ""
|
||||||
_isActivated.value = false
|
_isActivated.value = false
|
||||||
_sn.value = ""
|
|
||||||
_firmwareUpgrade.value = null
|
|
||||||
_btState.value = ConnectionState.DISCONNECTED
|
_btState.value = ConnectionState.DISCONNECTED
|
||||||
protocolService.stopListening()
|
protocolService.stopListening()
|
||||||
cancelAllPending(DuooomiBleError.NotConnected)
|
cancelAllPending(DuooomiBleError.NotConnected)
|
||||||
|
// 与 iOS 一致:sn / firmwareUpgrade 不在断开时重置
|
||||||
|
// —— sn 仅在 unbind 成功 / fetchLatestFirmware 软绑失败回滚时清空
|
||||||
|
// —— firmwareUpgrade 仅在 fetchLatestFirmware 成功时覆盖
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,8 +199,6 @@ class DuooomiBleSDK(context: Context, val config: DuooomiBleConfig) {
|
|||||||
_deviceInfo.value = null
|
_deviceInfo.value = null
|
||||||
_version.value = ""
|
_version.value = ""
|
||||||
_isActivated.value = false
|
_isActivated.value = false
|
||||||
_sn.value = ""
|
|
||||||
_firmwareUpgrade.value = null
|
|
||||||
_btState.value = ConnectionState.DISCONNECTED
|
_btState.value = ConnectionState.DISCONNECTED
|
||||||
BleLog.i("Disconnected", "Connect")
|
BleLog.i("Disconnected", "Connect")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user