Discussion:
fun with Intents on Android
Dirk Hohndel
2018-08-06 03:47:46 UTC
Permalink
I had wanted to push this for a while but never got around to it.

I did the first baby steps of better Android device integration. If the user plugs in a device that we have registered our interested in (like an FTDI dive computer), Subsurface-mobile actually gets notified.
The easiest thing we can do is at least log the information, duh. That's what I have implemented so far. But the next step could be to switch to the download screen (unless the user was doing something useful like editing / adding a dive) and select the device that was plugged in (assuming we can figure out what it is).
Hopefully this will also be the first tiny step to the much more important work of allowing Subsurface-mobile on Android to access serial devices even on modern phones that don't allow us access to the /dev directory. My first simplistic brute force way of doing that predictably failed. This will require a bit more careful thought and modification of the libraries that we use - which simply assume that it's ok to access '/dev'...

Anyway, for those who are curious and want to take a look - I didn't push this into master, yet, it's in the androidIntent branch on GitHub.
Anton, I'd love to hear what you think about the work so far and if you think this is the right direction, we can merge this into master.

/D
Anton Lundin
2018-08-06 21:42:06 UTC
Permalink
Post by Dirk Hohndel
I had wanted to push this for a while but never got around to it.
I did the first baby steps of better Android device integration. If the user plugs in a device that we have registered our interested in (like an FTDI dive computer), Subsurface-mobile actually gets notified.
The easiest thing we can do is at least log the information, duh. That's what I have implemented so far. But the next step could be to switch to the download screen (unless the user was doing something useful like editing / adding a dive) and select the device that was plugged in (assuming we can figure out what it is).
Hopefully this will also be the first tiny step to the much more important work of allowing Subsurface-mobile on Android to access serial devices even on modern phones that don't allow us access to the /dev directory. My first simplistic brute force way of doing that predictably failed. This will require a bit more careful thought and modification of the libraries that we use - which simply assume that it's ok to access '/dev'...
Anyway, for those who are curious and want to take a look - I didn't push this into master, yet, it's in the androidIntent branch on GitHub.
Anton, I'd love to hear what you think about the work so far and if you think this is the right direction, we can merge this into master.
There are actually nothing digging around in the /dev/ directory now.
That stopped working a long time ago, and doesn't work in any "modern"
android devices, like API 15+ or something. Thats why we patch libusb
and use get_usb_fd to have android services open the device for us and
pass us the fd.


What we are using, is things in /sys, and thats all libusb things.
libusb have different backends for discovering usb devices and the one
that works reasonably on android is the /sys thingie. This is all ok in
the standard ASOP selinux profiles, but some manufactures have on some
devices changed those profiles so libusb doesn't work as we expect.


We might be able to work around this issue by using another ftdi
function, like ftdi_usb_open_dev and that way we might not need to
have libusb dig around in /sys.



A compleatly orthogonal solution would be ditching libusb, libftdi and
our current custom serial and write a new one based on jni'ing into
https://github.com/mik3y/usb-serial-for-android .



//Anton
--
Anton Lundin +46702-161604
Loading...