mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Expose identify functionality. Shows a red screen with important data.
This commit is contained in:
parent
9c50c1bcdc
commit
ed5709aa04
6 changed files with 87 additions and 44 deletions
|
@ -313,6 +313,15 @@ module.exports = function(options) {
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
// Transactions
|
// Transactions
|
||||||
|
.on('device.identify', function(channel, responseChannel) {
|
||||||
|
push.send([
|
||||||
|
channel
|
||||||
|
, wireutil.transaction(
|
||||||
|
responseChannel
|
||||||
|
, new wire.PhysicalIdentifyMessage()
|
||||||
|
)
|
||||||
|
])
|
||||||
|
})
|
||||||
.on('group.invite', function(channel, responseChannel, data) {
|
.on('group.invite', function(channel, responseChannel, data) {
|
||||||
joinChannel(responseChannel)
|
joinChannel(responseChannel)
|
||||||
push.send([
|
push.send([
|
||||||
|
|
|
@ -5,6 +5,7 @@ var split = require('split')
|
||||||
var ByteBuffer = require('protobufjs/node_modules/bytebuffer')
|
var ByteBuffer = require('protobufjs/node_modules/bytebuffer')
|
||||||
|
|
||||||
var wire = require('../../../wire')
|
var wire = require('../../../wire')
|
||||||
|
var wireutil = require('../../../wire/util')
|
||||||
var devutil = require('../../../util/devutil')
|
var devutil = require('../../../util/devutil')
|
||||||
var keyutil = require('../../../util/keyutil')
|
var keyutil = require('../../../util/keyutil')
|
||||||
var streamutil = require('../../../util/streamutil')
|
var streamutil = require('../../../util/streamutil')
|
||||||
|
@ -13,9 +14,10 @@ var logger = require('../../../util/logger')
|
||||||
module.exports = syrup()
|
module.exports = syrup()
|
||||||
.dependency(require('../support/adb'))
|
.dependency(require('../support/adb'))
|
||||||
.dependency(require('../support/router'))
|
.dependency(require('../support/router'))
|
||||||
|
.dependency(require('../support/push'))
|
||||||
.dependency(require('../support/quit'))
|
.dependency(require('../support/quit'))
|
||||||
.dependency(require('../resources/inputagent'))
|
.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 log = logger.createLogger('device:plugins:input')
|
||||||
|
|
||||||
var agent = {
|
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()
|
return openAgent()
|
||||||
.then(openService)
|
.then(openService)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
router
|
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) {
|
.on(wire.KeyDownMessage, function(channel, message) {
|
||||||
sendInputEvent({
|
sendInputEvent({
|
||||||
action: 0
|
action: 0
|
||||||
|
@ -201,24 +237,11 @@ module.exports = syrup()
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
unlock: function() {
|
unlock: unlock
|
||||||
service.socket.write('unlock\n')
|
, lock: lock
|
||||||
}
|
, acquireWakeLock: acquireWakeLock
|
||||||
, lock: function() {
|
, releaseWakeLock: releaseWakeLock
|
||||||
service.socket.write('lock\n')
|
, identity: identity
|
||||||
}
|
|
||||||
, 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
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,38 +12,39 @@ var aliases = {
|
||||||
|
|
||||||
module.exports.applyData = function(device) {
|
module.exports.applyData = function(device) {
|
||||||
var model = device.model
|
var model = device.model
|
||||||
var match
|
|
||||||
|
|
||||||
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, '_')
|
|
||||||
match = deviceData[model]
|
|
||||||
|
|
||||||
|
if (!match) {
|
||||||
|
if (aliases[model]) {
|
||||||
|
match = deviceData[aliases[model]]
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (!match) {
|
if (!match) {
|
||||||
model = model.replace(/_/g, '')
|
model = model.replace(/ /g, '_')
|
||||||
match = deviceData[model]
|
match = deviceData[model]
|
||||||
|
|
||||||
|
if (!match) {
|
||||||
|
model = model.replace(/_/g, '')
|
||||||
|
match = deviceData[model]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
device.name = match.name.id
|
device.name = match.name.id
|
||||||
device.releasedAt = match.date
|
device.releasedAt = match.date
|
||||||
device.image = match.image.s.replace(/^small\//, '')
|
device.image = match.image.s.replace(/^small\//, '')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn(
|
log.warn(
|
||||||
'Device database does not have a match for device "%s" (model "%s")'
|
'Device database does not have a match for device "%s" (model "%s")'
|
||||||
, device.serial
|
, device.serial
|
||||||
, device.model
|
, device.model
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return device
|
return device
|
||||||
|
|
|
@ -12,6 +12,7 @@ enum MessageType {
|
||||||
DeviceRegisteredMessage = 8;
|
DeviceRegisteredMessage = 8;
|
||||||
DeviceStatusMessage = 9;
|
DeviceStatusMessage = 9;
|
||||||
GroupMessage = 10;
|
GroupMessage = 10;
|
||||||
|
PhysicalIdentifyMessage = 29;
|
||||||
JoinGroupMessage = 11;
|
JoinGroupMessage = 11;
|
||||||
KeyDownMessage = 12;
|
KeyDownMessage = 12;
|
||||||
KeyPressMessage = 13;
|
KeyPressMessage = 13;
|
||||||
|
@ -185,6 +186,9 @@ message LeaveGroupMessage {
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
|
|
||||||
|
message PhysicalIdentifyMessage {
|
||||||
|
}
|
||||||
|
|
||||||
message TouchDownMessage {
|
message TouchDownMessage {
|
||||||
required uint32 x = 1;
|
required uint32 x = 1;
|
||||||
required uint32 y = 2;
|
required uint32 y = 2;
|
||||||
|
|
|
@ -81,6 +81,12 @@ module.exports = function ControlServiceFactory($rootScope, socket, TransactionS
|
||||||
})
|
})
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.identify = function() {
|
||||||
|
var tx = TransactionService.create(devices)
|
||||||
|
socket.emit('device.identify', channel, tx.channel)
|
||||||
|
return tx
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
controlService.forOne = function(device, channel) {
|
controlService.forOne = function(device, channel) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
h1 {{ device.value.serial }}
|
h1 {{ device.value.serial }}
|
||||||
|
|
||||||
button(ng-click='showScreen = !showScreen') Show/Hide
|
button(ng-click='showScreen = !showScreen') Show/Hide
|
||||||
|
button(ng-click='control.identify()') Identify
|
||||||
|
|
||||||
div(ng-controller='DeviceScreenCtrl')
|
div(ng-controller='DeviceScreenCtrl')
|
||||||
device-screen(style='width: 400px; height: 600px; background: gray')
|
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.menu()') Menu
|
||||||
button(ng-click='control.home()') Home
|
button(ng-click='control.home()') Home
|
||||||
button(ng-click='control.back()') Back
|
button(ng-click='control.back()') Back
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue