Files
hardware_interfaces/uwb/aidl/default/src/service.rs
Jeff Vander Stoep e8934d0991 Replace use of deprecated logging functions
This is needed to upgrade the android_logger crate from 0.12.0
to 0.13.3.

with_max_level provides the same functionality as with_min_level.
The renaming is admittedly confusing, but the new name is accurate
and it makes sense that they deprecated and then removed the
previously poorly named with_min_level.

See crate documentation [1] and code [2].

[1]: https://docs.rs/android_logger/0.12.0/android_logger/struct.Config.html#method.with_min_level
[2]: https://docs.rs/android_logger/0.12.0/src/android_logger/lib.rs.html#227

Bug: 322718401
Test: build and run CF with the change.
Test: m aosp_cf_x86_64_phone
Change-Id: I0ca9596433967be70e9d55acb6cfbf9322741bf8
2024-01-31 10:49:31 +01:00

48 lines
1.1 KiB
Rust

use android_hardware_uwb::aidl::android::hardware::uwb::IUwb::{self, IUwb as _};
use android_hardware_uwb::binder;
use tokio::runtime::Runtime;
use std::env;
use std::panic;
use log::LevelFilter;
mod uwb;
mod uwb_chip;
fn main() -> anyhow::Result<()> {
logger::init(
logger::Config::default()
.with_max_level(LevelFilter::Debug)
.with_tag_on_device("android.hardware.uwb"),
);
// Redirect panic messages to logcat.
panic::set_hook(Box::new(|panic_info| {
log::error!("{}", panic_info);
}));
log::info!("UWB HAL starting up");
// Create the tokio runtime
let rt = Runtime::new()?;
let chips = env::args()
.skip(1) // Skip binary name
.enumerate()
.map(|(i, arg)| uwb_chip::UwbChip::new(i.to_string(), arg));
binder::add_service(
&format!("{}/default", IUwb::BpUwb::get_descriptor()),
IUwb::BnUwb::new_binder(
uwb::Uwb::from_chips(chips, rt.handle().clone()),
binder::BinderFeatures::default(),
)
.as_binder(),
)?;
binder::ProcessState::join_thread_pool();
Ok(())
}