1 /*
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 #include <hidl/AidlCameraServiceListener.h>
18 #include <hidl/Utils.h>
19 #include <camera/CameraUtils.h>
20 #include <camera/StringUtils.h>
21
22 namespace android {
23 namespace frameworks {
24 namespace cameraservice {
25 namespace service {
26 namespace V2_0 {
27 namespace implementation {
28
29 using hardware::cameraservice::utils::conversion::convertToHidlCameraDeviceStatus;
30 typedef frameworks::cameraservice::service::V2_1::ICameraServiceListener HCameraServiceListener2_1;
31
onStatusChanged(int32_t status,const std::string & cameraId,int32_t deviceId)32 binder::Status H2BCameraServiceListener::onStatusChanged(
33 int32_t status, const std::string& cameraId, int32_t deviceId) {
34 if (deviceId != kDefaultDeviceId) {
35 return binder::Status::ok();
36 }
37 HCameraDeviceStatus hCameraDeviceStatus = convertToHidlCameraDeviceStatus(status);
38 CameraStatusAndId cameraStatusAndId;
39 cameraStatusAndId.deviceStatus = hCameraDeviceStatus;
40 cameraStatusAndId.cameraId = cameraId;
41 auto ret = mBase->onStatusChanged(cameraStatusAndId);
42 if (!ret.isOk()) {
43 ALOGE("%s OnStatusChanged callback failed due to %s",__FUNCTION__,
44 ret.description().c_str());
45 }
46 return binder::Status::ok();
47 }
48
onPhysicalCameraStatusChanged(int32_t status,const std::string & cameraId,const std::string & physicalCameraId,int32_t deviceId)49 binder::Status H2BCameraServiceListener::onPhysicalCameraStatusChanged(
50 int32_t status, const std::string& cameraId,
51 const std::string& physicalCameraId, int32_t deviceId) {
52 if (deviceId != kDefaultDeviceId) {
53 return binder::Status::ok();
54 }
55 auto cast2_1 = HCameraServiceListener2_1::castFrom(mBase);
56 sp<HCameraServiceListener2_1> interface2_1 = nullptr;
57 if (cast2_1.isOk()) {
58 interface2_1 = cast2_1;
59 if (interface2_1 != nullptr) {
60 HCameraDeviceStatus hCameraDeviceStatus = convertToHidlCameraDeviceStatus(status);
61 V2_1::PhysicalCameraStatusAndId cameraStatusAndId;
62 cameraStatusAndId.deviceStatus = hCameraDeviceStatus;
63 cameraStatusAndId.cameraId = cameraId;
64 cameraStatusAndId.physicalCameraId = physicalCameraId;
65 auto ret = interface2_1->onPhysicalCameraStatusChanged(cameraStatusAndId);
66 if (!ret.isOk()) {
67 ALOGE("%s OnPhysicalCameraStatusChanged callback failed due to %s",__FUNCTION__,
68 ret.description().c_str());
69 }
70 }
71 }
72 return binder::Status::ok();
73 }
74
onTorchStatusChanged(int32_t,const std::string &,int32_t)75 ::android::binder::Status H2BCameraServiceListener::onTorchStatusChanged(
76 [[maybe_unused]] int32_t, [[maybe_unused]] const std::string&, [[maybe_unused]] int32_t) {
77 // We don't implement onTorchStatusChanged
78 return binder::Status::ok();
79 }
80
onTorchStrengthLevelChanged(const std::string &,int32_t,int32_t)81 ::android::binder::Status H2BCameraServiceListener::onTorchStrengthLevelChanged(
82 [[maybe_unused]] const std::string&, [[maybe_unused]] int32_t, [[maybe_unused]] int32_t) {
83 return binder::Status::ok();
84 }
85
86 } // implementation
87 } // V2_0
88 } // common
89 } // cameraservice
90 } // frameworks
91 } // android
92