mirror of
https://github.com/openstf/stf
synced 2025-10-06 03:50:04 +02:00
Implement account check (if it's already added).
This commit is contained in:
parent
060b58973c
commit
2e61911f8c
4 changed files with 52 additions and 1 deletions
|
@ -14,6 +14,34 @@ module.exports = syrup.serial()
|
|||
.define(function(options, service, identity, touch, router, push, adb) {
|
||||
var log = logger.createLogger('device:plugins:account')
|
||||
|
||||
router.on(wire.AccountCheckMessage, function(channel, message) {
|
||||
var reply = wireutil.reply(options.serial)
|
||||
|
||||
log.info('Checking if account "%s" is added',message.account)
|
||||
|
||||
service.getAccounts(message.type)
|
||||
.timeout(30000)
|
||||
.then(function(accounts) {
|
||||
if(accounts.indexOf(message.account) >= 0) {
|
||||
push.send([
|
||||
channel
|
||||
, reply.okay()
|
||||
])
|
||||
}
|
||||
else {
|
||||
throw new Error('The account is not added')
|
||||
}
|
||||
})
|
||||
.catch(function(err){
|
||||
log.error('Account check failed', err.stack)
|
||||
push.send([
|
||||
channel
|
||||
, reply.fail(err.message)
|
||||
])
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
router.on(wire.AccountGetMessage, function(channel, message) {
|
||||
var reply = wireutil.reply(options.serial)
|
||||
|
||||
|
|
|
@ -332,6 +332,16 @@ module.exports = function(options) {
|
|||
)
|
||||
])
|
||||
})
|
||||
.on('account.check', function(channel, responseChannel, data){
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.transaction(
|
||||
responseChannel
|
||||
, new wire.AccountCheckMessage(data)
|
||||
)
|
||||
])
|
||||
})
|
||||
.on('account.remove', function(channel, responseChannel, data) {
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
|
|
|
@ -59,6 +59,7 @@ enum MessageType {
|
|||
WifiGetStatusMessage = 58;
|
||||
AccountAddMenuMessage = 59;
|
||||
AccountAddMessage = 60;
|
||||
AccountCheckMessage = 63;
|
||||
AccountGetMessage = 62;
|
||||
AccountRemoveMessage = 55;
|
||||
SdStatusMessage = 61;
|
||||
|
@ -399,6 +400,11 @@ message AccountAddMessage {
|
|||
required string password = 2;
|
||||
}
|
||||
|
||||
message AccountCheckMessage {
|
||||
required string type = 1;
|
||||
required string account = 2;
|
||||
}
|
||||
|
||||
message AccountGetMessage {
|
||||
required string type = 1;
|
||||
}
|
||||
|
|
|
@ -218,6 +218,13 @@ module.exports = function ControlServiceFactory(
|
|||
return sendTwoWay('screen.capture')
|
||||
}
|
||||
|
||||
this.checkAccount = function(type, account) {
|
||||
return sendTwoWay('account.check', {
|
||||
type: type
|
||||
, account: account
|
||||
})
|
||||
}
|
||||
|
||||
this.removeAccount = function(type, account) {
|
||||
return sendTwoWay('account.remove', {
|
||||
type: type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue