diff options
author | Steven Moreland | 2016-10-20 19:42:01 -0500 |
---|---|---|
committer | Steven Moreland | 2016-10-21 14:33:06 -0500 |
commit | 22566b891381af660c670a5385385a38fa1882af (patch) | |
tree | dfbbbcce0f96ca3521d9f00be296f9d2bcaf3b68 /light/2.0/default | |
parent | 00dfbca81f5700880e261debce317b932f7460fa (diff) | |
download | platform-hardware-interfaces-22566b891381af660c670a5385385a38fa1882af.tar.gz platform-hardware-interfaces-22566b891381af660c670a5385385a38fa1882af.tar.xz platform-hardware-interfaces-22566b891381af660c670a5385385a38fa1882af.zip |
Use defaultPassthroughServiceImplementation.
Bug: 32279541
Bug: 32282345
Test: mma
Change-Id: Ic0222963c99bea41de7637e5f20c19d7c541cb97
Diffstat (limited to 'light/2.0/default')
-rw-r--r-- | light/2.0/default/service.cpp | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/light/2.0/default/service.cpp b/light/2.0/default/service.cpp index e4468784..b3848e95 100644 --- a/light/2.0/default/service.cpp +++ b/light/2.0/default/service.cpp | |||
@@ -1,46 +1,27 @@ | |||
1 | #define LOG_TAG "android.hardware.light@2.0-service" | 1 | /* |
2 | #include <utils/Log.h> | 2 | * Copyright 2016 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 | */ | ||
3 | 16 | ||
4 | #include <iostream> | 17 | #define LOG_TAG "android.hardware.light@2.0-service" |
5 | #include <unistd.h> | ||
6 | 18 | ||
7 | #include <android/hardware/light/2.0/ILight.h> | 19 | #include <android/hardware/light/2.0/ILight.h> |
20 | #include <hidl/LegacySupport.h> | ||
8 | 21 | ||
9 | #include <hidl/IServiceManager.h> | ||
10 | #include <hwbinder/IPCThreadState.h> | ||
11 | #include <hwbinder/ProcessState.h> | ||
12 | #include <utils/Errors.h> | ||
13 | #include <utils/StrongPointer.h> | ||
14 | |||
15 | using android::sp; | ||
16 | |||
17 | // libhwbinder: | ||
18 | using android::hardware::IPCThreadState; | ||
19 | using android::hardware::ProcessState; | ||
20 | |||
21 | // Generated HIDL files | ||
22 | using android::hardware::light::V2_0::ILight; | 22 | using android::hardware::light::V2_0::ILight; |
23 | using android::hardware::defaultPassthroughServiceImplementation; | ||
23 | 24 | ||
24 | int main() { | 25 | int main() { |
25 | ALOGI("Service is starting."); | 26 | return defaultPassthroughServiceImplementation<ILight>("light"); |
26 | const char instance[] = "light"; | ||
27 | ALOGI("Retrieving default implementation of instance %s.", | ||
28 | instance); | ||
29 | |||
30 | android::sp<ILight> service = ILight::getService(instance, true /* getStub */); | ||
31 | |||
32 | if (service.get() == nullptr) { | ||
33 | ALOGE("ILight::getService returned NULL, exiting"); | ||
34 | return EXIT_FAILURE; | ||
35 | } | ||
36 | |||
37 | LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!"); | ||
38 | |||
39 | ALOGI("Registering instance %s.", instance); | ||
40 | service->registerAsService(instance); | ||
41 | ALOGI("Ready."); | ||
42 | |||
43 | ProcessState::self()->setThreadPoolMaxThreadCount(0); | ||
44 | ProcessState::self()->startThreadPool(); | ||
45 | IPCThreadState::self()->joinThreadPool(); | ||
46 | } | 27 | } |