Yin-Chia Yeh | 10d6834 | 2017-01-10 14:21:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 "android.hardware.camera.provider@2.4-service" |
| 18 | |
| 19 | #include <android/hardware/camera/provider/2.4/ICameraProvider.h> |
| 20 | #include <CameraProvider.h> |
| 21 | |
| 22 | #include <hidl/HidlTransportSupport.h> |
Steven Moreland | 7fd6ad8 | 2017-01-31 16:05:29 -0800 | [diff] [blame] | 23 | #include <hidl/LegacySupport.h> |
Yin-Chia Yeh | 10d6834 | 2017-01-10 14:21:06 -0800 | [diff] [blame] | 24 | #include <utils/StrongPointer.h> |
| 25 | |
| 26 | using android::hardware::configureRpcThreadpool; |
| 27 | using android::hardware::joinRpcThreadpool; |
| 28 | using android::sp; |
| 29 | using android::hardware::camera::provider::V2_4::ICameraProvider; |
| 30 | using android::hardware::camera::provider::V2_4::implementation::HIDL_FETCH_ICameraProvider; |
| 31 | |
| 32 | int main() |
| 33 | { |
| 34 | const char instance[] = "legacy/0"; |
| 35 | |
Steven Moreland | 7fd6ad8 | 2017-01-31 16:05:29 -0800 | [diff] [blame] | 36 | // TODO(b/34817742): use defaultServicePassthroughImplementation |
| 37 | // so that the toggle is implemented correctly |
| 38 | using ::android::hardware::details::blockIfBinderizationDisabled; |
| 39 | blockIfBinderizationDisabled(ICameraProvider::descriptor, instance); |
| 40 | |
Yin-Chia Yeh | 10d6834 | 2017-01-10 14:21:06 -0800 | [diff] [blame] | 41 | ALOGI("Camera provider Service is starting."); |
| 42 | |
| 43 | configureRpcThreadpool(1, true /* callerWillJoin */); |
| 44 | // TODO (b/34510650): check the passthrough/binderized dev key |
| 45 | sp<ICameraProvider> service = HIDL_FETCH_ICameraProvider(instance); |
| 46 | if (service == nullptr) { |
| 47 | ALOGI("Camera provider getService returned NULL"); |
| 48 | return -1; |
| 49 | } |
| 50 | |
| 51 | LOG_FATAL_IF(service->isRemote(), "Camera provider service is REMOTE!"); |
| 52 | |
| 53 | service->registerAsService(instance); |
| 54 | joinRpcThreadpool(); |
| 55 | |
| 56 | return 0; |
| 57 | } |