mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Reboot functionality added
This commit is contained in:
parent
af6fa9fe29
commit
b84d1b97c6
5 changed files with 54 additions and 0 deletions
|
@ -30,6 +30,7 @@ module.exports = function(options) {
|
|||
.dependency(require('./device/plugins/install'))
|
||||
.dependency(require('./device/plugins/forward'))
|
||||
.dependency(require('./device/plugins/group'))
|
||||
.dependency(require('./device/plugins/reboot'))
|
||||
.define(function(options, solo) {
|
||||
if (process.send) {
|
||||
// Only if we have a parent process
|
||||
|
|
35
lib/roles/device/plugins/reboot.js
Normal file
35
lib/roles/device/plugins/reboot.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
var syrup = require('syrup')
|
||||
|
||||
var logger = require('../../../util/logger')
|
||||
var wire = require('../../../wire')
|
||||
var wireutil = require('../../../wire/util')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.dependency(require('../support/adb'))
|
||||
.dependency(require('../support/router'))
|
||||
.dependency(require('../support/push'))
|
||||
.define(function(options, adb, router, push) {
|
||||
var log = logger.createLogger('device:plugins:reboot')
|
||||
|
||||
router.on(wire.RebootMessage, function(channel, message) {
|
||||
var reply = wireutil.reply(options.serial)
|
||||
|
||||
log.info('Rebooting')
|
||||
|
||||
adb.reboot(options.serial)
|
||||
.timeout(30000)
|
||||
.then(function() {
|
||||
push.send([
|
||||
channel
|
||||
, reply.okay()
|
||||
])
|
||||
})
|
||||
.error(function(err) {
|
||||
log.error('Reboot failed', err.stack)
|
||||
push.send([
|
||||
channel
|
||||
, reply.fail(err.message)
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
|
@ -310,6 +310,16 @@ module.exports = function(options) {
|
|||
)
|
||||
])
|
||||
})
|
||||
.on('device.reboot', function(channel, responseChannel) {
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.transaction(
|
||||
responseChannel
|
||||
, new wire.RebootMessage()
|
||||
)
|
||||
])
|
||||
})
|
||||
.on('group.invite', function(channel, responseChannel, data) {
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
|
|
|
@ -51,6 +51,7 @@ enum MessageType {
|
|||
StoreOpenMessage = 49;
|
||||
ScreenCaptureMessage = 50;
|
||||
ProviderHeartbeatMessage = 51;
|
||||
RebootMessage = 52;
|
||||
}
|
||||
|
||||
message Envelope {
|
||||
|
@ -279,6 +280,9 @@ message KeyPressMessage {
|
|||
required string key = 1;
|
||||
}
|
||||
|
||||
message RebootMessage {
|
||||
}
|
||||
|
||||
// Output
|
||||
|
||||
message DeviceLogcatEntryMessage {
|
||||
|
|
|
@ -148,6 +148,10 @@ module.exports = function ControlServiceFactory(
|
|||
})
|
||||
}
|
||||
|
||||
this.reboot = function() {
|
||||
return sendTwoWay('device.reboot')
|
||||
}
|
||||
|
||||
this.rotate = function(rotation) {
|
||||
return sendOneWay('display.rotate', {
|
||||
rotation: rotation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue