!636 [Bug]: 搜索的蓝牙列表中部分设备显示mac地址,不显示设备名称

Merge pull request !636 from 宝宝爱晓梅/master
This commit is contained in:
openharmony_ci 2024-04-03 03:57:26 +00:00 committed by Gitee
commit 00e888e8b2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -306,9 +306,25 @@ export default class BluetoothDeviceController extends BaseSettingsController {
} else {
LogUtil.log(this.TAG + 'available bluetooth new device found. availableDevices length = ' + this.availableDevices.length);
let newDevice = this.getDevice(deviceId);
this.availableDevices.push(newDevice);
if (!!newDevice.deviceName) {
this.availableDevices.push(newDevice);
}
LogUtil.log(this.TAG + 'available bluetooth new device pushed. availableDevices length = ' + this.availableDevices.length);
}
} else {
LogUtil.log(this.TAG + 'bluetooth already exist!');
let indexDeviceID = 0;
for (let i = 0; i < this.availableDevices.length; i++) {
if (this.availableDevices[i].deviceId === deviceId) {
indexDeviceID = i;
break;
}
}
let existDevice = this.getDevice(deviceId);
if(existDevice.deviceName !== this.availableDevices[indexDeviceID].deviceName){
this.availableDevices.splice(indexDeviceID,1,existDevice);
}
}
})
AppStorage.SetOrCreate('bluetoothAvailableDevices', this.availableDevices);