mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 15:53:23 +02:00
options to disable bluetooth and/or clean bonded (paired) devices (#758)
Signed-off-by: Jussi Vatjus-Anttila <jussiva@gmail.com>
This commit is contained in:
committed by
GitHub
parent
806bfa4087
commit
a6b5f18941
@@ -8,7 +8,8 @@ module.exports = syrup.serial()
|
||||
.dependency(require('../support/adb'))
|
||||
.dependency(require('../resources/service'))
|
||||
.dependency(require('./group'))
|
||||
.define(function(options, adb, service, group) {
|
||||
.dependency(require('./service'))
|
||||
.define(function(options, adb, stfservice, group, service) {
|
||||
var log = logger.createLogger('device:plugins:cleanup')
|
||||
var plugin = Object.create(null)
|
||||
|
||||
@@ -31,7 +32,7 @@ module.exports = syrup.serial()
|
||||
|
||||
return listPackages()
|
||||
.then(function(initialPackages) {
|
||||
initialPackages.push(service.pkg)
|
||||
initialPackages.push(stfservice.pkg)
|
||||
|
||||
plugin.removePackages = function() {
|
||||
return listPackages()
|
||||
@@ -40,9 +41,31 @@ module.exports = syrup.serial()
|
||||
return Promise.map(remove, uninstallPackage)
|
||||
})
|
||||
}
|
||||
plugin.disableBluetooth = function() {
|
||||
if (!options.cleanupDisableBluetooth) {
|
||||
return
|
||||
}
|
||||
return service.getBluetoothStatus()
|
||||
.then(function(enabled) {
|
||||
if (enabled) {
|
||||
log.info('Disabling Bluetooth')
|
||||
return service.setBluetoothEnabled(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
plugin.cleanBluetoothBonds = function() {
|
||||
if (!options.cleanupBluetoothBonds) {
|
||||
return
|
||||
}
|
||||
log.info('Cleanup Bluetooth bonds')
|
||||
return service.cleanBluetoothBonds()
|
||||
}
|
||||
|
||||
group.on('leave', function() {
|
||||
plugin.removePackages()
|
||||
Promise.all([
|
||||
plugin.removePackages()
|
||||
, plugin.cleanBluetoothBonds()
|
||||
, plugin.disableBluetooth()])
|
||||
})
|
||||
})
|
||||
.return(plugin)
|
||||
|
||||
Reference in New Issue
Block a user