1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 02:29:26 +02:00

Fix provider not seeing device type changes. ADB doesn't keep the object up to date by itself.

This commit is contained in:
Simo Kinnunen 2014-02-07 00:26:16 +09:00
parent af2db0f719
commit e4c76e1793

View file

@ -128,23 +128,31 @@ module.exports = function(options) {
lists.all.push(device.id)
delayedTotals()
// The device object will be kept up to date by the tracker, except
// our custom "present" property
// Will be set to false when the device is removed
_.assign(device, {
present: true
})
// When any event occurs on the added device
function deviceListener(type) {
function deviceListener(type, updatedDevice) {
// Okay, this is a bit unnecessary but it allows us to get rid of an
// ugly switch statement and return to the original style.
privateTracker.emit(type)
privateTracker.emit(type, updatedDevice)
}
// When the added device changes
function changeListener() {
function changeListener(updatedDevice) {
register.then(function() {
log.info('Device "%s" is now "%s"', device.id, device.type)
log.info(
'Device "%s" is now "%s" (was "%s")'
, device.id
, updatedDevice.type
, device.type
)
_.assign(device, {
type: updatedDevice.type
})
// Tell others the device changed
push.send([
@ -160,7 +168,7 @@ module.exports = function(options) {
}
// When the added device gets removed
function removeListener() {
function removeListener(updatedDevice) {
register.then(function() {
log.info('Lost device "%s" (%s)', device.id, device.type)