Address comments from previous commit
This address late comments from following commit.
c03f6617 Enable microdroid console output with debug level or debug
policy
Bug: 268265510
Test: atest
Change-Id: I911b5cd4e0e3d56da76625f9246c31c00246c9ec
diff --git a/virtualizationmanager/src/aidl.rs b/virtualizationmanager/src/aidl.rs
index 1781007..abc8091 100644
--- a/virtualizationmanager/src/aidl.rs
+++ b/virtualizationmanager/src/aidl.rs
@@ -1025,13 +1025,12 @@
return Ok(Some(clone_file(fd)?));
}
- if let VirtualMachineConfig::AppConfig(app_config) = config {
- if !should_prepare_console_output(app_config.debugLevel) {
- return Ok(None);
- }
- } else {
+ let VirtualMachineConfig::AppConfig(app_config) = config else {
return Ok(None);
- }
+ };
+ if !should_prepare_console_output(app_config.debugLevel) {
+ return Ok(None);
+ };
let (raw_read_fd, raw_write_fd) = pipe().map_err(|e| {
Status::new_service_specific_error_str(-1, Some(format!("Failed to create pipe: {:?}", e)))
diff --git a/virtualizationmanager/src/debug_config.rs b/virtualizationmanager/src/debug_config.rs
index 332df08..e494040 100644
--- a/virtualizationmanager/src/debug_config.rs
+++ b/virtualizationmanager/src/debug_config.rs
@@ -22,13 +22,11 @@
/// Get debug policy value in bool. It's true iff the value is explicitly set to <1>.
fn get_debug_policy_bool(path: &'static str) -> Option<bool> {
- if let Ok(mut file) = File::open(path) {
- let mut log: [u8; 4] = Default::default();
- file.read_exact(&mut log).map_err(|_| false).unwrap();
- // DT spec uses big endian although Android is always little endian.
- return Some(u32::from_be_bytes(log) == 1);
- }
- None
+ let mut file = File::open(path).ok()?;
+ let mut log: [u8; 4] = Default::default();
+ file.read_exact(&mut log).ok()?;
+ // DT spec uses big endian although Android is always little endian.
+ Some(u32::from_be_bytes(log) == 1)
}
/// Get whether console output should be configred for VM to leave console and adb log.