1 /*
2  * Copyright (C) 2017 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 #include "Lefty.h"
17 #include "lefty_service.h"
18 
19 #include <android-base/logging.h>
20 #include <hidl/LegacySupport.h>
21 #include <utils/StrongPointer.h>
22 #include <vendor/google_clockwork/lefty/1.0/ILefty.h>
23 
24 using ::android::sp;
25 using ::vendor::google_clockwork::lefty::V1_0::ILefty;
26 using ::vendor::google_clockwork::lefty::V1_0::implementation::Lefty;
27 
register_lefty_service()28 void register_lefty_service() {
29     // Kids, don't do this at home. Here, registerAsService is called without
30     // configureRpcThreadpool/joinRpcThreadpool, because it is called from
31     // open_sensors() function, called from HIDL_FETCH_ISensors, called from
32     // ISensor::getService, called from registerPassthroughServiceImplementation
33     // which is surrounded with configureRpcThreadpool/joinRpcThreadpool.
34     sp<ILefty> lefty = new Lefty();
35     CHECK_EQ(lefty->registerAsService(), android::NO_ERROR)
36             << "Failed to register Lefty HAL";
37 }
38