mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-17 23:53:18 +02:00
UI support to cleanup bluetooth bonded devices (#757)
Signed-off-by: Jussi Vatjus-Anttila <jussiva@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c481720dd7
commit
806bfa4087
@@ -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)
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -303,6 +303,10 @@ module.exports = function ControlServiceFactory(
|
||||
return sendTwoWay('bluetooth.get')
|
||||
}
|
||||
|
||||
this.cleanBluetoothBondedDevices = function() {
|
||||
return sendTwoWay('bluetooth.cleanBonds')
|
||||
}
|
||||
|
||||
window.cc = this
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user