blob: b09b5ec4231c2c11a4be36181eee8d848f77390c [file] [log] [blame]
Polina Bondarenko254e2fe2016-10-11 16:39:23 +02001/*
2 * Copyright (C) 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 */
16
17#include <iostream>
18#include <unistd.h>
19
20#include <android/hardware/thermal/1.0/IThermal.h>
21
22#include <hidl/IServiceManager.h>
23#include <hwbinder/IPCThreadState.h>
24#include <hwbinder/ProcessState.h>
25#include <utils/Errors.h>
26
27#define LOG_TAG "android.hardware.thermal@1.0-service"
28#include <utils/Log.h>
29#include <utils/StrongPointer.h>
30
31using android::sp;
32
33// libhwbinder:
34using android::hardware::IPCThreadState;
35using android::hardware::ProcessState;
36
37// Generated HIDL files
38using android::hardware::thermal::V1_0::IThermal;
39
40int main() {
41 const char instance[] = "thermal";
42 sp<IThermal> service = IThermal::getService(instance, true /* getStub */);
43 if (service.get() == nullptr) {
44 ALOGE("IThermal::getService returned NULL, exiting");
45 return EXIT_FAILURE;
46 }
47 LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
48 service->registerAsService(instance);
49
50 ProcessState::self()->setThreadPoolMaxThreadCount(0);
51 ProcessState::self()->startThreadPool();
52 IPCThreadState::self()->joinThreadPool();
53}