1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-02-04 18:36:01 +02:00

Misc. Android Improvements (#2325)

- Add missing package declaration on the AIDL interface slide.
- Make the parcelable example more self-contained. The existing code was
referencing variables that weren't declared in the example code.
- Add a speaker note to the logging slide about explaining that the
logger implementation is only needed in binaries, and that just the log
facade is needed in libraries.
This commit is contained in:
Nicole L 2024-09-17 09:09:07 -07:00 committed by GitHub
parent 9c16b36b5e
commit d2bc223a06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 3 deletions

View File

@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// ANCHOR: package
package com.example.birthdayservice;
// ANCHOR_END: package
import com.example.birthdayservice.IBirthdayInfoProvider;
import com.example.birthdayservice.BirthdayInfo;

View File

@ -43,9 +43,7 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("{msg}");
// ANCHOR_END: main
// ANCHOR: wish_with_info
service.wishWithInfo(&BirthdayInfo { name: name.clone(), years })?;
// ANCHOR_END: wish_with_info
// ANCHOR: wish_with_provider

View File

@ -5,6 +5,8 @@ You declare the API of your service using an AIDL interface:
_birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl_:
```java
{{#include ../birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl:package}}
{{#include ../birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl:IBirthdayService}}
}
```

View File

@ -25,6 +25,7 @@ fn main() {
binder::ProcessState::start_thread_pool();
let service = connect().expect("Failed to connect to BirthdayService");
{{#include ../birthday_service/src/client.rs:wish_with_info}}
let info = BirthdayInfo { name: "Alice".into(), years: 123 };
service.wishWithInfo(&info)?;
}
```

View File

@ -32,3 +32,10 @@ adb logcat -s rust
09-08 08:38:32.454 2420 2420 I rust: hello_rust_logs: Things are going fine.
09-08 08:38:32.454 2420 2420 E rust: hello_rust_logs: Something went wrong!
```
<details>
- The logger implementation in `liblogger` is only needed in the final binary,
if you're logging from a library you only need the `log` facade crate.
</details>