Skip to content

Conversation

@e-khalilov
Copy link

No description provided.

@e-khalilov e-khalilov requested a review from a team as a code owner September 2, 2025 14:59

const delayedTotals = () => {
clearTimeout(totalsTimer)
totalsTimer = setTimeout(totals, 10000)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 10000? maybe need to set in params

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need, it is just a delay before the log is output to prevent false logging when the output values ​​may have time to change before being output to stdout.

// This can happen when ADB doesn't have a good connection to
// the device
const isWeirdUnusableDevice = (device: Device) =>
device.id === '????????????'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its bullshit and we can remove it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check causes minimal overhead.
This check was definitely implemented to fix a bug. I decided not to touch it until better times, so as not to create new unexpected problems.

What works - we do not touch.

// Check whether the device is remote (i.e. if we're connecting to
// an IP address (or hostname) and port pair).
const isRemoteDevice = (device: Device) =>
device.id.includes(':')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw not only remote device can includes ':' but idk how to diff by other way (maybe biy listing with -l)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this check should be removed?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it need to be refactored in future
See direct message in VK

device.id.includes(':')

// Helper for ignoring unwanted devices
const filterDevice = (listener: (device: Device) => any | Promise<any>) =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also we need to implement check for device with same serial as already exists in provider
and if its physical - we need to implement custom logic in future

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented, see line 169

}

// When any event occurs on the added device
const deviceListener = (type: string, ...args: any[]) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats happens here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forwarding global device tracker messages (for all connected devices) to an individual device EventEmmiter, for subscribing to tracker events (change and remove) by serial number (id from adb).

See usage of privateTracker for details


flippedTracker.removeListener(device.id, deviceListener)

device.present = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this place we set present: false, but how about db?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a device is lost, we send a DeviceAbsentMessage, which should set all the necessary device states.

For details, see line 283

privateTracker.on('remove', removeListener)

// Will be set to false when the device is removed
device.present = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this place we set present: false, but how about db?

Copy link
Author

@e-khalilov e-khalilov Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag is only required for the internal logic of the provider. Without the value true, the device will not start, but when it starts, it sends the DeviceIntroductionMessage event, which should set the device to the required initial state (present: true inclusive).

See line 185, 202

@DaniilSmirnov DaniilSmirnov self-requested a review September 2, 2025 16:55
DaniilSmirnov
DaniilSmirnov previously approved these changes Sep 2, 2025
@DaniilSmirnov DaniilSmirnov self-requested a review September 3, 2025 19:15
@e-khalilov e-khalilov merged commit bc4b02a into master Sep 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants