Merge "Query for /default and /strongbox IRPCs directly" into main

This commit is contained in:
Karuna Wadhera 2024-06-10 17:46:06 +00:00 committed by Gerrit Code Review
commit 77eb25fc04

View file

@ -44,8 +44,8 @@ use android_hardware_security_secureclock::aidl::android::hardware::security::se
};
use android_security_compat::aidl::android::security::compat::IKeystoreCompatService::IKeystoreCompatService;
use anyhow::{Context, Result};
use binder::get_declared_instances;
use binder::FromIBinder;
use binder::{get_declared_instances, is_declared};
use lazy_static::lazy_static;
use std::sync::{Arc, Mutex, RwLock};
use std::{cell::RefCell, sync::Once};
@ -420,19 +420,20 @@ pub fn get_timestamp_service() -> Result<Strong<dyn ISecureClock>> {
pub fn get_remotely_provisioned_component_name(security_level: &SecurityLevel) -> Result<String> {
let remote_prov_descriptor: &str =
<BpRemotelyProvisionedComponent as IRemotelyProvisionedComponent>::get_descriptor();
let remotely_prov_instances = get_declared_instances(remote_prov_descriptor).unwrap();
match *security_level {
SecurityLevel::TRUSTED_ENVIRONMENT => {
if remotely_prov_instances.iter().any(|instance| *instance == "default") {
Some(format!("{}/default", remote_prov_descriptor))
let instance = format!("{}/default", remote_prov_descriptor);
if is_declared(&instance)? {
Some(instance)
} else {
None
}
}
SecurityLevel::STRONGBOX => {
if remotely_prov_instances.iter().any(|instance| *instance == "strongbox") {
Some(format!("{}/strongbox", remote_prov_descriptor))
let instance = format!("{}/strongbox", remote_prov_descriptor);
if is_declared(&instance)? {
Some(instance)
} else {
None
}