blob: da543ef4eddb4018f5c02bebe7abdf09c53003cb [file] [log] [blame]
Andreas Huberdb49a412016-10-10 13:23:59 -07001/*
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 <android-base/logging.h>
18#include <android/hardware/sensors/1.0/ISensors.h>
19#include <hwbinder/IPCThreadState.h>
20#include <hwbinder/ProcessState.h>
21
22int main() {
23 using android::hardware::sensors::V1_0::ISensors;
24 using android::sp;
25 using android::OK;
26 using namespace android::hardware;
27
28 LOG(INFO) << "Service is starting.";
29 sp<ISensors> sensors = ISensors::getService("sensors", true /* getStub */);
30
31 if (sensors.get() == nullptr) {
32 LOG(ERROR) << "ISensors::getService returned nullptr, exiting.";
33 return 1;
34 }
35
36 LOG(INFO) << "Default implementation using sensors is "
37 << (sensors->isRemote() ? "REMOTE" : "LOCAL");
38
39 CHECK(!sensors->isRemote());
40
41 LOG(INFO) << "Registering instance sensors.";
42 sensors->registerAsService("sensors");
43 LOG(INFO) << "Ready.";
44
45 ProcessState::self()->setThreadPoolMaxThreadCount(0);
46 ProcessState::self()->startThreadPool();
47 IPCThreadState::self()->joinThreadPool();
48
49 return 0;
50}
51