mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 17:31:58 +00:00
error: field `0` is never read --> hardware/interfaces/security/authgraph/default/src/main.rs:34:24 | 34 | struct HalServiceError(String); | --------------- ^^^^^^ | | | field in this struct | = note: `HalServiceError` has derived impls for the traits `Clone` and `Debug`, but these are intenti onally ignored during dead code analysis = note: `-D dead-code` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(dead_code)]` help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 34 | struct HalServiceError(()); | ~~ error: aborting due to 1 previous error Test: ./build.py --lto thin bug: http://b/330185853 Change-Id: I08b79176fb5edea9e24990e4884e521c24660d68
82 lines
2.9 KiB
Rust
82 lines
2.9 KiB
Rust
/*
|
|
* Copyright (C) 2023 The Android Open Source Project
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
//! Default implementation of the AuthGraph key exchange HAL.
|
|
//!
|
|
//! This implementation of the HAL is only intended to allow testing and policy compliance. A real
|
|
//! implementation of the AuthGraph HAL would be implemented in a secure environment, and would not
|
|
//! be independently registered with service manager (a secure component that uses AuthGraph would
|
|
//! expose an entrypoint that allowed retrieval of the specific IAuthGraphKeyExchange instance that
|
|
//! is correlated with the component).
|
|
|
|
use authgraph_hal::service;
|
|
use authgraph_nonsecure::LocalTa;
|
|
use log::{error, info};
|
|
|
|
static SERVICE_NAME: &str = "android.hardware.security.authgraph.IAuthGraphKeyExchange";
|
|
static SERVICE_INSTANCE: &str = "nonsecure";
|
|
|
|
/// Local error type for failures in the HAL service.
|
|
#[derive(Debug, Clone)]
|
|
struct HalServiceError(String);
|
|
|
|
impl From<String> for HalServiceError {
|
|
fn from(s: String) -> Self {
|
|
Self(s)
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
if let Err(HalServiceError(e)) = inner_main() {
|
|
panic!("HAL service failed: {:?}", e);
|
|
}
|
|
}
|
|
|
|
fn inner_main() -> Result<(), HalServiceError> {
|
|
// Initialize Android logging.
|
|
android_logger::init_once(
|
|
android_logger::Config::default()
|
|
.with_tag("authgraph-hal-nonsecure")
|
|
.with_max_level(log::LevelFilter::Info)
|
|
.with_log_buffer(android_logger::LogId::System),
|
|
);
|
|
// Redirect panic messages to logcat.
|
|
std::panic::set_hook(Box::new(|panic_info| {
|
|
error!("{}", panic_info);
|
|
}));
|
|
|
|
info!("Insecure AuthGraph key exchange HAL service is starting.");
|
|
|
|
info!("Starting thread pool now.");
|
|
binder::ProcessState::start_thread_pool();
|
|
|
|
// Register the service
|
|
let local_ta = LocalTa::new().map_err(|e| format!("Failed to create the TA because: {e:?}"))?;
|
|
let service = service::AuthGraphService::new_as_binder(local_ta);
|
|
let service_name = format!("{}/{}", SERVICE_NAME, SERVICE_INSTANCE);
|
|
binder::add_service(&service_name, service.as_binder()).map_err(|e| {
|
|
format!(
|
|
"Failed to register service {} because of {:?}.",
|
|
service_name, e
|
|
)
|
|
})?;
|
|
|
|
info!("Successfully registered AuthGraph HAL services.");
|
|
binder::ProcessState::join_thread_pool();
|
|
info!("AuthGraph HAL service is terminating."); // should not reach here
|
|
Ok(())
|
|
}
|