Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Update the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nical committed Jun 27, 2022
1 parent fcffabd commit ba24d92
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
3 changes: 0 additions & 3 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ set -e
adb shell reboot

cargo check --target=aarch64-linux-android
cargo check --target=aarch64-linux-android
cargo check --target=aarch64-linux-android --features "bionic-deprecated"
cargo check --target=aarch64-linux-android --examples --features "bionic-deprecated"
cargo build --target=aarch64-linux-android --examples
cargo doc
cargo test
Expand Down
7 changes: 5 additions & 2 deletions examples/property_foreach.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use android_properties::AndroidProperties;

fn main() {
for property in android_properties::prop_values() {
println!("{}", property);
let properties = AndroidProperties::new();
for property in properties.property_values() {
println!("{:?}", properties.get(&property));
}
}
11 changes: 7 additions & 4 deletions examples/property_get.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use android_properties::AndroidProperty;
use android_properties::{AndroidProperties, AndroidProperty};

const HELLO_WORLD_PROPERTY: &str = "hello.world";

fn main() {
let mut hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
match hello_world.value() {
Some(_value) => println!("{}", hello_world),
let properties = AndroidProperties::new();
let hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
properties.set(&hello_world, "bonjour").unwrap();

match properties.get(&hello_world) {
Some(value) => println!("{:?}", value),
None => println!("Property {} not found", hello_world.name()),
};
}
13 changes: 8 additions & 5 deletions examples/property_refresh.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use android_properties::{setprop, AndroidProperty};
use android_properties::{AndroidProperties, AndroidProperty};

const HELLO_WORLD_PROPERTY: &str = "hello.world";

fn main() {
setprop(HELLO_WORLD_PROPERTY, "initial value").expect("Cannot set android property");
let properties = AndroidProperties::new();

properties.set_property(HELLO_WORLD_PROPERTY, "initial value").expect("Cannot set android property");

let hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
println!("Initial property: {}", hello_world);
println!("Initial property: {:?}", properties.get(&hello_world));

setprop(HELLO_WORLD_PROPERTY, "refreshed value").expect("Cannot set android property");
println!("Refreshed property: {}", hello_world);
properties.set_property(HELLO_WORLD_PROPERTY, "refreshed value").expect("Cannot set android property");
println!("Refreshed property: {:?}", properties.get(&hello_world));
}
5 changes: 4 additions & 1 deletion examples/property_set.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use android_properties::AndroidProperties;

fn main() {
android_properties::setprop("hello.world", "hello").expect("Cannot set android property");
let properties = AndroidProperties::new();
properties.set_property("hello.world", "hello").expect("Cannot set android property");
}

0 comments on commit ba24d92

Please sign in to comment.