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

Implement account removal.

This commit is contained in:
Valverde Antonio 2014-06-25 17:47:45 +09:00
parent a8da19472d
commit 3a3937ec2f
9 changed files with 78 additions and 1 deletions

View file

@ -32,6 +32,7 @@ module.exports = function(options) {
.dependency(require('./device/plugins/group'))
.dependency(require('./device/plugins/reboot'))
.dependency(require('./device/plugins/connect'))
.dependency(require('./device/plugins/account'))
.define(function(options, solo) {
if (process.send) {
// Only if we have a parent process

View file

@ -0,0 +1,35 @@
var syrup = require('syrup')
var logger = require('../../../util/logger')
var wire = require('../../../wire')
var wireutil = require('../../../wire/util')
module.exports = syrup.serial()
.dependency(require('./service'))
.dependency(require('../support/router'))
.dependency(require('../support/push'))
.define(function(options, service, router, push) {
var log = logger.createLogger('device:plugins:account')
router.on(wire.AccountRemoveMessage, function(channel, message) {
var reply = wireutil.reply(options.serial)
log.info('Removing current Google account(s)')
service.removeAccount()
.timeout(30000)
.then(function() {
push.send([
channel
, reply.okay()
])
})
.error(function(err) {
log.error('Account removal failed', err.stack)
push.send([
channel
, reply.fail(err.message)
])
})
})
})

View file

@ -490,6 +490,21 @@ module.exports = syrup.serial()
})
}
plugin.removeAccount = function() {
return runServiceCommand(
apk.wire.MessageType.REMOVE_ACCOUNT
, new apk.wire.RemoveAccountRequest()
)
.timeout(15000)
.then(function(data) {
var response = apk.wire.RemoveAccountResponse.decode(data)
if (response.success) {
return true
}
throw new Error('Unable to remove account')
})
}
function runServiceCommand(type, cmd) {
var resolver = Promise.defer()
var id = Math.floor(Math.random() * 0xFFFFFF)

View file

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

View file

@ -321,6 +321,16 @@ module.exports = function(options) {
)
])
})
.on('account.remove', function(channel, responseChannel) {
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.AccountRemoveMessage()
)
])
})
.on('group.invite', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([

View file

@ -54,6 +54,7 @@ enum MessageType {
RebootMessage = 52;
ConnectStartMessage = 53;
ConnectStopMessage = 54;
AccountRemoveMessage = 55;
}
message Envelope {
@ -382,6 +383,9 @@ message ConnectStartMessage {
message ConnectStopMessage {
}
message AccountRemoveMessage {
}
// Events, these must be kept in sync with STFService/wire.proto
message AirplaneModeEvent {

View file

@ -218,6 +218,10 @@ module.exports = function ControlServiceFactory(
return sendTwoWay('screen.capture')
}
this.removeAccount = function() {
return sendTwoWay('account.remove')
}
window.cc = this
}

Binary file not shown.

View file

@ -22,6 +22,7 @@ enum MessageType {
EVENT_PHONE_STATE = 16;
EVENT_ROTATION = 17;
EVENT_BROWSER_PACKAGE = 18;
REMOVE_ACCOUNT = 20;
}
message Envelope {
@ -172,6 +173,13 @@ message DoIdentifyResponse {
required bool success = 1;
}
message RemoveAccountRequest {
}
message RemoveAccountResponse {
required bool success = 1;
}
// Agent
enum KeyEvent {