dianlujitao | 47d41f6 | 2019-10-06 12:04:33 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 The LineageOS 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 | #ifndef CRYPTFS_HW_BACKEND |
| 18 | #error "CRYPTFS_HW_BACKEND must be set before including this file." |
| 19 | #endif |
| 20 | |
| 21 | #include <android-base/logging.h> |
| 22 | #include <hidl/HidlTransportSupport.h> |
| 23 | |
| 24 | #ifdef ARCH_ARM_32 |
| 25 | #include <hwbinder/ProcessState.h> |
| 26 | #endif |
| 27 | |
| 28 | #include <CryptfsHw.h> |
| 29 | |
| 30 | using ::android::OK; |
| 31 | using ::android::status_t; |
| 32 | using ::android::hardware::configureRpcThreadpool; |
| 33 | using ::android::hardware::joinRpcThreadpool; |
| 34 | |
| 35 | using ::vendor::qti::hardware::cryptfshw::V1_0::implementation::CryptfsHw; |
| 36 | using ::vendor::qti::hardware::cryptfshw::V1_0::implementation::ICryptfsHwController; |
| 37 | using ::vendor::qti::hardware::cryptfshw::V1_0::implementation::CRYPTFS_HW_BACKEND::Controller; |
| 38 | |
| 39 | int main() { |
| 40 | #ifdef ARCH_ARM_32 |
| 41 | android::hardware::ProcessState::initWithMmapSize((size_t)16384); |
| 42 | #endif |
| 43 | |
| 44 | LOG(DEBUG) << "CryptfsHw HAL service is starting."; |
| 45 | |
| 46 | auto controller = std::make_unique<Controller>(); |
| 47 | android::sp<CryptfsHw> cryptfsHw = new CryptfsHw(std::move(controller)); |
| 48 | |
| 49 | configureRpcThreadpool(1, true /*callerWillJoin*/); |
| 50 | |
| 51 | status_t status = cryptfsHw->registerAsService(); |
| 52 | if (status == OK) { |
| 53 | LOG(DEBUG) << "CryptfsHw HAL service is ready."; |
| 54 | joinRpcThreadpool(); |
| 55 | } else { |
| 56 | LOG(ERROR) << "Could not register service for CryptfsHw HAL CryptfsHw Iface (" << status |
| 57 | << ")"; |
| 58 | } |
| 59 | |
| 60 | // In normal operation, we don't expect the thread pool to shutdown |
| 61 | LOG(ERROR) << "CryptfsHw HAL service is shutting down."; |
| 62 | return 1; |
| 63 | } |