<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 30, 2019, at 11:55 AM, Anton Lundin <<a href="mailto:glance@acc.umu.se" class="">glance@acc.umu.se</a>> wrote:</div><div class=""><div class=""><blockquote type="cite" class=""><blockquote type="cite" class="">Yea, its a quite complex call chain, but I thin it can be simplified to<br class="">filling out struct libusb_device and calling usbi_connect_device on<br class="">those.<br class=""><br class="">UsbManager.getDeviceList() gives us enough to fill in the libusb_device<br class="">structs.<br class=""></blockquote><br class="">Hmm - I hadn't planned to go that route. We already have the intent handling<br class="">that talks to us when a device is connected. And that gives us the one USB<br class="">device that we need to talk to - so why even get that list?<br class=""><br class=""></blockquote><br class="">Its probably easier to just generate the whole list, rather than keep<br class="">some intent data around. The use might not even care about the intent,<br class="">and dismisses it, and then later starts subsurface manually, and expect<br class="">to be able to download.<br class=""></div></div></blockquote><div><br class=""></div>You are absolutely correct. Simply in the regular debugging cycle it becomes </div><div>obvious that this is needed: </div><div>connect dive computer, Subsurface-mobile pops up</div><div>try things out, fail</div><div>edit sources, rebuild, use adb over wifi to upload new version</div><div>if you now want to try things out in my model you'd have to unplug/replug the DC.</div><div><br class=""></div><div>So yeah, I decided to go your suggested route. And it turned out to be</div><div>surprisingly simple once I had wrapped  my mind around the machinations it</div><div>takes to unpack the java data structures.</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class="">If you look at the UsbDevice class and the struct libusb_device, they're<br class="">quite similar, so just lift over the values.<br class=""><br class="">I haven't dug down into it, but I'm guessing its actually libusb on the<br class="">other side of that UsbDevice class.<br class=""></div></div></blockquote><div><br class=""></div><div>There are quite a few similarities, but as I had pointed out, there are also a</div><div>fair number of things that are different / appear to be missing on the JNI side.</div><div><br class=""></div></div>My current NO WORKING code is in <a href="https://github.com/Subsurface-divelog/subsurface/pull/2309" class="">https://github.com/Subsurface-divelog/subsurface/pull/2309</a><div class=""><br class=""></div><div class="">It's based on your two patches to libusb - those didn't even compile, but</div><div class="">they were a great starting point and I added the parts that actually allows </div><div class="">us to assemble the devices array from android.cpp - and I added the JNI</div><div class="">code there to do just that.<br class=""><div class=""><br class=""></div><div class="">This gets pretty far. I can see my OSTC, and when I try to open it from </div><div class="">serial_ftdi.c we get pretty far and we don't fail with permission errors based </div><div class="">on file system access but instead there's an issue reading the configuration. </div><div class=""><br class=""></div><div class="">I even think I have an idea why that is - I'm guessing that I need to populate </div><div class="">more of the endpoint information somehow.</div><div class=""><br class=""></div><div class="">I'll be traveling the next two days and while I'll take the little dive computer</div><div class="">with me I am not convinced that I'll really have any time to work on this. So</div><div class="">if anyone else wants to poke at it, feel free to give it a go.</div><div class=""><br class=""></div><div class="">/D</div></div></body></html>