diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-03 23:07:08 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-03 23:07:08 +0000 |
commit | 2532cae5f6c62e990c773f8fc94090de08edfd2e (patch) | |
tree | 511e02af3e7c742f91248edf54330984f8386060 | |
parent | ed467e7c7cc4f2b56c7fc2beb9223b1bd0b8d75f (diff) | |
parent | 084270e3d29d96c8786a1bfc05138de34f2944fc (diff) | |
download | uwb-2532cae5f6c62e990c773f8fc94090de08edfd2e.tar.gz |
Snap for 8534619 from 084270e3d29d96c8786a1bfc05138de34f2944fc to tm-release
Change-Id: If6e1dbb4520bdb3f92fb877b8e8aa9fa81035539
-rwxr-xr-x | src/Android.bp | 64 | ||||
-rw-r--r-- | src/rust/adaptation/mod.rs | 36 | ||||
-rw-r--r-- | src/rust/lib.rs | 1 |
3 files changed, 73 insertions, 28 deletions
diff --git a/src/Android.bp b/src/Android.bp index d6cfa15..5fca6f6 100755 --- a/src/Android.bp +++ b/src/Android.bp @@ -21,12 +21,18 @@ rust_defaults { "liblog_rust", "liblogger", "libnum_traits", - "librustutils", "libthiserror", "libtokio", "libuwb_uci_packets", - "libbinder_tokio_rs", + "libbinder_tokio_rs", ], + target: { + android: { + rustlibs: [ + "librustutils", + ], + }, + }, rlibs: [ "libarbitrary", ], @@ -37,6 +43,7 @@ rust_defaults { "com.android.uwb", ], min_sdk_version: "Tiramisu", + host_supported: true, } rust_library { @@ -47,11 +54,29 @@ rust_library { rust_test { name: "libuwb_uci_rust_tests", defaults: ["libuwb_uci_defaults"], - test_suites: [ - "general-tests", - "mts-uwb" - ], - test_config_template: "uwb_rust_test_config_template.xml", + target: { + android: { + test_suites: [ + "general-tests", + "mts-uwb" + ], + test_config_template: "uwb_rust_test_config_template.xml", + }, + host: { + test_suites: [ + "general-tests", + ], + data_libs: [ + "libandroid_runtime_lazy", + "libbase", + "libbinder", + "libbinder_ndk", + "libcutils", + "liblog", + "libutils", + ], + }, + }, // Support multilib variants (using different suffix per sub-architecture), which is needed on // build targets with secondary architectures, as the MTS test suite packaging logic flattens // all test artifacts into a single `testcases` directory. @@ -80,16 +105,26 @@ rust_defaults { "libnum_traits", "libthiserror", ], + host_supported: true, } rust_test { name: "libuwb_uci_packet_tests", defaults: ["libuwb_uci_packet_defaults"], - test_suites: [ - "general-tests", - "mts-uwb" - ], - test_config_template: "uwb_rust_test_config_template.xml", + target: { + android: { + test_suites: [ + "general-tests", + "mts-uwb" + ], + test_config_template: "uwb_rust_test_config_template.xml", + }, + host: { + test_suites: [ + "general-tests", + ], + }, + }, // Support multilib variants (using different suffix per sub-architecture), which is needed on // build targets with secondary architectures, as the MTS test suite packaging logic flattens // all test artifacts into a single `testcases` directory. @@ -103,11 +138,6 @@ rust_test { }, }, auto_gen_config: true, - rustlibs:[ - "android.hardware.uwb-V1-rust", - "liblog_rust", - "libuwb_uci_rust", - ], } rust_library { diff --git a/src/rust/adaptation/mod.rs b/src/rust/adaptation/mod.rs index 4f017fd..a650810 100644 --- a/src/rust/adaptation/mod.rs +++ b/src/rust/adaptation/mod.rs @@ -17,7 +17,8 @@ use android_hardware_uwb::binder::{ use async_trait::async_trait; use binder::IBinder; use binder_tokio::{Tokio, TokioRuntime}; -use log::{error, warn}; +use log::error; +#[cfg(target_os = "android")] use rustutils::system_properties; use std::sync::Arc; use tokio::runtime::Handle; @@ -112,18 +113,15 @@ pub struct UwbAdaptationImpl { } impl UwbAdaptationImpl { - async fn new_with_args( - rsp_sender: mpsc::UnboundedSender<HalCallback>, - hal: Strong<dyn IUwbChipAsync<Tokio>>, - hal_death_recipient: Arc<Mutex<DeathRecipient>>, - ) -> Result<Self> { - let mode = match system_properties::read("persist.uwb.uci_logger_mode") { + #[cfg(target_os = "android")] + fn get_uci_log_mode() -> UciLogMode { + match system_properties::read("persist.uwb.uci_logger_mode") { Ok(Some(logger_mode)) => match logger_mode.as_str() { "disabled" => UciLogMode::Disabled, "filtered" => UciLogMode::Filtered, "enabled" => UciLogMode::Enabled, str => { - warn!("Logger mode not recognized! Value: {:?}", str); + error!("Logger mode not recognized! Value: {:?}", str); UCI_LOG_DEFAULT } }, @@ -132,9 +130,25 @@ impl UwbAdaptationImpl { error!("Failed to get uci_logger_mode {:?}", e); UCI_LOG_DEFAULT } - }; - let logger = - UciLoggerImpl::new(mode, Arc::new(Mutex::new(RealFileFactory::default()))).await; + } + } + + #[cfg(not(target_os = "android"))] + fn get_uci_log_mode() -> UciLogMode { + // system_properties is not supported on host builds. + UCI_LOG_DEFAULT + } + + async fn new_with_args( + rsp_sender: mpsc::UnboundedSender<HalCallback>, + hal: Strong<dyn IUwbChipAsync<Tokio>>, + hal_death_recipient: Arc<Mutex<DeathRecipient>>, + ) -> Result<Self> { + let logger = UciLoggerImpl::new( + UwbAdaptationImpl::get_uci_log_mode(), + Arc::new(Mutex::new(RealFileFactory::default())), + ) + .await; Ok(UwbAdaptationImpl { hal, rsp_sender, logger: Arc::new(logger), hal_death_recipient }) } diff --git a/src/rust/lib.rs b/src/rust/lib.rs index d42e060..e9f3dbe 100644 --- a/src/rust/lib.rs +++ b/src/rust/lib.rs @@ -16,6 +16,7 @@ // TODO remove this and add appropriate documentation once it is decided whether this stays here or // moves into packages/modules/Uwb #![allow(missing_docs)] +#![feature(rustc_private)] pub mod adaptation; pub mod error; |