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

Merge branch 'feature/get-accounts' into develop

This commit is contained in:
Valverde Antonio 2014-07-30 16:06:59 +09:00
commit 4a6d375adc
8 changed files with 69 additions and 1 deletions

View file

@ -14,6 +14,28 @@ module.exports = syrup.serial()
.define(function(options, service, identity, touch, router, push, adb) {
var log = logger.createLogger('device:plugins:account')
router.on(wire.AccountGetMessage, function(channel, message){
var reply = wireutil.reply(options.serial)
log.info('Getting account(s) of type "%s"', message.type)
service.getAccounts(message.type)
.timeout(30000)
.then(function(accounts) {
push.send([
channel
, reply.okay('success',accounts)
])
})
.catch(function(err) {
log.error('Account get failed', err.stack)
push.send([
channel
, reply.fail(err.message)
])
})
})
router.on(wire.AccountRemoveMessage, function(channel, message) {
var reply = wireutil.reply(options.serial)

View file

@ -490,6 +490,21 @@ module.exports = syrup.serial()
})
}
plugin.getAccounts = function(type) {
return runServiceCommand(
apk.wire.MessageType.GET_ACCOUNTS
, new apk.wire.GetAccountsRequest(type)
)
.timeout(15000)
.then(function(data) {
var response = apk.wire.GetAccountsResponse.decode(data)
if (response.success) {
return response.accounts
}
throw new Error('No accounts returned')
})
}
plugin.removeAccount = function(data) {
return runServiceCommand(
apk.wire.MessageType.DO_REMOVE_ACCOUNT

View file

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

View file

@ -362,6 +362,16 @@ module.exports = function(options) {
)
])
})
.on('account.get', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.AccountGetMessage(data.type)
)
])
})
.on('sd.status', function(channel, responseChannel) {
joinChannel(responseChannel)
push.send([

View file

@ -60,6 +60,7 @@ enum MessageType {
WifiGetStatusMessage = 58;
AccountAddMenuMessage = 59;
AccountAddMessage = 60;
AccountGetMessage = 62;
SdStatusMessage = 61;
}
@ -403,6 +404,10 @@ message AccountAddMessage {
required string password = 2;
}
message AccountGetMessage {
required string type = 1;
}
message SdStatusMessage {
}

View file

@ -236,6 +236,12 @@ module.exports = function ControlServiceFactory(
})
}
this.getAccounts = function(type) {
return sendTwoWay('account.get', {
type: type
})
}
this.getSdStatus = function() {
return sendTwoWay('sd.status')
}

Binary file not shown.

View file

@ -9,6 +9,7 @@ enum MessageType {
DO_WAKE = 4;
DO_ADD_ACCOUNT_MENU = 24;
DO_REMOVE_ACCOUNT = 20;
GET_ACCOUNTS = 26;
GET_BROWSERS = 5;
GET_CLIPBOARD = 6;
GET_DISPLAY = 19;
@ -178,6 +179,15 @@ message DoIdentifyResponse {
required bool success = 1;
}
message GetAccountsRequest {
required string type = 1;
}
message GetAccountsResponse {
required bool success = 1;
repeated string accounts = 2;
}
message DoAddAccountMenuRequest {
}