Skip to content

Commit ceb9bb0

Browse files
committed
fix: android 14 ble pair
1 parent 16c20bf commit ceb9bb0

File tree

1 file changed

+16
-4
lines changed
  • packages/hd-transport-react-native/src

1 file changed

+16
-4
lines changed

packages/hd-transport-react-native/src/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import {
1919
isOnekeyDevice,
2020
} from '@onekeyfe/hd-shared';
2121
import type EventEmitter from 'events';
22-
import { getConnectedDeviceIds, onDeviceBondState, pairDevice } from './BleManager';
22+
import {
23+
getConnectedDeviceIds,
24+
onDeviceBondState,
25+
pairDevice,
26+
getBondedDevices,
27+
} from './BleManager';
2328
import { subscribeBleOn } from './subscribeBleOn';
2429
import {
2530
getBluetoothServiceUuids,
@@ -260,9 +265,16 @@ export default class ReactNativeBleTransport {
260265

261266
// check device is bonded
262267
if (Platform.OS === 'android') {
263-
const bondState = await pairDevice(uuid);
264-
if (bondState.bonding) {
265-
await onDeviceBondState(uuid);
268+
const bondedDevices = await getBondedDevices();
269+
const existsBondedList = bondedDevices.find(
270+
device => device.id.toLowerCase() === uuid.toLowerCase()
271+
);
272+
273+
if (!existsBondedList) {
274+
const bondState = await pairDevice(uuid);
275+
if (bondState.bonding) {
276+
await onDeviceBondState(uuid);
277+
}
266278
}
267279
}
268280

0 commit comments

Comments
 (0)