Reputation: 195
I read the docs on Android Developer about IBinder/Binder.
It says
The Binder system also supports recursion across processes. For example if process A performs a transaction to process B, and process B while handling that transaction calls transact() on an IBinder that is implemented in A, then the thread in A that is currently waiting for the original transaction to finish will take care of calling Binder.onTransact() on the object being called by B. This ensures that the recursion semantics when calling remote binder object are the same as when calling local objects.
I have two questions about this
then the thread in A that is currently waiting for the original transaction to finish will take care of calling Binder.onTransact() on the object being called by B
First, how can a blocked thread be notified to do other stuff other than original procedure?
Second, After the thread finishes the onTransact()
, will it block again to wait for original transaction.
Upvotes: 2
Views: 423
Reputation: 40357
First, How can a blocked thread be notified to do other stuff other than original procedure?
Binder is meant to abstract out the process of IPC, hence this question essentially simplifies to "how can a called function call a function before returning". Since that is clearly possible, and sensible, it should work with Binder too.
Implementation wise, it would be done by interpreting the data received from the binder transaction operation - if that is an encoding of "call this method for me" rather than "your return value is" then that is what will happen.
Second, After the thread finishes the onTransact(), will it block again to wait for original transaction.
Yes, because the method called out of the code that handles binder transactions will eventually return there (unless there's an exception, process death, signal or similar)
Upvotes: 1