Can an Android app work with a native Android service using sockets?

I'm trying to get an Android application to talk to a native service (either a compiled binary of ARM or a Linux script), and I wonder if I can do this using sockets?

In principle, the native service will be launched during initialization and wait for the application to send data before doing any other things.

Is this possible, and does this Android app need root privileges?

Thanks.

+4
source share
1 answer

Yes it is possible. And no, the application does not need any special permissions for this - for a unix domain socket, you do not even need an Internet permission.

The only place where you need special permission will be what starts the service - in fact, you have to give it the values โ€‹โ€‹of the oom killer, which will tell the android to leave this process alone, and / or set it to automatically configure, re-set launch. Otherwise, the resource-limited Android system may destroy a secret process that does not appear to be related to any particular legitimate activity or service.

More android-style integration tools, of course, would be to implement your service more than existing Android services, i.e. using the api stub, which starts in the client process and pushes things through the IPC Binder to a service running in a special (possibly a system process). It can also make it easier to regulate access to your service using the existing package / manifest resolution scheme. But this is ultimately a stylistic thing, and although it may be to some extent related to the acquisition by Google of your device, this is not the only way to make something that works.

+4
source

Source: https://habr.com/ru/post/1416281/


All Articles