Use LazyLock rather than lazy_static.
Bug: 364211748
Test: m virtmgr virtualizationservice libcompos_common libservice_vm_manager libvm_payload_rs
Change-Id: I3e92489a925709c3ab91968d1a38c9b52a54f3c5
diff --git a/android/virtmgr/src/aidl.rs b/android/virtmgr/src/aidl.rs
index 7a357f3..158c564 100644
--- a/android/virtmgr/src/aidl.rs
+++ b/android/virtmgr/src/aidl.rs
@@ -67,7 +67,6 @@
};
use cstr::cstr;
use glob::glob;
-use lazy_static::lazy_static;
use log::{debug, error, info, warn};
use microdroid_payload_config::{ApkConfig, Task, TaskType, VmPayloadConfig};
use nix::unistd::pipe;
@@ -86,7 +85,7 @@
use std::os::unix::io::{AsRawFd, IntoRawFd};
use std::os::unix::raw::pid_t;
use std::path::{Path, PathBuf};
-use std::sync::{Arc, Mutex, Weak};
+use std::sync::{Arc, Mutex, Weak, LazyLock};
use vbmeta::VbMetaImage;
use vmconfig::{VmConfig, get_debug_level};
use vsock::VsockStream;
@@ -119,13 +118,13 @@
const VM_REFERENCE_DT_ON_HOST_PATH: &str = "/proc/device-tree/avf/reference";
-lazy_static! {
- pub static ref GLOBAL_SERVICE: Strong<dyn IVirtualizationServiceInternal> =
+pub static GLOBAL_SERVICE: LazyLock<Strong<dyn IVirtualizationServiceInternal>> =
+ LazyLock::new(|| {
wait_for_interface(BINDER_SERVICE_IDENTIFIER)
- .expect("Could not connect to VirtualizationServiceInternal");
- static ref SUPPORTED_OS_NAMES: HashSet<String> =
- get_supported_os_names().expect("Failed to get list of supported os names");
-}
+ .expect("Could not connect to VirtualizationServiceInternal")
+ });
+static SUPPORTED_OS_NAMES: LazyLock<HashSet<String>> =
+ LazyLock::new(|| get_supported_os_names().expect("Failed to get list of supported os names"));
fn create_or_update_idsig_file(
input_fd: &ParcelFileDescriptor,