I’m trying to get an android app to talk to a native service (either a cross-compiled ARM binary or a Linux script), and I’m wondering if I can do this using sockets?
Basically, the native service will run upon init, and wait for the app to send it data before doing some other stuff.
Is this possible, and does the android app need root permissions to do this?
Thanks.
Yes, it’s possible. And no, the app does not need any special permission to do so – for a unix domain socket, you do not even need internet permission.
The only place where you would need special permission would be in what launches the service – essentially, you have to give it oom killer values that will tell android to leave that process alone, and/or set it up to be auto-restarting. Otherwise a resource constrained android system could kill off a mystery process that doesn’t seem linked to any particular legitimate activity or service.
A more android-style means of integration would of course be to implement your service more like existing android services, ie, with a stub api that runs in the client process and pushes things through Binder IPC to a service running in a special process (quite possibly the system process). This might also make it easier to regulate access to your service using the existing package/manifest permission scheme. But it’s ultimately a stylistic thing, and while perhaps to some degree linked to gaining Google acceptance of your device, that is not the only way to make something which works.