mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +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:
parent
af2db0f719
commit
e4c76e1793
1 changed files with 15 additions and 7 deletions
|
@ -128,23 +128,31 @@ module.exports = function(options) {
|
||||||
lists.all.push(device.id)
|
lists.all.push(device.id)
|
||||||
delayedTotals()
|
delayedTotals()
|
||||||
|
|
||||||
// The device object will be kept up to date by the tracker, except
|
// Will be set to false when the device is removed
|
||||||
// our custom "present" property
|
|
||||||
_.assign(device, {
|
_.assign(device, {
|
||||||
present: true
|
present: true
|
||||||
})
|
})
|
||||||
|
|
||||||
// When any event occurs on the added device
|
// 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
|
// Okay, this is a bit unnecessary but it allows us to get rid of an
|
||||||
// ugly switch statement and return to the original style.
|
// ugly switch statement and return to the original style.
|
||||||
privateTracker.emit(type)
|
privateTracker.emit(type, updatedDevice)
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the added device changes
|
// When the added device changes
|
||||||
function changeListener() {
|
function changeListener(updatedDevice) {
|
||||||
register.then(function() {
|
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
|
// Tell others the device changed
|
||||||
push.send([
|
push.send([
|
||||||
|
@ -160,7 +168,7 @@ module.exports = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the added device gets removed
|
// When the added device gets removed
|
||||||
function removeListener() {
|
function removeListener(updatedDevice) {
|
||||||
register.then(function() {
|
register.then(function() {
|
||||||
log.info('Lost device "%s" (%s)', device.id, device.type)
|
log.info('Lost device "%s" (%s)', device.id, device.type)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue