1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00

Reboot functionality added

This commit is contained in:
Valverde Antonio 2014-06-19 19:29:59 +09:00
parent af6fa9fe29
commit b84d1b97c6
5 changed files with 54 additions and 0 deletions

View file

@ -30,6 +30,7 @@ module.exports = function(options) {
.dependency(require('./device/plugins/install')) .dependency(require('./device/plugins/install'))
.dependency(require('./device/plugins/forward')) .dependency(require('./device/plugins/forward'))
.dependency(require('./device/plugins/group')) .dependency(require('./device/plugins/group'))
.dependency(require('./device/plugins/reboot'))
.define(function(options, solo) { .define(function(options, solo) {
if (process.send) { if (process.send) {
// Only if we have a parent process // Only if we have a parent process

View 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)
])
})
})
})

View file

@ -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) { .on('group.invite', function(channel, responseChannel, data) {
joinChannel(responseChannel) joinChannel(responseChannel)
push.send([ push.send([

View file

@ -51,6 +51,7 @@ enum MessageType {
StoreOpenMessage = 49; StoreOpenMessage = 49;
ScreenCaptureMessage = 50; ScreenCaptureMessage = 50;
ProviderHeartbeatMessage = 51; ProviderHeartbeatMessage = 51;
RebootMessage = 52;
} }
message Envelope { message Envelope {
@ -279,6 +280,9 @@ message KeyPressMessage {
required string key = 1; required string key = 1;
} }
message RebootMessage {
}
// Output // Output
message DeviceLogcatEntryMessage { message DeviceLogcatEntryMessage {

View file

@ -148,6 +148,10 @@ module.exports = function ControlServiceFactory(
}) })
} }
this.reboot = function() {
return sendTwoWay('device.reboot')
}
this.rotate = function(rotation) { this.rotate = function(rotation) {
return sendOneWay('display.rotate', { return sendOneWay('display.rotate', {
rotation: rotation rotation: rotation