UI support to cleanup bluetooth bonded devices (#757)

Signed-off-by: Jussi Vatjus-Anttila <jussiva@gmail.com>
This commit is contained in:
Jussi Vatjus-Anttila
2024-01-30 01:38:54 +02:00
committed by GitHub
parent c481720dd7
commit 806bfa4087
7 changed files with 61 additions and 0 deletions

View File

@@ -51,4 +51,24 @@ module.exports = syrup.serial()
])
})
})
router.on(wire.BluetoothCleanBondedMessage, function(channel) {
var reply = wireutil.reply(options.serial)
log.info('Clean bonded Bluetooth devices')
service.cleanupBondedBluetoothDevices()
.timeout(30000)
.then(function() {
push.send([
channel
, reply.okay()
])
})
.catch(function(err) {
log.error('Cleaning Bluetooth bonded devices failed', err.stack)
push.send([
channel
, reply.fail(err.message)
])
})
})
})

View File

@@ -612,6 +612,21 @@ module.exports = syrup.serial()
})
}
plugin.cleanupBondedBluetoothDevices = function() {
return runServiceCommand(
apk.wire.MessageType.DO_CLEAN_BLUETOOTH_BONDED_DEVICES
, new apk.wire.DoCleanBluetoothBondedDevicesRequest()
)
.timeout(15000)
.then(function(data) {
var response = apk.wire.DoCleanBluetoothBondedDevicesResponse.decode(data)
if (response.success) {
return true
}
throw new Error('Unable to clean bluetooth bonded devices')
})
}
plugin.setRingerMode = function(mode) {
return runServiceCommand(
apk.wire.MessageType.SET_RINGER_MODE

View File

@@ -786,6 +786,16 @@ module.exports = function(options) {
)
])
})
.on('bluetooth.cleanBonds', function(channel, responseChannel) {
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.BluetoothCleanBondedMessage()
)
])
})
.on('group.invite', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([

View File

@@ -84,6 +84,7 @@ enum MessageType {
ConnectStoppedMessage = 93;
BluetoothSetEnabledMessage = 94;
BluetoothGetStatusMessage = 95;
BluetoothCleanBondedMessage = 96;
GroupUserChangeMessage = 1200;
DeviceGroupChangeMessage = 1201;
DeviceOriginGroupMessage = 1202;
@@ -719,6 +720,9 @@ message BluetoothSetEnabledMessage {
message BluetoothGetStatusMessage {
}
message BluetoothCleanBondedMessage {
}
// Events, these must be kept in sync with STFService/wire.proto

View File

@@ -303,6 +303,10 @@ module.exports = function ControlServiceFactory(
return sendTwoWay('bluetooth.get')
}
this.cleanBluetoothBondedDevices = function() {
return sendTwoWay('bluetooth.cleanBonds')
}
window.cc = this
}

View File

@@ -50,6 +50,12 @@ module.exports = function DeviceSettingsCtrl($scope, $timeout) {
}
}
$scope.cleanBluetoothBondedDevices = function() {
if ($scope.control) {
$scope.control.cleanBluetoothBondedDevices()
}
}
$scope.$watch('ringerMode', function(newValue, oldValue) {
if (oldValue) {
if ($scope.control) {

View File

@@ -29,6 +29,8 @@
i.fa.fa-power-off.fa-fw
label.btn.btn-sm.btn-primary-outline(ng-model='bluetoothEnabled', ng-click='toggleBluetooth(true)', ng-disabled='bluetoothPending', uib-btn-radio='true', uib-tooltip='{{"Enable Bluetooth" | translate}}')
i.fa.fa-bluetooth-b.fa-fw
label.btn.btn-sm.btn-primary-outline(ng-click='cleanBluetoothBondedDevices()', uib-tooltip='{{"Clean Bluetooth bonded devices" | translate}}')
i.fa.fa-trash.fa-fw
//.row
.col-md-12