Seungjae Yoo | 529d53c | 2024-05-14 14:36:18 +0900 | [diff] [blame] | 1 | // Copyright 2024 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | //! Android Vmnic (Virtual Machine Network Interface Creator) |
| 16 | |
| 17 | mod aidl; |
| 18 | |
| 19 | use crate::aidl::Vmnic; |
| 20 | use android_logger::Config; |
| 21 | use android_system_virtualizationservice_internal::aidl::android::system::virtualizationservice_internal::IVmnic::{ |
| 22 | BnVmnic, |
| 23 | BpVmnic, |
| 24 | IVmnic, |
| 25 | }; |
| 26 | use binder::{register_lazy_service, BinderFeatures, ProcessState}; |
| 27 | use log::{info, LevelFilter}; |
| 28 | |
| 29 | const LOG_TAG: &str = "Vmnic"; |
| 30 | |
| 31 | fn main() { |
| 32 | android_logger::init_once( |
| 33 | Config::default() |
| 34 | .with_tag(LOG_TAG) |
| 35 | .with_max_level(LevelFilter::Info) |
| 36 | .with_log_buffer(android_logger::LogId::System), |
| 37 | ); |
| 38 | |
| 39 | let service = Vmnic::init(); |
| 40 | let service = BnVmnic::new_binder(service, BinderFeatures::default()); |
| 41 | register_lazy_service(<BpVmnic as IVmnic>::get_descriptor(), service.as_binder()).unwrap(); |
| 42 | info!("Registered Binder service, joining threadpool."); |
| 43 | ProcessState::join_thread_pool(); |
| 44 | } |