Fix fake UVC device serial generated from VID/PID #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes the fake serial number generation using PID/VID for UVC devices.
The way the SDK identifies UVC devices is by their serial number. But if the UVC device doesn't have a serial, the SDK makes up a fake one from the PID and VID USB metadata. However, this latter functionality was broken, because the calls to get PID and VID were returning "0" and thus the fake serial number was "0:0". What's more, although UVC devices could be correctly detected (or have their absence detected) when their serial was "0:0", when you go to actually USE it (I tested with the Vuforia webcam example and my own webcam example for EasyOpenCV) it would not work correctly.
This patch fixes the PID and VID being reported as "0" by replacing the calls to native C++ code to get those values with calls to the Android Java API. The heart of the change is the diff for the LibUsbDevice.java file. The rest of the changes were simply things that had to be changed as the result of the change to LibUsbDevice.java. Some legacy code (which was already disabled thanks to a boolean flag) had to be commented out, but that really shouldn't be a big deal given that it was not actually being used at all....
I was testing with my UVC-compatible microscope, which does not report a serial number. Before the change it was detected as "0:0". After the change, it was detected as "7758:265".
Results when running Vuforia Webcam sample before change (no preview and/or crash), and after the change (works great!):