diff --git a/lib/roles/device/plugins/account.js b/lib/roles/device/plugins/account.js index b7a0c163..9727672c 100644 --- a/lib/roles/device/plugins/account.js +++ b/lib/roles/device/plugins/account.js @@ -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) + ]) + }) + }) }) diff --git a/lib/roles/device/plugins/service.js b/lib/roles/device/plugins/service.js index 1140a967..f086f16e 100644 --- a/lib/roles/device/plugins/service.js +++ b/lib/roles/device/plugins/service.js @@ -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) { return runServiceCommand( apk.wire.MessageType.SET_RINGER_MODE diff --git a/lib/roles/device/resources/service.js b/lib/roles/device/resources/service.js index 98294486..716c3a7d 100644 --- a/lib/roles/device/resources/service.js +++ b/lib/roles/device/resources/service.js @@ -15,7 +15,7 @@ module.exports = syrup.serial() var log = logger.createLogger('device:resources:service') var resource = { - requiredVersion: '0.7.12' + requiredVersion: '0.7.13' , pkg: 'jp.co.cyberagent.stf' , main: 'jp.co.cyberagent.stf.Agent' , apk: pathutil.vendor('STFService/STFService.apk') diff --git a/lib/roles/websocket.js b/lib/roles/websocket.js index 99fcb94d..b5c98239 100644 --- a/lib/roles/websocket.js +++ b/lib/roles/websocket.js @@ -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) { joinChannel(responseChannel) push.send([ diff --git a/lib/wire/wire.proto b/lib/wire/wire.proto index eff53268..69744b3a 100644 --- a/lib/wire/wire.proto +++ b/lib/wire/wire.proto @@ -58,6 +58,7 @@ enum MessageType { RingerSetMessage = 56; WifiSetEnabledMessage = 57; WifiGetStatusMessage = 58; + AccountAddMenuMessage = 59; } message Envelope { @@ -389,6 +390,9 @@ message ConnectStopMessage { message AccountRemoveMessage { } +message AccountAddMenuMessage { +} + message RingerSetMessage { required int32 mode = 1; } diff --git a/res/app/components/stf/control/control-service.js b/res/app/components/stf/control/control-service.js index 3d382d5a..be766e27 100644 --- a/res/app/components/stf/control/control-service.js +++ b/res/app/components/stf/control/control-service.js @@ -222,6 +222,10 @@ module.exports = function ControlServiceFactory( return sendTwoWay('account.remove') } + this.addAccountMenu = function() { + return sendTwoWay('account.add') + } + this.setRingerMode = function(mode) { return sendTwoWay('ringer.set', { mode: mode diff --git a/vendor/STFService/STFService.apk b/vendor/STFService/STFService.apk index 21962872..d8f2a434 100644 Binary files a/vendor/STFService/STFService.apk and b/vendor/STFService/STFService.apk differ diff --git a/vendor/STFService/wire.proto b/vendor/STFService/wire.proto index 1511e371..d1f21622 100644 --- a/vendor/STFService/wire.proto +++ b/vendor/STFService/wire.proto @@ -7,6 +7,7 @@ enum MessageType { DO_KEYEVENT = 2; DO_TYPE = 3; DO_WAKE = 4; + DO_ADD_ACCOUNT_MENU = 24; GET_BROWSERS = 5; GET_CLIPBOARD = 6; GET_DISPLAY = 19; @@ -176,6 +177,13 @@ message DoIdentifyResponse { required bool success = 1; } +message DoAddAccountMenuRequest { +} + +message DoAddAccountMenuResponse { + required bool success = 1; +} + message RemoveAccountRequest { }