mirror of
https://github.com/openstf/stf
synced 2025-10-06 03:50:04 +02:00
Merge branch 'feature/get-ringer-mode' into develop
This commit is contained in:
commit
27db828de3
8 changed files with 73 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -13,15 +13,15 @@ module.exports = syrup.serial()
|
|||
.dependency(require('../support/adb'))
|
||||
.define(function(options, adb) {
|
||||
var log = logger.createLogger('device:resources:service')
|
||||
var builder = ProtoBuf.loadProtoFile(pathutil.vendor('STFService/wire.proto'))
|
||||
|
||||
var resource = {
|
||||
requiredVersion: '0.7.20'
|
||||
requiredVersion: '0.7.21'
|
||||
, pkg: 'jp.co.cyberagent.stf'
|
||||
, main: 'jp.co.cyberagent.stf.Agent'
|
||||
, apk: pathutil.vendor('STFService/STFService.apk')
|
||||
, wire: ProtoBuf.loadProtoFile(
|
||||
pathutil.vendor('STFService/wire.proto')
|
||||
).build().jp.co.cyberagent.stf.proto
|
||||
, wire: builder.build().jp.co.cyberagent.stf.proto
|
||||
, builder: builder
|
||||
, startIntent: {
|
||||
action: 'jp.co.cyberagent.stf.ACTION_START'
|
||||
, component: 'jp.co.cyberagent.stf/.Service'
|
||||
|
|
|
@ -402,6 +402,16 @@ module.exports = function(options) {
|
|||
)
|
||||
])
|
||||
})
|
||||
.on('ringer.get', function(channel, responseChannel) {
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.transaction(
|
||||
responseChannel
|
||||
, new wire.RingerGetMessage()
|
||||
)
|
||||
])
|
||||
})
|
||||
.on('wifi.set', function(channel, responseChannel, data) {
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
|
|
|
@ -55,6 +55,7 @@ enum MessageType {
|
|||
ConnectStartMessage = 53;
|
||||
ConnectStopMessage = 54;
|
||||
RingerSetMessage = 56;
|
||||
RingerGetMessage = 64;
|
||||
WifiSetEnabledMessage = 57;
|
||||
WifiGetStatusMessage = 58;
|
||||
AccountAddMenuMessage = 59;
|
||||
|
@ -427,6 +428,9 @@ message RingerSetMessage {
|
|||
required RingerMode mode = 1;
|
||||
}
|
||||
|
||||
message RingerGetMessage {
|
||||
}
|
||||
|
||||
message WifiSetEnabledMessage {
|
||||
required bool enabled = 1;
|
||||
}
|
||||
|
|
|
@ -259,6 +259,10 @@ module.exports = function ControlServiceFactory(
|
|||
})
|
||||
}
|
||||
|
||||
this.getRingerMode = function() {
|
||||
return sendTwoWay('ringer.get')
|
||||
}
|
||||
|
||||
this.setWifiEnabled = function(enabled) {
|
||||
return sendTwoWay('wifi.set', {
|
||||
enabled: enabled
|
||||
|
|
BIN
vendor/STFService/STFService.apk
vendored
BIN
vendor/STFService/STFService.apk
vendored
Binary file not shown.
9
vendor/STFService/wire.proto
vendored
9
vendor/STFService/wire.proto
vendored
|
@ -14,6 +14,7 @@ enum MessageType {
|
|||
GET_CLIPBOARD = 6;
|
||||
GET_DISPLAY = 19;
|
||||
GET_PROPERTIES = 7;
|
||||
GET_RINGER_MODE = 27;
|
||||
GET_SD_STATUS = 25;
|
||||
GET_VERSION = 8;
|
||||
GET_WIFI_STATUS = 23;
|
||||
|
@ -218,6 +219,14 @@ message SetRingerModeResponse {
|
|||
required bool success = 1;
|
||||
}
|
||||
|
||||
message GetRingerModeRequest {
|
||||
}
|
||||
|
||||
message GetRingerModeResponse {
|
||||
required bool success = 1;
|
||||
required RingerMode mode = 2;
|
||||
}
|
||||
|
||||
message SetWifiEnabledRequest {
|
||||
required bool enabled = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue