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

Ignore remote devices by default, use -R or --allow-remote to override.

This commit is contained in:
Simo Kinnunen 2015-07-13 14:31:52 +09:00
parent a996d97681
commit 55d27364a2
2 changed files with 21 additions and 1 deletions

View file

@ -58,6 +58,8 @@ program
, 'ADB port (defaults to 5037)'
, Number
, 5037)
.option('-R, --allow-remote'
, 'Whether to allow remote devices to be set up')
.option('--screen-ws-url-pattern <pattern>'
, 'screen WebSocket URL pattern'
, String
@ -83,6 +85,7 @@ program
, filter: function(device) {
return serials.length === 0 || serials.indexOf(device.id) !== -1
}
, allowRemote: options.allowRemote
, fork: function(device, ports) {
var fork = require('child_process').fork
return fork(__filename, [
@ -885,6 +888,8 @@ program
, 'ADB port (defaults to 5037)'
, Number
, 5037)
.option('-R, --allow-remote'
, 'Whether to allow remote devices to be set up')
.option('--user-profile-url <url>'
, 'URL to external user profile page'
, String)
@ -949,7 +954,9 @@ program
, util.format('http://localhost:%d/', options.poorxyPort)
, '--adb-host', options.adbHost
, '--adb-port', options.adbPort
].concat(cliutil.allUnknownArgs(args)))
]
.concat(options.allowRemote ? ['--allow-remote'] : [])
.concat(cliutil.allUnknownArgs(args)))
// auth
, procutil.fork(__filename, [

View file

@ -117,6 +117,12 @@ module.exports = function(options) {
return device.id === '????????????'
}
// Check whether the device is remote (i.e. if we're connecting to
// an IP address (or hostname) and port pair).
function isRemoteDevice(device) {
return device.id.indexOf(':') !== -1
}
// Helper for ignoring unwanted devices
function filterDevice(listener) {
return function(device) {
@ -124,6 +130,13 @@ module.exports = function(options) {
log.warn('ADB lists a weird device: "%s"', device.id)
return false
}
if (!options.allowRemote && isRemoteDevice(device)) {
log.info(
'Filtered out remote device "%s", use --allow-remote to override'
, device.id
)
return false
}
if (options.filter && !options.filter(device)) {
log.info('Filtered out device "%s"', device.id)
return false