blob: 96005596f60b09ed7d2a851a32eb420d22e250d1 [file] [log] [blame]
Yin-Chia Yeh10d68342017-01-10 14:21:06 -08001/*
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 Moreland7fd6ad82017-01-31 16:05:29 -080023#include <hidl/LegacySupport.h>
Yin-Chia Yeh10d68342017-01-10 14:21:06 -080024#include <utils/StrongPointer.h>
25
26using android::hardware::configureRpcThreadpool;
27using android::hardware::joinRpcThreadpool;
28using android::sp;
29using android::hardware::camera::provider::V2_4::ICameraProvider;
30using android::hardware::camera::provider::V2_4::implementation::HIDL_FETCH_ICameraProvider;
31
32int main()
33{
34 const char instance[] = "legacy/0";
35
Steven Moreland7fd6ad82017-01-31 16:05:29 -080036 // 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 Yeh10d68342017-01-10 14:21:06 -080041 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}