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

Expose identify functionality. Shows a red screen with important data.

This commit is contained in:
Simo Kinnunen 2014-03-17 19:21:34 +09:00
parent 9c50c1bcdc
commit ed5709aa04
6 changed files with 87 additions and 44 deletions

View file

@ -313,6 +313,15 @@ module.exports = function(options) {
])
})
// Transactions
.on('device.identify', function(channel, responseChannel) {
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.PhysicalIdentifyMessage()
)
])
})
.on('group.invite', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([

View file

@ -5,6 +5,7 @@ var split = require('split')
var ByteBuffer = require('protobufjs/node_modules/bytebuffer')
var wire = require('../../../wire')
var wireutil = require('../../../wire/util')
var devutil = require('../../../util/devutil')
var keyutil = require('../../../util/keyutil')
var streamutil = require('../../../util/streamutil')
@ -13,9 +14,10 @@ var logger = require('../../../util/logger')
module.exports = syrup()
.dependency(require('../support/adb'))
.dependency(require('../support/router'))
.dependency(require('../support/push'))
.dependency(require('../support/quit'))
.dependency(require('../resources/inputagent'))
.define(function(options, adb, router, quit, apk) {
.define(function(options, adb, router, push, quit, apk) {
var log = logger.createLogger('device:plugins:input')
var agent = {
@ -170,10 +172,44 @@ module.exports = syrup()
]))
}
function unlock() {
service.socket.write('unlock\n')
}
function lock() {
service.socket.write('lock\n')
}
function acquireWakeLock() {
service.socket.write('acquire wake lock\n')
}
function releaseWakeLock() {
service.socket.write('release wake lock\n')
}
function identity() {
service.socket.write(util.format(
'show identity %s\n'
, options.serial
))
}
return openAgent()
.then(openService)
.then(function() {
router
.on(wire.PhysicalIdentifyMessage, function(channel, message) {
identity()
push.send([
channel
, wireutil.envelope(new wire.TransactionDoneMessage(
options.serial
, 0
, true
))
])
})
.on(wire.KeyDownMessage, function(channel, message) {
sendInputEvent({
action: 0
@ -201,24 +237,11 @@ module.exports = syrup()
})
return {
unlock: function() {
service.socket.write('unlock\n')
}
, lock: function() {
service.socket.write('lock\n')
}
, acquireWakeLock: function() {
service.socket.write('acquire wake lock\n')
}
, releaseWakeLock: function() {
service.socket.write('release wake lock\n')
}
, identity: function() {
service.socket.write(util.format(
'show identity %s\n'
, options.serial
))
}
unlock: unlock
, lock: lock
, acquireWakeLock: acquireWakeLock
, releaseWakeLock: releaseWakeLock
, identity: identity
}
})
})

View file

@ -12,38 +12,39 @@ var aliases = {
module.exports.applyData = function(device) {
var model = device.model
var match
match = deviceData[model]
if (!match) {
if (aliases[model]) {
match = deviceData[aliases[model]]
}
else {
if (!match) {
model = model.replace(/ /g, '_')
match = deviceData[model]
if (model) {
var match = deviceData[model]
if (!match) {
if (aliases[model]) {
match = deviceData[aliases[model]]
}
else {
if (!match) {
model = model.replace(/_/g, '')
model = model.replace(/ /g, '_')
match = deviceData[model]
if (!match) {
model = model.replace(/_/g, '')
match = deviceData[model]
}
}
}
}
}
if (match) {
device.name = match.name.id
device.releasedAt = match.date
device.image = match.image.s.replace(/^small\//, '')
}
else {
log.warn(
'Device database does not have a match for device "%s" (model "%s")'
, device.serial
, device.model
)
if (match) {
device.name = match.name.id
device.releasedAt = match.date
device.image = match.image.s.replace(/^small\//, '')
}
else {
log.warn(
'Device database does not have a match for device "%s" (model "%s")'
, device.serial
, device.model
)
}
}
return device

View file

@ -12,6 +12,7 @@ enum MessageType {
DeviceRegisteredMessage = 8;
DeviceStatusMessage = 9;
GroupMessage = 10;
PhysicalIdentifyMessage = 29;
JoinGroupMessage = 11;
KeyDownMessage = 12;
KeyPressMessage = 13;
@ -185,6 +186,9 @@ message LeaveGroupMessage {
// Input
message PhysicalIdentifyMessage {
}
message TouchDownMessage {
required uint32 x = 1;
required uint32 y = 2;

View file

@ -81,6 +81,12 @@ module.exports = function ControlServiceFactory($rootScope, socket, TransactionS
})
return tx
}
this.identify = function() {
var tx = TransactionService.create(devices)
socket.emit('device.identify', channel, tx.channel)
return tx
}
}
controlService.forOne = function(device, channel) {

View file

@ -1,6 +1,7 @@
h1 {{ device.value.serial }}
button(ng-click='showScreen = !showScreen') Show/Hide
button(ng-click='control.identify()') Identify
div(ng-controller='DeviceScreenCtrl')
device-screen(style='width: 400px; height: 600px; background: gray')
@ -8,4 +9,3 @@ div(ng-controller='DeviceScreenCtrl')
button(ng-click='control.menu()') Menu
button(ng-click='control.home()') Home
button(ng-click='control.back()') Back