Alan Stokes | 3ef78d9 | 2021-09-08 11:51:06 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 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 | //! Exposes an on-demand binder service to perform system compilation tasks using CompOS. It is |
| 18 | //! responsible for managing the lifecycle of the CompOS VM instances, providing key management for |
| 19 | //! them, and orchestrating trusted compilation. |
| 20 | |
| 21 | mod service; |
| 22 | |
| 23 | use android_system_composd::binder::{register_lazy_service, ProcessState}; |
| 24 | use anyhow::{Context, Result}; |
| 25 | use log::{error, info}; |
| 26 | |
| 27 | fn try_main() -> Result<()> { |
| 28 | android_logger::init_once( |
| 29 | android_logger::Config::default().with_tag("composd").with_min_level(log::Level::Info), |
| 30 | ); |
| 31 | |
| 32 | let service = service::new_binder(); |
| 33 | register_lazy_service("android.system.composd", service.as_binder()) |
| 34 | .context("Registering service")?; |
| 35 | |
| 36 | info!("Registered service, joining threadpool"); |
| 37 | ProcessState::join_thread_pool(); |
| 38 | |
| 39 | info!("Exiting"); |
| 40 | Ok(()) |
| 41 | } |
| 42 | |
| 43 | fn main() { |
| 44 | if let Err(e) = try_main() { |
| 45 | error!("{}", e); |
| 46 | std::process::exit(1) |
| 47 | } |
| 48 | } |