Ignore debug policy with sysprop
Read system property hypervisor.virtualizationmanager.debug_policy.path
to decide whether to ignore debug policy or not.
Follow-up CLs will use the system property to disable debug policy for
tests and also allows to set custom debug policy for debug policy test.
Bug: 272496125, Bug: 275047565
Test: Run following tests twice with/without the sysprop \
1) `atest MicrodroidTestApp MicrodroidHostTestCases` for \
checking no regression. \
2) Launched VM on a debug policy enabled device without debug level
Change-Id: I9f3a829c84a55441942953979e3aec893c0405fd
diff --git a/virtualizationmanager/src/payload.rs b/virtualizationmanager/src/payload.rs
index 99aea01..33659d4 100644
--- a/virtualizationmanager/src/payload.rs
+++ b/virtualizationmanager/src/payload.rs
@@ -14,7 +14,7 @@
//! Payload disk image
-use crate::debug_config::should_include_debug_apexes;
+use crate::debug_config::DebugConfig;
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::{
DiskImage::DiskImage,
Partition::Partition,
@@ -257,6 +257,7 @@
/// ..
fn make_payload_disk(
app_config: &VirtualMachineAppConfig,
+ debug_config: &DebugConfig,
apk_file: File,
idsig_file: File,
vm_payload_config: &VmPayloadConfig,
@@ -274,8 +275,7 @@
let apex_list = pm.get_apex_list(vm_payload_config.prefer_staged)?;
// collect APEXes from config
- let mut apex_infos =
- collect_apex_infos(&apex_list, &vm_payload_config.apexes, app_config.debugLevel);
+ let mut apex_infos = collect_apex_infos(&apex_list, &vm_payload_config.apexes, debug_config);
// Pass sorted list of apexes. Sorting key shouldn't use `path` because it will change after
// reboot with prefer_staged. `last_update_seconds` is added to distinguish "samegrade"
@@ -380,10 +380,10 @@
fn collect_apex_infos<'a>(
apex_list: &'a ApexInfoList,
apex_configs: &[ApexConfig],
- debug_level: DebugLevel,
+ debug_config: &DebugConfig,
) -> Vec<&'a ApexInfo> {
let mut additional_apexes: Vec<&str> = MICRODROID_REQUIRED_APEXES.to_vec();
- if should_include_debug_apexes(debug_level) {
+ if debug_config.should_include_debug_apexes() {
additional_apexes.extend(MICRODROID_REQUIRED_APEXES_DEBUG.to_vec());
}
@@ -437,6 +437,7 @@
pub fn add_microdroid_payload_images(
config: &VirtualMachineAppConfig,
+ debug_config: &DebugConfig,
temporary_directory: &Path,
apk_file: File,
idsig_file: File,
@@ -445,6 +446,7 @@
) -> Result<()> {
vm_config.disks.push(make_payload_disk(
config,
+ debug_config,
apk_file,
idsig_file,
vm_payload_config,
@@ -582,7 +584,7 @@
ApexConfig { name: "{CLASSPATH}".to_string() },
];
assert_eq!(
- collect_apex_infos(&apex_info_list, &apex_configs, DebugLevel::FULL),
+ collect_apex_infos(&apex_info_list, &apex_configs, &DebugConfig::new(DebugLevel::FULL)),
vec![
// Pass active/required APEXes
&apex_info_list.list[0],