blob: fcd1c9656566e1f6b8c8320f92a0171abf1a29a8 [file] [log] [blame]
Shuzhen Wangd3feb3d2018-08-17 13:52:40 -07001/*
2 * Copyright (C) 2018 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 "CamDev@3.5-impl"
18#include <log/log.h>
19
20#include "CameraModule.h"
21#include "CameraDevice_3_5.h"
22
23namespace android {
24namespace hardware {
25namespace camera {
26namespace device {
27namespace V3_5 {
28namespace implementation {
29
30using namespace ::android::hardware::camera::device;
31using ::android::hardware::camera::common::V1_0::Status;
32using ::android::hardware::camera::device::V3_2::CameraMetadata;
33
34CameraDevice::CameraDevice(sp<CameraModule> module, const std::string& cameraId,
35 const SortedVector<std::pair<std::string, std::string>>& cameraDeviceNames) :
36 V3_4::implementation::CameraDevice(module, cameraId, cameraDeviceNames) {
37}
38
39CameraDevice::~CameraDevice() {
40}
41
42Return<void> CameraDevice::getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
43 V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) {
44 Status status = initStatus();
45 CameraMetadata cameraCharacteristics;
46 if (status == Status::OK) {
47 // Require module 2.5+ version.
48 if (mModule->getModuleApiVersion() < CAMERA_MODULE_API_VERSION_2_5) {
49 ALOGE("%s: get_physical_camera_info must be called on camera module 2.5 or newer",
50 __FUNCTION__);
51 status = Status::INTERNAL_ERROR;
52 } else {
53 char *end;
54 errno = 0;
55 long id = strtol(physicalCameraId.c_str(), &end, 0);
56 if (id > INT_MAX || (errno == ERANGE && id == LONG_MAX) ||
57 id < INT_MIN || (errno == ERANGE && id == LONG_MIN) ||
58 *end != '\0') {
59 ALOGE("%s: Invalid physicalCameraId %s", __FUNCTION__, physicalCameraId.c_str());
60 status = Status::ILLEGAL_ARGUMENT;
61 } else {
62 camera_metadata_t *physicalInfo = nullptr;
63 int ret = mModule->getPhysicalCameraInfo((int)id, &physicalInfo);
64 if (ret == OK) {
65 V3_2::implementation::convertToHidl(physicalInfo, &cameraCharacteristics);
66 } else {
67 ALOGE("%s: Failed to get physical camera %s info: %s (%d)!", __FUNCTION__,
68 physicalCameraId.c_str(), strerror(-ret), ret);
69 status = Status::INTERNAL_ERROR;
70 }
71 }
72 }
73 }
74 _hidl_cb(status, cameraCharacteristics);
75 return Void();
76}
77
78// End of methods from ::android::hardware::camera::device::V3_2::ICameraDevice.
79
80} // namespace implementation
81} // namespace V3_5
82} // namespace device
83} // namespace camera
84} // namespace hardware
85} // namespace android
86