-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ca53547
Flesh out existing Binder content
randomPoison fcddc17
Move Birthday Service section into its own directory
randomPoison f634395
Add first pass at types section
randomPoison 8756902
Remove unused string.md
randomPoison 0d132ef
Add speaker notes for parcelables slide
randomPoison c94e0f2
Partially extend the BirthdayService example
randomPoison dc837fc
Fix binder object example
randomPoison 829a75c
Fixup and flesh out the objects slide
randomPoison 3af6844
Cleanup parcelables slide
randomPoison 6b6f112
Implement the service side of things
randomPoison af905af
Implement service side of wishFromFile
randomPoison dd6365d
Cleanup birthday service code examples
randomPoison dde7958
Reword birthday-service.md
randomPoison 1029f40
Re-organize birthday_service example
randomPoison 9cbe86f
Improve wording in speaker notes
randomPoison d76d7f4
Misc code review cleanup
randomPoison 7eb9cb7
Run formatter
randomPoison ea184a6
Normalize error handling in client.rs
randomPoison 2b87d25
Misc minor improvements
randomPoison 995005a
Remove comment about `vendor_available: true`
randomPoison bc415a1
Fix failing tests
randomPoison 2f51ba2
Add note about arrays in parcelables
randomPoison f517a4e
Use `into_interface` to downcast `SpIBinder`
randomPoison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Birthday Service Tutorial | ||
|
||
To illustrate how to use Rust with Binder, we're going to walk through the | ||
process of creating a Binder interface. We're then going to both implement the | ||
described service and write client code that talks to that service. |
6 changes: 6 additions & 0 deletions
6
src/android/aidl/birthday_service/aidl/com/example/birthdayservice/BirthdayInfo.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.birthdayservice; | ||
|
||
parcelable BirthdayInfo { | ||
String name; | ||
int years; | ||
} |
21 changes: 21 additions & 0 deletions
21
...android/aidl/birthday_service/aidl/com/example/birthdayservice/IBirthdayInfoProvider.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// ANCHOR: IBirthdayInfoProvider | ||
package com.example.birthdayservice; | ||
|
||
interface IBirthdayInfoProvider { | ||
String name(); | ||
int years(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Changing API | ||
|
||
Let us extend the API with more functionality: we want to let clients specify a | ||
list of lines for the birthday card: | ||
|
||
```java | ||
package com.example.birthdayservice; | ||
|
||
/** Birthday service interface. */ | ||
interface IBirthdayService { | ||
/** Generate a Happy Birthday message. */ | ||
String wishHappyBirthday(String name, int years, in String[] text); | ||
} | ||
``` | ||
|
||
This results in an updated trait definition for `IBirthdayService`: | ||
|
||
```rust,ignore | ||
trait IBirthdayService { | ||
fn wishHappyBirthday( | ||
&self, | ||
name: &str, | ||
years: i32, | ||
text: &[String], | ||
) -> binder::Result<String>; | ||
} | ||
``` | ||
|
||
<details> | ||
|
||
- Note how the `String[]` in the AIDL definition is translated as a `&[String]` | ||
in Rust, i.e. that idiomatic Rust types are used in the generated bindings | ||
wherever possible: | ||
- `in` array arguments are translated to slices. | ||
- `out` and `inout` args are translated to `&mut Vec<T>`. | ||
- Return values are translated to returning a `Vec<T>`. | ||
|
||
</details> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andthiserror
here.