[AGS] Fix Bluetooth crashes

This commit is contained in:
2025-04-26 09:38:15 +02:00
parent 33fcdd72f7
commit e19a1179d5
9 changed files with 54 additions and 35 deletions

View File

@@ -114,15 +114,26 @@ const openBTPicker = () => {
};
const BluetoothPickerList = () => {
let btEnableState = readFile("./btconf") === "true" ? true : false;
let btEnableState = false;
try {
btEnableState = readFile("./btconf") === "true" ? true : false;
} catch (_) { }
if (bt.get_adapter()) {
print( 'Setting BT state to ' + btEnableState );
print('Setting BT state to ' + btEnableState);
bt.adapter.set_powered(btEnableState);
} else {
timeout(5000, () => {
if (bt.get_adapter()) {
print( 'Setting BT state to ' + btEnableState );
print('Setting BT state to ' + btEnableState);
bt.adapter.set_powered(btEnableState);
} else {
timeout(5000, () => {
try {
bt.adapter.set_powered(btEnableState);
} catch (_) { }
})
}
})
}