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

Implement pop up add account menu (for Google Account).

This commit is contained in:
Valverde Antonio 2014-07-02 18:37:39 +09:00
parent 9125816d07
commit d294906a65
8 changed files with 64 additions and 1 deletions

View file

@ -32,4 +32,26 @@ module.exports = syrup.serial()
]) ])
}) })
}) })
router.on(wire.AccountAddMenuMessage, function(channel) {
var reply = wireutil.reply(options.serial)
log.info('Showing add account menu for Google Account')
service.addAccountMenu()
.timeout(30000)
.then(function() {
push.send([
channel
, reply.okay()
])
})
.error(function(err) {
log.error('Add account menu failed', err.stack)
push.send([
channel
, reply.fail(err.message)
])
})
})
}) })

View file

@ -505,6 +505,21 @@ module.exports = syrup.serial()
}) })
} }
plugin.addAccountMenu = function() {
return runServiceCommand(
apk.wire.MessageType.DO_ADD_ACCOUNT_MENU
, new apk.wire.DoAddAccountMenuRequest()
)
.timeout(15000)
.then(function(data) {
var response = apk.wire.DoAddAccountMenuResponse.decode(data)
if (response.success) {
return true
}
throw new Error('Unable to show add account menu')
})
}
plugin.setRingerMode = function(mode) { plugin.setRingerMode = function(mode) {
return runServiceCommand( return runServiceCommand(
apk.wire.MessageType.SET_RINGER_MODE apk.wire.MessageType.SET_RINGER_MODE

View file

@ -15,7 +15,7 @@ module.exports = syrup.serial()
var log = logger.createLogger('device:resources:service') var log = logger.createLogger('device:resources:service')
var resource = { var resource = {
requiredVersion: '0.7.12' requiredVersion: '0.7.13'
, pkg: 'jp.co.cyberagent.stf' , pkg: 'jp.co.cyberagent.stf'
, main: 'jp.co.cyberagent.stf.Agent' , main: 'jp.co.cyberagent.stf.Agent'
, apk: pathutil.vendor('STFService/STFService.apk') , apk: pathutil.vendor('STFService/STFService.apk')

View file

@ -331,6 +331,16 @@ module.exports = function(options) {
) )
]) ])
}) })
.on('account.add', function(channel, responseChannel) {
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.AccountAddMenuMessage()
)
])
})
.on('ringer.set', function(channel, responseChannel, data) { .on('ringer.set', function(channel, responseChannel, data) {
joinChannel(responseChannel) joinChannel(responseChannel)
push.send([ push.send([

View file

@ -58,6 +58,7 @@ enum MessageType {
RingerSetMessage = 56; RingerSetMessage = 56;
WifiSetEnabledMessage = 57; WifiSetEnabledMessage = 57;
WifiGetStatusMessage = 58; WifiGetStatusMessage = 58;
AccountAddMenuMessage = 59;
} }
message Envelope { message Envelope {
@ -389,6 +390,9 @@ message ConnectStopMessage {
message AccountRemoveMessage { message AccountRemoveMessage {
} }
message AccountAddMenuMessage {
}
message RingerSetMessage { message RingerSetMessage {
required int32 mode = 1; required int32 mode = 1;
} }

View file

@ -222,6 +222,10 @@ module.exports = function ControlServiceFactory(
return sendTwoWay('account.remove') return sendTwoWay('account.remove')
} }
this.addAccountMenu = function() {
return sendTwoWay('account.add')
}
this.setRingerMode = function(mode) { this.setRingerMode = function(mode) {
return sendTwoWay('ringer.set', { return sendTwoWay('ringer.set', {
mode: mode mode: mode

Binary file not shown.

View file

@ -7,6 +7,7 @@ enum MessageType {
DO_KEYEVENT = 2; DO_KEYEVENT = 2;
DO_TYPE = 3; DO_TYPE = 3;
DO_WAKE = 4; DO_WAKE = 4;
DO_ADD_ACCOUNT_MENU = 24;
GET_BROWSERS = 5; GET_BROWSERS = 5;
GET_CLIPBOARD = 6; GET_CLIPBOARD = 6;
GET_DISPLAY = 19; GET_DISPLAY = 19;
@ -176,6 +177,13 @@ message DoIdentifyResponse {
required bool success = 1; required bool success = 1;
} }
message DoAddAccountMenuRequest {
}
message DoAddAccountMenuResponse {
required bool success = 1;
}
message RemoveAccountRequest { message RemoveAccountRequest {
} }