• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //! No-op implementation of the IVmCapabilitiesService.
18 
19 mod aidl;
20 
21 use crate::aidl::NoOpVmCapabilitiesService;
22 use anyhow::{bail, Context, Result};
23 use log::{error, info, LevelFilter};
24 use binder::{register_lazy_service, BinderFeatures, ProcessState};
25 use android_hardware_virtualization_capabilities_capabilities_service::aidl::android::hardware::virtualization::capabilities::IVmCapabilitiesService::BnVmCapabilitiesService;
26 
27 const SERVICE_NAME: &str = "android.hardware.virtualization.capabilities.IVmCapabilitiesService/noop";
28 
try_main() -> Result<()>29 fn try_main() -> Result<()> {
30     // Initialize Android logging.
31     android_logger::init_once(
32         android_logger::Config::default()
33             .with_tag("NoOpIVmCapabilitiesService")
34             .with_max_level(LevelFilter::Info)
35             .with_log_buffer(android_logger::LogId::System),
36     );
37 
38     ProcessState::start_thread_pool();
39     let service_impl = NoOpVmCapabilitiesService::init();
40     let service = BnVmCapabilitiesService::new_binder(service_impl, BinderFeatures::default());
41     register_lazy_service(SERVICE_NAME, service.as_binder())
42         .with_context(|| format!("failed to register {SERVICE_NAME}"))?;
43     info!("Registered Binder service, joining threadpool.");
44     ProcessState::join_thread_pool();
45     bail!("thread pool unexpectedly ended");
46 }
47 
main()48 fn main() {
49     if let Err(e) = try_main() {
50         error!("failed with {e:?}");
51         std::process::exit(1);
52     }
53 }
54