1 /* 2 * Copyright (C) 2022 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 #ifndef FRAMEWORKS_AV_SERVICES_CAMERA_LIBCAMERASERVICE_AIDL_AIDLCAMERASERVICELISTENER_H_ 18 #define FRAMEWORKS_AV_SERVICES_CAMERA_LIBCAMERASERVICE_AIDL_AIDLCAMERASERVICELISTENER_H_ 19 20 21 #include <aidl/DeathPipe.h> 22 #include <aidl/android/frameworks/cameraservice/service/CameraDeviceStatus.h> 23 #include <aidl/android/frameworks/cameraservice/service/ICameraServiceListener.h> 24 #include <android/hardware/BnCameraServiceListener.h> 25 26 namespace android::frameworks::cameraservice::service::implementation { 27 28 using ::android::frameworks::cameraservice::utils::DeathPipe; 29 30 // VNDK classes 31 using SCameraDeviceStatus = ::aidl::android::frameworks::cameraservice::service::CameraDeviceStatus; 32 using SICameraServiceListener = 33 ::aidl::android::frameworks::cameraservice::service::ICameraServiceListener; 34 // NDK classes 35 using UBnCameraServiceListener = ::android::hardware::BnCameraServiceListener; 36 37 /** 38 * A simple shim to pass calls from CameraService to VNDK client. 39 */ 40 class AidlCameraServiceListener : public UBnCameraServiceListener { 41 public: AidlCameraServiceListener(const std::shared_ptr<SICameraServiceListener> & base)42 AidlCameraServiceListener(const std::shared_ptr<SICameraServiceListener>& base): 43 mBase(base), mDeathPipe(this, base->asBinder()) {} 44 45 ~AidlCameraServiceListener() = default; 46 47 ::android::binder::Status onStatusChanged(int32_t status, 48 const ::android::String16& cameraId) override; 49 ::android::binder::Status onPhysicalCameraStatusChanged(int32_t status, 50 const ::android::String16& cameraId, 51 const ::android::String16& physicalCameraId) override; 52 53 ::android::binder::Status onTorchStatusChanged( 54 int32_t status, const ::android::String16& cameraId) override; 55 ::android::binder::Status onTorchStrengthLevelChanged( 56 const ::android::String16& cameraId, int32_t newStrengthLevel) override; onCameraAccessPrioritiesChanged()57 binder::Status onCameraAccessPrioritiesChanged() override { 58 // TODO: no implementation yet. 59 return binder::Status::ok(); 60 } onCameraOpened(const::android::String16 &,const::android::String16 &)61 binder::Status onCameraOpened(const ::android::String16& /*cameraId*/, 62 const ::android::String16& /*clientPackageId*/) override { 63 // empty implementation 64 return binder::Status::ok(); 65 } onCameraClosed(const::android::String16 &)66 binder::Status onCameraClosed(const ::android::String16& /*cameraId*/) override { 67 // empty implementation 68 return binder::Status::ok(); 69 } 70 71 status_t linkToDeath(const sp<DeathRecipient>& recipient, void* cookie, 72 uint32_t flags) override; 73 status_t unlinkToDeath(const wp<DeathRecipient>& recipient, void* cookie, uint32_t flags, 74 wp<DeathRecipient>* outRecipient) override; 75 76 private: 77 std::shared_ptr<SICameraServiceListener> mBase; 78 79 // Pipes death subscription to current NDK AIDL interface to VNDK mBase. 80 // Should consume calls to linkToDeath and unlinkToDeath. 81 DeathPipe mDeathPipe; 82 }; 83 84 } // android 85 86 #endif // FRAMEWORKS_AV_SERVICES_CAMERA_LIBCAMERASERVICE_AIDL_AIDLCAMERASERVICELISTENER_H_