Add support for checking whether feature is enabled on device
In case of AVF development most of the features will be protected for
build time flags, meaning that we need to provide a way for tests to
query whether device build actually has the feature enabled.
This is achieved by providing isFeatureEnabled @TestApi. As part of this
change I've also switched the payloadIsNotRoot test to use this new API
as an example of how the API can be used in tests.
Bug: 298012279
Bug: 298008232
Test: atest MicrodroidTests
Change-Id: If9afc013e178439f45627c1ac7dfe50242799f09
diff --git a/virtualizationmanager/src/aidl.rs b/virtualizationmanager/src/aidl.rs
index 97151d7..1ddf129 100644
--- a/virtualizationmanager/src/aidl.rs
+++ b/virtualizationmanager/src/aidl.rs
@@ -34,6 +34,7 @@
IVirtualMachine::{BnVirtualMachine, IVirtualMachine},
IVirtualMachineCallback::IVirtualMachineCallback,
IVirtualizationService::IVirtualizationService,
+ IVirtualizationService::FEATURE_PAYLOAD_NON_ROOT,
MemoryTrimLevel::MemoryTrimLevel,
Partition::Partition,
PartitionType::PartitionType,
@@ -264,6 +265,21 @@
// Delegate to the global service, including checking the permission.
GLOBAL_SERVICE.getAssignableDevices()
}
+
+ /// Returns whether given feature is enabled
+ fn isFeatureEnabled(&self, feature: &str) -> binder::Result<bool> {
+ check_manage_access()?;
+
+ // This approach is quite cumbersome, but will do the work for the short term.
+ // TODO(b/298012279): make this scalable.
+ match feature {
+ FEATURE_PAYLOAD_NON_ROOT => Ok(cfg!(payload_not_root)),
+ _ => {
+ warn!("unknown feature {}", feature);
+ Ok(false)
+ }
+ }
+ }
}
impl VirtualizationService {