xref: /aosp_15_r20/system/chre/host/hal_generic/aidl/service.cc (revision 84e339476a462649f82315436d70fd732297a399)
1*84e33947SAndroid Build Coastguard Worker /*
2*84e33947SAndroid Build Coastguard Worker  * Copyright (C) 2021 The Android Open Source Project
3*84e33947SAndroid Build Coastguard Worker  *
4*84e33947SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*84e33947SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*84e33947SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*84e33947SAndroid Build Coastguard Worker  *
8*84e33947SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*84e33947SAndroid Build Coastguard Worker  *
10*84e33947SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*84e33947SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*84e33947SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*84e33947SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*84e33947SAndroid Build Coastguard Worker  * limitations under the License.
15*84e33947SAndroid Build Coastguard Worker  */
16*84e33947SAndroid Build Coastguard Worker 
17*84e33947SAndroid Build Coastguard Worker #include "generic_context_hub_aidl.h"
18*84e33947SAndroid Build Coastguard Worker 
19*84e33947SAndroid Build Coastguard Worker #include <android-base/logging.h>
20*84e33947SAndroid Build Coastguard Worker #include <android/binder_manager.h>
21*84e33947SAndroid Build Coastguard Worker #include <android/binder_process.h>
22*84e33947SAndroid Build Coastguard Worker 
23*84e33947SAndroid Build Coastguard Worker #ifndef LOG_TAG
24*84e33947SAndroid Build Coastguard Worker #define LOG_TAG "android.hardware.contexthub-service"
25*84e33947SAndroid Build Coastguard Worker #endif
26*84e33947SAndroid Build Coastguard Worker 
27*84e33947SAndroid Build Coastguard Worker using aidl::android::hardware::contexthub::ContextHub;
28*84e33947SAndroid Build Coastguard Worker 
main()29*84e33947SAndroid Build Coastguard Worker int main() {
30*84e33947SAndroid Build Coastguard Worker   ABinderProcess_setThreadPoolMaxThreadCount(0);
31*84e33947SAndroid Build Coastguard Worker 
32*84e33947SAndroid Build Coastguard Worker   // Make a default contexthub service
33*84e33947SAndroid Build Coastguard Worker   auto contextHub = ndk::SharedRefBase::make<ContextHub>();
34*84e33947SAndroid Build Coastguard Worker   const std::string contextHubName =
35*84e33947SAndroid Build Coastguard Worker       std::string() + ContextHub::descriptor + "/default";
36*84e33947SAndroid Build Coastguard Worker   binder_status_t status = AServiceManager_addService(
37*84e33947SAndroid Build Coastguard Worker       contextHub->asBinder().get(), contextHubName.c_str());
38*84e33947SAndroid Build Coastguard Worker   CHECK(status == STATUS_OK);
39*84e33947SAndroid Build Coastguard Worker 
40*84e33947SAndroid Build Coastguard Worker   ABinderProcess_joinThreadPool();
41*84e33947SAndroid Build Coastguard Worker   return EXIT_FAILURE;  // should not reach
42*84e33947SAndroid Build Coastguard Worker }
43