• 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 //! Service that registers the IHello interface for a codelab
17 
18 use hello_service::Hello;
19 use hello_world::aidl::hello::world::IHello::{BnHello, IHello};
20 
main()21 fn main() {
22     // We join the threadpool with this main thread and never exit. We don't
23     // have any callback binders in this interface, so the single thread is OK.
24     // Set the max to 0 here so libbinder doesn't spawn any additional threads.
25     binder::ProcessState::set_thread_pool_max_thread_count(0);
26 
27     let service = BnHello::new_binder(Hello, binder::BinderFeatures::default());
28     let service_name = format!("{}/default", Hello::get_descriptor());
29     binder::add_service(&service_name, service.as_binder())
30         .expect("Failed to register IHello service!");
31 
32     binder::ProcessState::join_thread_pool()
33 }
34