-
Notifications
You must be signed in to change notification settings - Fork 25
Rework provider flow & rewtrite to TS #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| const delayedTotals = () => { | ||
| clearTimeout(totalsTimer) | ||
| totalsTimer = setTimeout(totals, 10000) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 === '????????????' |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(':') |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>) => |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats happens here?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
No description provided.