mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
Implement get ringer mode.
This commit is contained in:
@@ -24,7 +24,7 @@ module.exports = syrup.serial()
|
||||
, reply.okay()
|
||||
])
|
||||
})
|
||||
.error(function(err) {
|
||||
.catch(function(err) {
|
||||
log.error('Setting ringer mode failed', err.stack)
|
||||
push.send([
|
||||
channel
|
||||
@@ -32,4 +32,26 @@ module.exports = syrup.serial()
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
router.on(wire.RingerGetMessage, function(channel) {
|
||||
var reply = wireutil.reply(options.serial)
|
||||
|
||||
log.info('Getting ringer mode')
|
||||
|
||||
service.getRingerMode()
|
||||
.timeout(30000)
|
||||
.then(function(mode) {
|
||||
push.send([
|
||||
channel
|
||||
, reply.okay('success', mode)
|
||||
])
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.error('Getting ringer mode failed', err.stack)
|
||||
push.send([
|
||||
channel
|
||||
, reply.fail(err.message)
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -552,6 +552,25 @@ module.exports = syrup.serial()
|
||||
})
|
||||
}
|
||||
|
||||
plugin.getRingerMode = function() {
|
||||
return runServiceCommand(
|
||||
apk.wire.MessageType.GET_RINGER_MODE
|
||||
, new apk.wire.GetRingerModeRequest()
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.wire.GetRingerModeResponse.decode(data)
|
||||
// Reflection to decode enums to their string values, otherwise
|
||||
// we only get an integer
|
||||
var ringerMode = apk.builder.lookup('jp.co.cyberagent.stf.proto.RingerMode')
|
||||
.children[response.mode].name
|
||||
if (response.success) {
|
||||
return ringerMode
|
||||
}
|
||||
throw new Error('Unable to get ringer mode')
|
||||
})
|
||||
}
|
||||
|
||||
plugin.setWifiEnabled = function(enabled) {
|
||||
return runServiceCommand(
|
||||
apk.wire.MessageType.SET_WIFI_ENABLED
|
||||
|
||||
Reference in New Issue
Block a user