1 /* 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 18 use android_hardware_light::aidl::android::hardware::light::ILights::{BnLights, ILights}; 19 use binder::BinderFeatures; 20 21 mod lights; 22 use lights::LightsService; 23 24 const LOG_TAG: &str = "lights_service_example_rust"; 25 26 use log::LevelFilter; 27 main()28fn main() { 29 let logger_success = logger::init( 30 logger::Config::default().with_tag_on_device(LOG_TAG).with_max_level(LevelFilter::Trace), 31 ); 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 38 let lights_service = LightsService::default(); 39 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 } 47