Android IPC localsocket and binder (Aidl)
I hope every application can send data to my service. Therefore, I need interprocess communication. Messenger, Aidl or intentions (broadcastreceiver) are recommended for every page I can find. So far, I can make it clear by building some test applications that if multiple threads are sent in a while (true) loop, Broadcastreceiver will be very slow, and messages may be lost without notification. Aidl and messenger are not only complex to implement (services, binders, etc.), but also may provide strange behavior. For example, when sending multiple threads leads to RemoteException (!!! Failed binder transaction!!!) in Aidl, one-way keyword is used. I want to ensure delivery. When delivery should be guaranteed, Is there even reason to use it alone?
Nevertheless, localsocket seems to be very easy to use (no service is required, just like java socket). Client applications can only open localsocket, connect to the provided address, and then while (true) OutputStream. Writeobject()
What are the disadvantages of using localsocket? Android developers say on the page: "some applications try to use traditional Linux technologies (such as network sockets and shared files) to implement IPC. We strongly recommend that you use Android system functions for IPC instead", but do not make further comments on this page
resolvent:
>Localsocket has no security at the framework level. Although you may "want every application to send data to my service", users may not, which is why standard IPC can be protected by permissions. > startservice() and bindservice() will lead to the creation of service instances and even start a process for you when necessary, Your service will not run all the time. Therefore, you need startservice () or bindservice () anyway