mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
Implement get account names function.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user