Fix tests on aosp_cf_x86_64_only_phone
Our nested virtualization check failed on this target. Move to a
prefix check to support this device and any other ones that appear.
Also extract the code to do the check to a library, rather than
changing in two places.
Bug: 236922543
Test: Presubmit
Change-Id: Id1d424f5f107e2098d89ca2ea8089ba956f212ca
diff --git a/compos/common/timeouts.rs b/compos/common/timeouts.rs
index bdabb1e..d0d107f 100644
--- a/compos/common/timeouts.rs
+++ b/compos/common/timeouts.rs
@@ -18,7 +18,6 @@
//! virtualization.
use anyhow::Result;
-use rustutils::system_properties;
use std::time::Duration;
/// Holder for the various timeouts we use.
@@ -30,19 +29,10 @@
pub vm_max_time_to_ready: Duration,
}
-/// Whether the current platform requires extra time for operations inside a VM.
-pub fn need_extra_time() -> Result<bool> {
- // Nested virtualization is slow. Check if we are running on vsoc as a proxy for this.
- if let Some(value) = system_properties::read("ro.build.product")? {
- Ok(value == "vsoc_x86_64" || value == "vsoc_x86")
- } else {
- Ok(false)
- }
-}
-
/// Return the timeouts that are appropriate on the current platform.
pub fn timeouts() -> Result<&'static Timeouts> {
- if need_extra_time()? {
+ // Nested virtualization is slow.
+ if nested_virt::is_nested_virtualization()? {
Ok(&EXTENDED_TIMEOUTS)
} else {
Ok(&NORMAL_TIMEOUTS)
@@ -50,14 +40,14 @@
}
/// The timeouts that we use normally.
-pub const NORMAL_TIMEOUTS: Timeouts = Timeouts {
+const NORMAL_TIMEOUTS: Timeouts = Timeouts {
// Note: the source of truth for these odrefresh timeouts is art/odrefresh/odr_config.h.
odrefresh_max_execution_time: Duration::from_secs(300),
vm_max_time_to_ready: Duration::from_secs(15),
};
/// The timeouts that we use when need_extra_time() returns true.
-pub const EXTENDED_TIMEOUTS: Timeouts = Timeouts {
+const EXTENDED_TIMEOUTS: Timeouts = Timeouts {
odrefresh_max_execution_time: Duration::from_secs(480),
vm_max_time_to_ready: Duration::from_secs(120),
};