AIDL methods and interfaces marked with the "oneway" keyword are asynchronous Binder calls for remote processes, and it is said that the ordering of the calls is not guaranteed. On the other hand, the last comment of Dianne Hackborn (author of Binder) in this thread ( https://groups.google.com/forum/#!topic/android-developers/FFY-hg2Jx0M) says:
"ordering of delivery is tied to the target object (so you can receive calls on different interfaces out of order)"
Which seems to suggest, that calls to the same interface keep their order.
Can anyone clarify this?
As a general rule, oneway calls are asynchronous and can be dispatched on different threads concurrently with no ordering guarantees. However, the system imposes special ordering guarantees on oneway calls happening on the same
IBinder
object: in this case the transactions will be dispatched one at a time, in order of the original calls. Note that this ordering only applies in the specific case of oneway calls on the sameIBinder
object. Anything else -- calls on differentIBinder
objects or mixing oneway and sync calls -- will not give you any ordering guarantees between them.The way this work is that in the kernel each
IBinder
object has a queue of oneway transactions to dispatch. A oneway call adds to that queue (a non-oneway call bypasses the queue). Transactions are dispatched out of the queue one at a time, as each previous transaction completes. So you may see these calls being dispatched on different threads, but the system makes sure that only one is executing at a time. (Again only for a singleIBinder
object, oneway calls on two differentIBinder
objects can execute concurrently.)