Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ignore incomplete device info when retrieving devices with paths #22

Merged

Conversation

emereum
Copy link

@emereum emereum commented Oct 11, 2024

Problem

Users can retrieve a list of devices using client.listDevicesWithPaths(). Internally, this method parses ADB output which it assumes to be of the form:

deafbeef1234     device usb:2-1 product:hero2ltexx model:SM_G935F device:hero2lte transport_id:35
deafbeef4321     device usb:2-2 product:hero2ltexx model:SM_G935F device:hero2lte transport_id:35

If client.listDevicesWithPaths() is called immediately after a new device is connected, that device may be in authorizing state which will cause an exception because it takes the form:

deadbeef5432       authorizing usb:1-1.3 transport_id:45

Solution

Update the string parsing logic to ignore unsupported data.

@emereum
Copy link
Author

emereum commented Nov 7, 2024

@UrielCh

@UrielCh
Copy link
Owner

UrielCh commented Nov 7, 2024

Yes?? 😉

/**
* adb device starts
*/
export type DeviceType = 'emulator' | 'device' | 'offline' | 'unauthorized' | 'recovery';
export type DeviceType = typeof deviceTypes[number];
Copy link
Owner

Choose a reason for hiding this comment

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

yep, proper typescript +1

@UrielCh UrielCh merged commit d010008 into UrielCh:master Nov 7, 2024
2 checks passed
@UrielCh
Copy link
Owner

UrielCh commented Nov 8, 2024

Released

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants