-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binder/AIDL content updates #1618
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really great! More depth than was there before, and I like the new notes you've incorporated. I think that covers most of what I've added off slides when I've taught this, but I'll think if there's anything else we should add.
...idl/birthday-service/birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl
Outdated
Show resolved
Hide resolved
@@ -1,4 +1,4 @@ | |||
// Copyright 2022 Google LLC | |||
// Copyright 2024 Google LLC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: 2022-2024
or just keep the original year?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new file I created, so I thought we'd want to use 2024 in the comment since that's when it's written?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using 2024 is correct for new files. My understanding is that we leave the years alone in existing files.
Way back when I first read about licenses for open source projects, the advice was to update the year of files that have received "significant changes" or so. Many projects just updated the year of every file in the beginning of the year. It's now my understanding that we don't do that, we just leave the files alone and only add new notices to new files.
src/android/aidl/birthday-service/birthday_service/src/client.rs
Outdated
Show resolved
Hide resolved
src/android/aidl/birthday-service/birthday_service/src/client.rs
Outdated
Show resolved
Hide resolved
src/android/aidl/birthday-service/birthday_service/src/client.rs
Outdated
Show resolved
Hide resolved
src/android/aidl/birthday-service/birthday_service/src/client.rs
Outdated
Show resolved
Hide resolved
59ebd7b
to
b7f4655
Compare
&self, | ||
provider: &SpIBinder, | ||
) -> binder::Result<String> { | ||
use binder::binder_impl::Proxy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this re-exported by binder
? If it's not but it's needed, we should fix that upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not currently appear to be re-exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, see the next comment.
| ---------------------- | ------------- | | ||
| `in` argument | `&[T]` | | ||
| `out`/`inout` argument | `&mut Vec<T>` | | ||
| Return | `Vec<T>` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also parcelable fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about parcelable fields? I'm not sure how that's relevant on this slide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm saying if you have a parcelable field that's an array, it will also use a Vec<T>
. E.g.
parcelable Foo {
int[] a;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense. I think I'll keep the slide specific to arrays in function signatures, but I'll add this to the speaker notes.
* Add speaker notes covering more details about how AIDL/Binder works. * Add examples of generated Rust bindings. * Flesh out the section on updating a Binder API.
* Add interface methods for passing binder objects and file descriptors. * Partially implement the Rust service/client/server changes for the updated AIDL definitions.
* Fix code in `client.rs` for sending Binder objects. * Add client code for sending a file descriptor.
3dea292
to
7eb9cb7
Compare
/// Call the birthday service. | ||
fn main() -> Result<(), binder::Status> { | ||
fn main() -> Result<(), Box<dyn Error>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope people don't start doing this in their production code. Otoh I'm not sure it's worth talking about anyhow
and thiserror
here.
&self, | ||
provider: &SpIBinder, | ||
) -> binder::Result<String> { | ||
use binder::binder_impl::Proxy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, see the next comment.
|
||
The array types (`T[]`, `byte[]`, and `List<T>`) get translated to the | ||
appropriate Rust array type depending on how they are used in the function | ||
signature: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this was the source of the confusion: types can occur in function signatures but also in parcelable field definitions. References are never used for the latter, because they would add lifetimes to the corresponding Rust types.
| --------- | --------- | ----------------------------------- | | ||
| `boolean` | `bool` | | | ||
| `byte` | `i8` | Note that bytes are signed. | | ||
| `char` | `u16` | Note the usage of `u16`, NOT `u32`. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending which language you come from, you'd expect a different type here: char
would be u8
coming from C, u16
from Java, or u32
from Rust. AIDL picked the Java option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, looks like I'm not allowed to approve the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving on behalf of Andrei 🚀
Thanks all for the much-needed updates here! 😄 Two ideas:
|
So far this PR makes two broad improvements to the Android course materials:
There are still additional changes to do (add an exercise, add a section on async binder), but those can be split into separate PRs if necessary.
This PR is still WIP because I need to test the code examples around the Binder types; Some of them are basically just psuedo-code at the moment.