Chia-I Wu | b0b5a4d | 2016-10-17 14:56:15 +0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | |
| 17 | #define LOG_TAG "HWComposerService" |
| 18 | |
| 19 | #include <binder/ProcessState.h> |
| 20 | #include <hwbinder/IPCThreadState.h> |
| 21 | #include <hwbinder/ProcessState.h> |
| 22 | #include <utils/StrongPointer.h> |
| 23 | #include "Hwc.h" |
| 24 | |
| 25 | using android::sp; |
| 26 | using android::hardware::IPCThreadState; |
| 27 | using android::hardware::ProcessState; |
| 28 | using android::hardware::graphics::composer::V2_1::IComposer; |
| 29 | using android::hardware::graphics::composer::V2_1::implementation::HIDL_FETCH_IComposer; |
| 30 | |
| 31 | int main() |
| 32 | { |
| 33 | const char instance[] = "hwcomposer"; |
| 34 | |
| 35 | ALOGI("Service is starting."); |
| 36 | |
| 37 | sp<IComposer> service = HIDL_FETCH_IComposer(instance); |
| 38 | if (service == nullptr) { |
| 39 | ALOGI("getService returned NULL"); |
| 40 | return -1; |
| 41 | } |
| 42 | |
| 43 | LOG_FATAL_IF(service->isRemote(), "Service is REMOTE!"); |
| 44 | |
| 45 | service->registerAsService(instance); |
| 46 | |
| 47 | // the conventional HAL might start binder services |
| 48 | android::ProcessState::self()->setThreadPoolMaxThreadCount(4); |
| 49 | android::ProcessState::self()->startThreadPool(); |
| 50 | |
| 51 | ProcessState::self()->setThreadPoolMaxThreadCount(0); |
| 52 | ProcessState::self()->startThreadPool(); |
| 53 | IPCThreadState::self()->joinThreadPool(); |
| 54 | |
| 55 | return 0; |
| 56 | } |