Skip to content

Commit

Permalink
Add note about AIDL methods taking &self
Browse files Browse the repository at this point in the history
  • Loading branch information
randomPoison committed Feb 12, 2025
1 parent 699c513 commit d0a12a8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/android/aidl/example-service/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ _birthday_service/Android.bp_:

- Point out the path to the generated `IBirthdayService` trait, and explain why
each of the segments is necessary.
- Note that `wishHappyBirthday` and other AIDL IPC methods take `&self` (instead
of `&mut self`).
- This is necessary because binder responds to incoming requests on a thread
pool, allowing for multiple requests to be processed in parallel. This
requires that the service methods only get a shared reference to `self`.
- Any state that needs to be modified by the service will have to be put in
something like a `Mutex` to allow for safe mutation.
- The correct approach for managing service state depends heavily on the
details of your service.
- TODO: What does the `binder::Interface` trait do? Are there methods to
override? Where source?

Expand Down

0 comments on commit d0a12a8

Please sign in to comment.