blob: b5452d68d7729de3f81c3a6393e267108dfe9f5d [file] [log] [blame]
Jesus Sanchez-Palencia531b5ba2023-06-16 00:13:04 +00001/*
2 * Copyright (C) 2023 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//! This implements the Lights Example Service.
17
18use android_hardware_light::aidl::android::hardware::light::ILights::{BnLights, ILights};
19use binder::BinderFeatures;
20
21mod lights;
22use lights::LightsService;
23
24const LOG_TAG: &str = "lights_service_example_rust";
25
Jeff Vander Stoep116a4d82024-02-07 12:55:53 +010026use log::LevelFilter;
Jesus Sanchez-Palencia531b5ba2023-06-16 00:13:04 +000027
28fn main() {
29 let logger_success = logger::init(
Jeff Vander Stoep116a4d82024-02-07 12:55:53 +010030 logger::Config::default().with_tag_on_device(LOG_TAG).with_max_level(LevelFilter::Trace),
Jesus Sanchez-Palencia531b5ba2023-06-16 00:13:04 +000031 );
32 if !logger_success {
33 panic!("{LOG_TAG}: Failed to start logger.");
34 }
35
36 binder::ProcessState::set_thread_pool_max_thread_count(0);
37
Jesus Sanchez-Palenciac0544582023-06-26 17:28:06 -070038 let lights_service = LightsService::default();
Jesus Sanchez-Palencia531b5ba2023-06-16 00:13:04 +000039 let lights_service_binder = BnLights::new_binder(lights_service, BinderFeatures::default());
40
41 let service_name = format!("{}/default", LightsService::get_descriptor());
42 binder::add_service(&service_name, lights_service_binder.as_binder())
43 .expect("Failed to register service");
44
45 binder::ProcessState::join_thread_pool()
46}