Browse Source

上传绑定扫描优化

weicu
liwei1dao 1 year ago
parent
commit
9e48b4c67d
  1. 3
      lib/modules/pairing/controllers/pairing_controller.dart
  2. 1
      local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleServicePlugin.kt

3
lib/modules/pairing/controllers/pairing_controller.dart

@ -807,13 +807,12 @@ class PairingController extends GetxController with WidgetsBindingObserver {
} }
} else { } else {
//未绑定设备 //未绑定设备
_bleManager.clearPairedDevices();
Logger.i(_tag, '验证时BLE状态: $currentBleState'); Logger.i(_tag, '验证时BLE状态: $currentBleState');
if (currentBleState == 2) { if (currentBleState == 2) {
//已连接 清理 //已连接 清理
// BleConnectionState.connected // BleConnectionState.connected
Logger.i(_tag, 'BLE已连接,断开并清理缓存'); Logger.i(_tag, 'BLE已连接,断开并清理缓存');
_bleManager.clearPairedDevices();
_bleManager.disconnect(); _bleManager.disconnect();
} }
} }

1
local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleServicePlugin.kt

@ -304,6 +304,7 @@ class BleServicePlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
} }
"clearAssociations" -> { "clearAssociations" -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
bleCompanionManager.unregisterBackgroundScan() //停止后台扫描
bleCompanionManager.clearPairedMacAddress() bleCompanionManager.clearPairedMacAddress()
result.success(true) result.success(true)
} else { } else {

Loading…
Cancel
Save