Query for /default and /strongbox IRPCs directly
This removes the need to query for and call find on all IRPCs.
Bug: 312427637
Test: atest -p --include-subdirs system/security/keystore2
Change-Id: I8893627e983eac577b9920497f926f12c0e98271
diff --git a/keystore2/src/globals.rs b/keystore2/src/globals.rs
index 2d5c20a..c7b495d 100644
--- a/keystore2/src/globals.rs
+++ b/keystore2/src/globals.rs
@@ -44,8 +44,8 @@
};
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_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
}