Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 ANDROID_SERVERS_CAMERA_CAMERAPROVIDER_H |
| 18 | #define ANDROID_SERVERS_CAMERA_CAMERAPROVIDER_H |
| 19 | |
| 20 | #include <vector> |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 21 | #include <unordered_map> |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 22 | #include <unordered_set> |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 23 | #include <set> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 24 | #include <string> |
| 25 | #include <mutex> |
Shuzhen Wang | 394ad70 | 2020-07-23 13:01:54 -0700 | [diff] [blame] | 26 | #include <future> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 27 | |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 28 | #include <camera/camera2/ConcurrentCamera.h> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 29 | #include <camera/CameraParameters2.h> |
| 30 | #include <camera/CameraMetadata.h> |
| 31 | #include <camera/CameraBase.h> |
Valentin Iftime | 29e2e15 | 2021-08-13 15:17:33 +0200 | [diff] [blame] | 32 | #include <utils/Condition.h> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 33 | #include <utils/Errors.h> |
Valentin Iftime | 29e2e15 | 2021-08-13 15:17:33 +0200 | [diff] [blame] | 34 | #include <android/hardware/ICameraService.h> |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 35 | #include <utils/IPCTransport.h> |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 36 | #include <aidl/android/hardware/camera/provider/ICameraProvider.h> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 37 | #include <android/hardware/camera/common/1.0/types.h> |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 38 | #include <android/hardware/camera/provider/2.5/ICameraProvider.h> |
Shuzhen Wang | 4385816 | 2020-01-10 13:42:15 -0800 | [diff] [blame] | 39 | #include <android/hardware/camera/provider/2.6/ICameraProviderCallback.h> |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 40 | #include <android/hardware/camera/provider/2.6/ICameraProvider.h> |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 41 | #include <android/hardware/camera/provider/2.7/ICameraProvider.h> |
| 42 | #include <android/hardware/camera/device/3.7/types.h> |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 43 | #include <android/hardware/camera/device/3.8/types.h> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 44 | #include <android/hidl/manager/1.0/IServiceNotification.h> |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 45 | #include <binder/IServiceManager.h> |
Yin-Chia Yeh | 067428c | 2017-01-13 15:19:24 -0800 | [diff] [blame] | 46 | #include <camera/VendorTagDescriptor.h> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 47 | |
| 48 | namespace android { |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 49 | |
| 50 | using hardware::camera2::utils::CameraIdAndSessionConfiguration; |
| 51 | |
| 52 | enum class CameraDeviceStatus : uint32_t { |
| 53 | NOT_PRESENT = 0, |
| 54 | PRESENT = 1, |
| 55 | ENUMERATING = 2 |
| 56 | }; |
| 57 | |
| 58 | enum class TorchModeStatus : uint32_t { |
| 59 | NOT_AVAILABLE = 0, |
| 60 | AVAILABLE_OFF = 1, |
| 61 | AVAILABLE_ON = 2 |
| 62 | }; |
| 63 | |
| 64 | struct CameraResourceCost { |
| 65 | uint32_t resourceCost; |
| 66 | std::vector<std::string> conflictingDevices; |
Yin-Chia Yeh | 067428c | 2017-01-13 15:19:24 -0800 | [diff] [blame] | 67 | }; |
| 68 | |
Jayant Chowdhary | 5216b21 | 2019-07-17 09:26:23 -0700 | [diff] [blame] | 69 | enum SystemCameraKind { |
| 70 | /** |
| 71 | * These camera devices are visible to all apps and system components alike |
| 72 | */ |
| 73 | PUBLIC = 0, |
| 74 | |
| 75 | /** |
| 76 | * These camera devices are visible only to processes having the |
| 77 | * android.permission.SYSTEM_CAMERA permission. They are not exposed to 3P |
| 78 | * apps. |
| 79 | */ |
| 80 | SYSTEM_ONLY_CAMERA, |
| 81 | |
| 82 | /** |
| 83 | * These camera devices are visible only to HAL clients (that try to connect |
| 84 | * on a hwbinder thread). |
| 85 | */ |
| 86 | HIDDEN_SECURE_CAMERA |
| 87 | }; |
| 88 | |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 89 | #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) |
| 90 | #define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) |
| 91 | #define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) |
| 92 | #define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2) |
| 93 | #define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3) |
| 94 | #define CAMERA_DEVICE_API_VERSION_3_4 HARDWARE_DEVICE_API_VERSION(3, 4) |
| 95 | #define CAMERA_DEVICE_API_VERSION_3_5 HARDWARE_DEVICE_API_VERSION(3, 5) |
| 96 | #define CAMERA_DEVICE_API_VERSION_3_6 HARDWARE_DEVICE_API_VERSION(3, 6) |
| 97 | #define CAMERA_DEVICE_API_VERSION_3_7 HARDWARE_DEVICE_API_VERSION(3, 7) |
Shuzhen Wang | 90708ea | 2021-11-04 11:40:49 -0700 | [diff] [blame] | 98 | #define CAMERA_DEVICE_API_VERSION_3_8 HARDWARE_DEVICE_API_VERSION(3, 8) |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 99 | |
Yin-Chia Yeh | 067428c | 2017-01-13 15:19:24 -0800 | [diff] [blame] | 100 | /** |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 101 | * The vendor tag descriptor class that takes HIDL/AIDL vendor tag information as |
| 102 | * input. Not part of VendorTagDescriptor class because that class is used |
| 103 | * in AIDL generated sources which don't have access to AIDL / HIDL headers. |
| 104 | */ |
| 105 | class IdlVendorTagDescriptor : public VendorTagDescriptor { |
| 106 | public: |
| 107 | /** |
| 108 | * Create a VendorTagDescriptor object from the HIDL/AIDL VendorTagSection |
| 109 | * vector. |
| 110 | * |
| 111 | * Returns OK on success, or a negative error code. |
| 112 | */ |
| 113 | template <class VendorTagSectionVectorType, class VendorTagSectionType> |
| 114 | static status_t createDescriptorFromIdl( |
| 115 | const VendorTagSectionVectorType& vts, |
| 116 | /*out*/ |
| 117 | sp<VendorTagDescriptor>& descriptor); |
| 118 | }; |
| 119 | |
| 120 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 121 | * A manager for all camera providers available on an Android device. |
| 122 | * |
| 123 | * Responsible for enumerating providers and the individual camera devices |
| 124 | * they export, both at startup and as providers and devices are added/removed. |
| 125 | * |
| 126 | * Provides methods for requesting information about individual devices and for |
| 127 | * opening them for active use. |
| 128 | * |
| 129 | */ |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 130 | class CameraProviderManager : virtual public hidl::manager::V1_0::IServiceNotification, |
| 131 | public virtual IServiceManager::LocalRegistrationCallback { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 132 | public: |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 133 | // needs to be made friend strict since HidlProviderInfo needs to inherit |
| 134 | // from CameraProviderManager::ProviderInfo which isn't a public member. |
| 135 | friend struct HidlProviderInfo; |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 136 | friend struct AidlProviderInfo; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 137 | ~CameraProviderManager(); |
| 138 | |
| 139 | // Tiny proxy for the static methods in a HIDL interface that communicate with the hardware |
| 140 | // service manager, to be replacable in unit tests with a fake. |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 141 | struct HidlServiceInteractionProxy { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 142 | virtual bool registerForNotifications( |
| 143 | const std::string &serviceName, |
| 144 | const sp<hidl::manager::V1_0::IServiceNotification> |
| 145 | ¬ification) = 0; |
Eino-Ville Talvala | ec96060 | 2019-10-15 11:46:16 -0700 | [diff] [blame] | 146 | // Will not wait for service to start if it's not already running |
| 147 | virtual sp<hardware::camera::provider::V2_4::ICameraProvider> tryGetService( |
| 148 | const std::string &serviceName) = 0; |
| 149 | // Will block for service if it exists but isn't running |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 150 | virtual sp<hardware::camera::provider::V2_4::ICameraProvider> getService( |
| 151 | const std::string &serviceName) = 0; |
Yin-Chia Yeh | 177b0c1 | 2019-06-25 10:53:03 -0700 | [diff] [blame] | 152 | virtual hardware::hidl_vec<hardware::hidl_string> listServices() = 0; |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 153 | virtual ~HidlServiceInteractionProxy() {} |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | // Standard use case - call into the normal generated static methods which invoke |
| 157 | // the real hardware service manager |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 158 | struct HidlServiceInteractionProxyImpl : public HidlServiceInteractionProxy { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 159 | virtual bool registerForNotifications( |
| 160 | const std::string &serviceName, |
| 161 | const sp<hidl::manager::V1_0::IServiceNotification> |
| 162 | ¬ification) override { |
| 163 | return hardware::camera::provider::V2_4::ICameraProvider::registerForNotifications( |
| 164 | serviceName, notification); |
| 165 | } |
Eino-Ville Talvala | ec96060 | 2019-10-15 11:46:16 -0700 | [diff] [blame] | 166 | virtual sp<hardware::camera::provider::V2_4::ICameraProvider> tryGetService( |
| 167 | const std::string &serviceName) override { |
| 168 | return hardware::camera::provider::V2_4::ICameraProvider::tryGetService(serviceName); |
| 169 | } |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 170 | virtual sp<hardware::camera::provider::V2_4::ICameraProvider> getService( |
| 171 | const std::string &serviceName) override { |
| 172 | return hardware::camera::provider::V2_4::ICameraProvider::getService(serviceName); |
| 173 | } |
Yin-Chia Yeh | 177b0c1 | 2019-06-25 10:53:03 -0700 | [diff] [blame] | 174 | |
| 175 | virtual hardware::hidl_vec<hardware::hidl_string> listServices() override; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | /** |
| 179 | * Listener interface for device/torch status changes |
| 180 | */ |
| 181 | struct StatusListener : virtual public RefBase { |
| 182 | ~StatusListener() {} |
| 183 | |
| 184 | virtual void onDeviceStatusChanged(const String8 &cameraId, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 185 | CameraDeviceStatus newStatus) = 0; |
Shuzhen Wang | 4385816 | 2020-01-10 13:42:15 -0800 | [diff] [blame] | 186 | virtual void onDeviceStatusChanged(const String8 &cameraId, |
| 187 | const String8 &physicalCameraId, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 188 | CameraDeviceStatus newStatus) = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 189 | virtual void onTorchStatusChanged(const String8 &cameraId, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 190 | TorchModeStatus newStatus, |
Jayant Chowdhary | 46ef0f5 | 2021-10-05 14:36:13 -0700 | [diff] [blame] | 191 | SystemCameraKind kind) = 0; |
| 192 | virtual void onTorchStatusChanged(const String8 &cameraId, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 193 | TorchModeStatus newStatus) = 0; |
Emilian Peev | aee727d | 2017-05-04 16:35:48 +0100 | [diff] [blame] | 194 | virtual void onNewProviderRegistered() = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 195 | }; |
| 196 | |
| 197 | /** |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 198 | * Represents the mode a camera device is currently in |
| 199 | */ |
| 200 | enum class DeviceMode { |
| 201 | TORCH, |
| 202 | CAMERA |
| 203 | }; |
| 204 | |
| 205 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 206 | * Initialize the manager and give it a status listener; optionally accepts a service |
| 207 | * interaction proxy. |
| 208 | * |
| 209 | * The default proxy communicates via the hardware service manager; alternate proxies can be |
| 210 | * used for testing. The lifetime of the proxy must exceed the lifetime of the manager. |
| 211 | */ |
| 212 | status_t initialize(wp<StatusListener> listener, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 213 | HidlServiceInteractionProxy *hidlProxy = &sHidlServiceInteractionProxy); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 214 | |
Jayant Chowdhary | 22441f3 | 2021-12-26 18:35:41 -0800 | [diff] [blame] | 215 | status_t getCameraIdIPCTransport(const std::string &id, |
| 216 | IPCTransport *providerTransport) const; |
| 217 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 218 | /** |
Jayant Chowdhary | 847947d | 2019-08-30 18:02:59 -0700 | [diff] [blame] | 219 | * Retrieve the total number of available cameras. |
| 220 | * This value may change dynamically as cameras are added or removed. |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 221 | */ |
Jayant Chowdhary | 847947d | 2019-08-30 18:02:59 -0700 | [diff] [blame] | 222 | std::pair<int, int> getCameraCount() const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 223 | |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 224 | std::vector<std::string> getCameraDeviceIds() const; |
| 225 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 226 | /** |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 227 | * Retrieve the number of API1 compatible cameras; these are internal and |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 228 | * backwards-compatible. This is the set of cameras that will be |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 229 | * accessible via the old camera API. |
| 230 | * The return value may change dynamically due to external camera hotplug. |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 231 | */ |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 232 | std::vector<std::string> getAPI1CompatibleCameraDeviceIds() const; |
Yin-Chia Yeh | dc3134e | 2017-03-23 15:26:59 -0700 | [diff] [blame] | 233 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 234 | /** |
| 235 | * Return true if a device with a given ID and major version exists |
| 236 | */ |
| 237 | bool isValidDevice(const std::string &id, uint16_t majorVersion) const; |
| 238 | |
| 239 | /** |
| 240 | * Return true if a device with a given ID has a flash unit. Returns false |
| 241 | * for devices that are unknown. |
| 242 | */ |
| 243 | bool hasFlashUnit(const std::string &id) const; |
| 244 | |
| 245 | /** |
Shuzhen Wang | dbdf72b | 2019-11-13 11:22:12 -0800 | [diff] [blame] | 246 | * Return true if the camera device has native zoom ratio support. |
| 247 | */ |
| 248 | bool supportNativeZoomRatio(const std::string &id) const; |
| 249 | |
| 250 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 251 | * Return the resource cost of this camera device |
| 252 | */ |
| 253 | status_t getResourceCost(const std::string &id, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 254 | CameraResourceCost* cost) const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 255 | |
| 256 | /** |
| 257 | * Return the old camera API camera info |
| 258 | */ |
| 259 | status_t getCameraInfo(const std::string &id, |
| 260 | hardware::CameraInfo* info) const; |
| 261 | |
| 262 | /** |
| 263 | * Return API2 camera characteristics - returns NAME_NOT_FOUND if a device ID does |
| 264 | * not have a v3 or newer HAL version. |
| 265 | */ |
| 266 | status_t getCameraCharacteristics(const std::string &id, |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 267 | bool overrideForPerfClass, CameraMetadata* characteristics) const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 268 | |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 269 | status_t isConcurrentSessionConfigurationSupported( |
| 270 | const std::vector<hardware::camera2::utils::CameraIdAndSessionConfiguration> |
| 271 | &cameraIdsAndSessionConfigs, |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 272 | const std::set<std::string>& perfClassPrimaryCameraIds, |
| 273 | int targetSdkVersion, bool *isSupported); |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 274 | |
Jayant Chowdhary | cad23c2 | 2020-03-10 15:04:59 -0700 | [diff] [blame] | 275 | std::vector<std::unordered_set<std::string>> getConcurrentCameraIds() const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 276 | /** |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 277 | * Check for device support of specific stream combination. |
| 278 | */ |
| 279 | status_t isSessionConfigurationSupported(const std::string& id, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 280 | const SessionConfiguration &configuration, |
| 281 | bool overrideForPerfClass, |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 282 | bool *status /*out*/) const; |
| 283 | |
| 284 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 285 | * Return the highest supported device interface version for this ID |
| 286 | */ |
| 287 | status_t getHighestSupportedVersion(const std::string &id, |
| 288 | hardware::hidl_version *v); |
| 289 | |
| 290 | /** |
Yin-Chia Yeh | dc3134e | 2017-03-23 15:26:59 -0700 | [diff] [blame] | 291 | * Check if a given camera device support setTorchMode API. |
| 292 | */ |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 293 | bool supportSetTorchMode(const std::string &id) const; |
Yin-Chia Yeh | dc3134e | 2017-03-23 15:26:59 -0700 | [diff] [blame] | 294 | |
| 295 | /** |
Rucha Katakwar | 3828452 | 2021-11-10 11:25:21 -0800 | [diff] [blame] | 296 | * Check if torch strength update should be skipped or not. |
| 297 | */ |
| 298 | bool shouldSkipTorchStrengthUpdate(const std::string &id, int32_t torchStrength) const; |
| 299 | |
| 300 | /** |
| 301 | * Return the default torch strength level if the torch strength control |
| 302 | * feature is supported. |
| 303 | */ |
| 304 | int32_t getTorchDefaultStrengthLevel(const std::string &id) const; |
| 305 | |
| 306 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 307 | * Turn on or off the flashlight on a given camera device. |
Yin-Chia Yeh | dc3134e | 2017-03-23 15:26:59 -0700 | [diff] [blame] | 308 | * May fail if the device does not support this API, is in active use, or if the device |
| 309 | * doesn't exist, etc. |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 310 | */ |
| 311 | status_t setTorchMode(const std::string &id, bool enabled); |
| 312 | |
| 313 | /** |
Rucha Katakwar | 3828452 | 2021-11-10 11:25:21 -0800 | [diff] [blame] | 314 | * Change the brightness level of the flash unit associated with the cameraId and |
| 315 | * set it to the value in torchStrength. |
| 316 | * If the torch is OFF and torchStrength > 0, the torch will be turned ON with the |
| 317 | * specified strength level. If the torch is ON, only the brightness level will be |
| 318 | * changed. |
| 319 | * |
| 320 | * This operation will fail if the device does not have flash unit, has flash unit |
| 321 | * but does not support this API, torchStrength is invalid or if the device doesn't |
| 322 | * exist etc. |
| 323 | */ |
| 324 | status_t turnOnTorchWithStrengthLevel(const std::string &id, int32_t torchStrength); |
| 325 | |
| 326 | /** |
| 327 | * Return the torch strength level of this camera device. |
| 328 | */ |
| 329 | status_t getTorchStrengthLevel(const std::string &id, int32_t* torchStrength); |
| 330 | |
| 331 | /** |
Yin-Chia Yeh | 067428c | 2017-01-13 15:19:24 -0800 | [diff] [blame] | 332 | * Setup vendor tags for all registered providers |
| 333 | */ |
| 334 | status_t setUpVendorTags(); |
| 335 | |
| 336 | /** |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 337 | * Inform registered providers about a device state change, such as folding or unfolding |
| 338 | */ |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 339 | status_t notifyDeviceStateChange(int64_t newState); |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 340 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 341 | status_t openAidlSession(const std::string &id, |
| 342 | const std::shared_ptr< |
| 343 | aidl::android::hardware::camera::device::ICameraDeviceCallback>& callback, |
| 344 | /*out*/ |
| 345 | std::shared_ptr<aidl::android::hardware::camera::device::ICameraDeviceSession> *session); |
| 346 | |
| 347 | |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 348 | /** |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 349 | * Open an active session to a camera device. |
| 350 | * |
| 351 | * This fully powers on the camera device hardware, and returns a handle to a |
| 352 | * session to be used for hardware configuration and operation. |
| 353 | */ |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 354 | status_t openHidlSession(const std::string &id, |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 355 | const sp<hardware::camera::device::V3_2::ICameraDeviceCallback>& callback, |
| 356 | /*out*/ |
| 357 | sp<hardware::camera::device::V3_2::ICameraDeviceSession> *session); |
| 358 | |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 359 | /** |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 360 | * Notify that the camera or torch is no longer being used by a camera client |
| 361 | */ |
| 362 | void removeRef(DeviceMode usageType, const std::string &cameraId); |
| 363 | |
| 364 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 365 | * IServiceNotification::onRegistration |
| 366 | * Invoked by the hardware service manager when a new camera provider is registered |
| 367 | */ |
| 368 | virtual hardware::Return<void> onRegistration(const hardware::hidl_string& fqName, |
| 369 | const hardware::hidl_string& name, |
| 370 | bool preexisting) override; |
| 371 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 372 | // LocalRegistrationCallback::onServiceRegistration |
| 373 | virtual void onServiceRegistration(const String16& name, const sp<IBinder> &binder) override; |
| 374 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 375 | /** |
| 376 | * Dump out information about available providers and devices |
| 377 | */ |
| 378 | status_t dump(int fd, const Vector<String16>& args); |
| 379 | |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 380 | /** |
| 381 | * Conversion methods between HAL Status and status_t and strings |
| 382 | */ |
| 383 | static status_t mapToStatusT(const hardware::camera::common::V1_0::Status& s); |
| 384 | static const char* statusToString(const hardware::camera::common::V1_0::Status& s); |
| 385 | |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 386 | /* |
| 387 | * Return provider type for a specific device. |
| 388 | */ |
| 389 | metadata_vendor_id_t getProviderTagIdLocked(const std::string& id, |
| 390 | hardware::hidl_version minVersion = hardware::hidl_version{0,0}, |
| 391 | hardware::hidl_version maxVersion = hardware::hidl_version{1000,0}) const; |
| 392 | |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 393 | /* |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 394 | * Check if a camera is a logical camera. And if yes, return |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 395 | * the physical camera ids. |
| 396 | */ |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 397 | bool isLogicalCamera(const std::string& id, std::vector<std::string>* physicalCameraIds); |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 398 | |
Jayant Chowdhary | 33e8ef8 | 2019-09-27 09:20:42 -0700 | [diff] [blame] | 399 | status_t getSystemCameraKind(const std::string& id, SystemCameraKind *kind) const; |
| 400 | bool isHiddenPhysicalCamera(const std::string& cameraId) const; |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 401 | |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 402 | status_t filterSmallJpegSizes(const std::string& cameraId); |
Shuzhen Wang | 89db299 | 2021-05-20 13:09:48 -0700 | [diff] [blame] | 403 | |
Valentin Iftime | 29e2e15 | 2021-08-13 15:17:33 +0200 | [diff] [blame] | 404 | status_t notifyUsbDeviceEvent(int32_t eventId, const std::string &usbDeviceId); |
| 405 | |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 406 | static const float kDepthARTolerance; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 407 | private: |
| 408 | // All private members, unless otherwise noted, expect mInterfaceMutex to be locked before use |
| 409 | mutable std::mutex mInterfaceMutex; |
| 410 | |
| 411 | wp<StatusListener> mListener; |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 412 | HidlServiceInteractionProxy* mHidlServiceProxy; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 413 | |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 414 | // Current overall Android device physical status |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 415 | int64_t mDeviceState; |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 416 | |
Shuzhen Wang | 6ba8eb2 | 2018-07-08 13:10:44 -0700 | [diff] [blame] | 417 | // mProviderLifecycleLock is locked during onRegistration and removeProvider |
| 418 | mutable std::mutex mProviderLifecycleLock; |
| 419 | |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 420 | static HidlServiceInteractionProxyImpl sHidlServiceInteractionProxy; |
| 421 | |
| 422 | struct HalCameraProvider { |
| 423 | // Empty parent struct for storing either aidl / hidl camera provider reference |
| 424 | HalCameraProvider(const char *descriptor) : mDescriptor(descriptor) { }; |
| 425 | virtual ~HalCameraProvider() {}; |
| 426 | std::string mDescriptor; |
| 427 | }; |
| 428 | |
| 429 | struct HidlHalCameraProvider : public HalCameraProvider { |
| 430 | HidlHalCameraProvider( |
| 431 | const sp<hardware::camera::provider::V2_4::ICameraProvider> &provider, |
| 432 | const char *descriptor) : |
| 433 | HalCameraProvider(descriptor), mCameraProvider(provider) { }; |
| 434 | private: |
| 435 | sp<hardware::camera::provider::V2_4::ICameraProvider> mCameraProvider; |
| 436 | }; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 437 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 438 | struct AidlHalCameraProvider : public HalCameraProvider { |
| 439 | AidlHalCameraProvider( |
| 440 | const std::shared_ptr< |
| 441 | aidl::android::hardware::camera::provider::ICameraProvider> &provider, |
| 442 | const char *descriptor) : |
| 443 | HalCameraProvider(descriptor), mCameraProvider(provider) { }; |
| 444 | private: |
| 445 | std::shared_ptr<aidl::android::hardware::camera::provider::ICameraProvider> mCameraProvider; |
| 446 | }; |
| 447 | |
| 448 | |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 449 | // Mapping from CameraDevice IDs to CameraProviders. This map is used to keep the |
| 450 | // ICameraProvider alive while it is in use by the camera with the given ID for camera |
| 451 | // capabilities |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 452 | std::unordered_map<std::string, std::shared_ptr<HalCameraProvider>> |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 453 | mCameraProviderByCameraId; |
| 454 | |
| 455 | // Mapping from CameraDevice IDs to CameraProviders. This map is used to keep the |
| 456 | // ICameraProvider alive while it is in use by the camera with the given ID for torch |
| 457 | // capabilities |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 458 | std::unordered_map<std::string, std::shared_ptr<HalCameraProvider>> |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 459 | mTorchProviderByCameraId; |
| 460 | |
| 461 | // Lock for accessing mCameraProviderByCameraId and mTorchProviderByCameraId |
| 462 | std::mutex mProviderInterfaceMapLock; |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 463 | struct ProviderInfo : public virtual RefBase { |
| 464 | friend struct HidlProviderInfo; |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 465 | friend struct AidlProviderInfo; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 466 | const std::string mProviderName; |
Emilian Peev | c93cac2 | 2020-08-17 16:00:10 -0700 | [diff] [blame] | 467 | const std::string mProviderInstance; |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 468 | const metadata_vendor_id_t mProviderTagid; |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 469 | int32_t mMinorVersion; |
Peter Kalauskas | 1b3c907 | 2018-11-07 12:41:53 -0800 | [diff] [blame] | 470 | sp<VendorTagDescriptor> mVendorTagDescriptor; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 471 | bool mSetTorchModeSupported; |
| 472 | bool mIsRemote; |
| 473 | |
Emilian Peev | c93cac2 | 2020-08-17 16:00:10 -0700 | [diff] [blame] | 474 | ProviderInfo(const std::string &providerName, const std::string &providerInstance, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 475 | CameraProviderManager *manager); |
| 476 | ~ProviderInfo(); |
| 477 | |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 478 | virtual IPCTransport getIPCTransport() = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 479 | |
| 480 | const std::string& getType() const; |
| 481 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 482 | status_t dump(int fd, const Vector<String16>& args) const; |
| 483 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 484 | void initializeProviderInfoCommon(const std::vector<std::string> &devices); |
Peter Kalauskas | 1b3c907 | 2018-11-07 12:41:53 -0800 | [diff] [blame] | 485 | /** |
| 486 | * Setup vendor tags for this provider |
| 487 | */ |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 488 | virtual status_t setUpVendorTags() = 0; |
Peter Kalauskas | 1b3c907 | 2018-11-07 12:41:53 -0800 | [diff] [blame] | 489 | |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 490 | /** |
| 491 | * Notify provider about top-level device physical state changes |
Emilian Peev | 7fe6c42 | 2021-09-08 13:43:20 -0700 | [diff] [blame] | 492 | * |
| 493 | * Note that 'mInterfaceMutex' should not be held when calling this method. |
| 494 | * It is possible for camera providers to add/remove devices and try to |
| 495 | * acquire it. |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 496 | */ |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 497 | virtual status_t notifyDeviceStateChange(int64_t newDeviceState) = 0; |
| 498 | |
| 499 | virtual bool successfullyStartedProviderInterface() = 0; |
Jayant Chowdhary | cbe770a | 2020-02-14 11:14:46 -0800 | [diff] [blame] | 500 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 501 | virtual int64_t getDeviceState() = 0; |
| 502 | |
Jayant Chowdhary | cbe770a | 2020-02-14 11:14:46 -0800 | [diff] [blame] | 503 | std::vector<std::unordered_set<std::string>> getConcurrentCameraIdCombinations(); |
| 504 | |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 505 | /** |
Emilian Peev | b50402e | 2021-09-24 17:41:57 -0700 | [diff] [blame] | 506 | * Notify 'DeviceInfo' instanced about top-level device physical state changes |
| 507 | * |
| 508 | * Note that 'mInterfaceMutex' should be held when calling this method. |
| 509 | */ |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 510 | void notifyDeviceInfoStateChangeLocked(int64_t newDeviceState); |
Emilian Peev | b50402e | 2021-09-24 17:41:57 -0700 | [diff] [blame] | 511 | |
| 512 | /** |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 513 | * Query the camera provider for concurrent stream configuration support |
| 514 | */ |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 515 | virtual status_t isConcurrentSessionConfigurationSupported( |
| 516 | const std::vector<CameraIdAndSessionConfiguration> &cameraIdsAndSessionConfigs, |
| 517 | const std::set<std::string>& perfClassPrimaryCameraIds, |
| 518 | int targetSdkVersion, bool *isSupported) = 0; |
| 519 | |
Valentin Iftime | 29e2e15 | 2021-08-13 15:17:33 +0200 | [diff] [blame] | 520 | /** |
| 521 | * Remove all devices associated with this provider and notify listeners |
| 522 | * with NOT_PRESENT state. |
| 523 | */ |
| 524 | void removeAllDevices(); |
| 525 | |
| 526 | /** |
| 527 | * Provider is an external lazy HAL |
| 528 | */ |
| 529 | bool isExternalLazyHAL() const; |
| 530 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 531 | // Basic device information, common to all camera devices |
| 532 | struct DeviceInfo { |
| 533 | const std::string mName; // Full instance name |
| 534 | const std::string mId; // ID section of full name |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 535 | //Both hidl and aidl DeviceInfos. Aidl deviceInfos get {3, 8} to |
| 536 | //start off. |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 537 | const hardware::hidl_version mVersion; |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 538 | const metadata_vendor_id_t mProviderTagid; |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 539 | bool mIsLogicalCamera; |
| 540 | std::vector<std::string> mPhysicalIds; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 541 | hardware::CameraInfo mInfo; |
Jayant Chowdhary | 5216b21 | 2019-07-17 09:26:23 -0700 | [diff] [blame] | 542 | SystemCameraKind mSystemCameraKind = SystemCameraKind::PUBLIC; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 543 | |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 544 | const CameraResourceCost mResourceCost; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 545 | |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 546 | CameraDeviceStatus mStatus; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 547 | |
Shuzhen Wang | 7968043 | 2020-03-05 11:53:46 -0800 | [diff] [blame] | 548 | wp<ProviderInfo> mParentProvider; |
Rucha Katakwar | 3828452 | 2021-11-10 11:25:21 -0800 | [diff] [blame] | 549 | // Torch strength default, maximum levels if the torch strength control |
| 550 | // feature is supported. |
| 551 | int32_t mTorchStrengthLevel; |
| 552 | int32_t mTorchMaximumStrengthLevel; |
| 553 | int32_t mTorchDefaultStrengthLevel; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 554 | |
Valentin Iftime | 29e2e15 | 2021-08-13 15:17:33 +0200 | [diff] [blame] | 555 | // Wait for lazy HALs to confirm device availability |
| 556 | static const nsecs_t kDeviceAvailableTimeout = 2000e6; // 2000 ms |
| 557 | Mutex mDeviceAvailableLock; |
| 558 | Condition mDeviceAvailableSignal; |
| 559 | bool mIsDeviceAvailable = true; |
| 560 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 561 | bool hasFlashUnit() const { return mHasFlashUnit; } |
Shuzhen Wang | dbdf72b | 2019-11-13 11:22:12 -0800 | [diff] [blame] | 562 | bool supportNativeZoomRatio() const { return mSupportNativeZoomRatio; } |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 563 | virtual status_t setTorchMode(bool enabled) = 0; |
Rucha Katakwar | 3828452 | 2021-11-10 11:25:21 -0800 | [diff] [blame] | 564 | virtual status_t turnOnTorchWithStrengthLevel(int32_t torchStrength) = 0; |
| 565 | virtual status_t getTorchStrengthLevel(int32_t *torchStrength) = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 566 | virtual status_t getCameraInfo(hardware::CameraInfo *info) const = 0; |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 567 | virtual bool isAPI1Compatible() const = 0; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 568 | virtual status_t dumpState(int fd) = 0; |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 569 | virtual status_t getCameraCharacteristics(bool overrideForPerfClass, |
| 570 | CameraMetadata *characteristics) const { |
| 571 | (void) overrideForPerfClass; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 572 | (void) characteristics; |
| 573 | return INVALID_OPERATION; |
| 574 | } |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 575 | virtual status_t getPhysicalCameraCharacteristics(const std::string& physicalCameraId, |
| 576 | CameraMetadata *characteristics) const { |
| 577 | (void) physicalCameraId; |
| 578 | (void) characteristics; |
| 579 | return INVALID_OPERATION; |
| 580 | } |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 581 | |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 582 | virtual status_t isSessionConfigurationSupported( |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 583 | const SessionConfiguration &/*configuration*/, |
| 584 | bool /*overrideForPerfClass*/, |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 585 | bool * /*status*/) { |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 586 | return INVALID_OPERATION; |
| 587 | } |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 588 | virtual status_t filterSmallJpegSizes() = 0; |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 589 | virtual void notifyDeviceStateChange(int64_t /*newState*/) {} |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 590 | |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 591 | DeviceInfo(const std::string& name, const metadata_vendor_id_t tagId, |
| 592 | const std::string &id, const hardware::hidl_version& version, |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 593 | const std::vector<std::string>& publicCameraIds, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 594 | const CameraResourceCost& resourceCost, |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 595 | sp<ProviderInfo> parentProvider) : |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 596 | mName(name), mId(id), mVersion(version), mProviderTagid(tagId), |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 597 | mIsLogicalCamera(false), mResourceCost(resourceCost), |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 598 | mStatus(CameraDeviceStatus::PRESENT), |
Rucha Katakwar | 3c6714d | 2021-12-15 13:56:55 -0800 | [diff] [blame] | 599 | mParentProvider(parentProvider), mTorchStrengthLevel(0), |
| 600 | mTorchMaximumStrengthLevel(0), mTorchDefaultStrengthLevel(0), |
| 601 | mHasFlashUnit(false), mSupportNativeZoomRatio(false), |
| 602 | mPublicCameraIds(publicCameraIds) {} |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 603 | virtual ~DeviceInfo() {} |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 604 | protected: |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 605 | |
Shuzhen Wang | dbdf72b | 2019-11-13 11:22:12 -0800 | [diff] [blame] | 606 | bool mHasFlashUnit; // const after constructor |
| 607 | bool mSupportNativeZoomRatio; // const after constructor |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 608 | const std::vector<std::string>& mPublicCameraIds; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 609 | }; |
| 610 | std::vector<std::unique_ptr<DeviceInfo>> mDevices; |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 611 | std::unordered_set<std::string> mUniqueCameraIds; |
Yin-Chia Yeh | e8e9e19 | 2017-03-16 15:23:51 -0700 | [diff] [blame] | 612 | int mUniqueDeviceCount; |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 613 | std::vector<std::string> mUniqueAPI1CompatibleCameraIds; |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 614 | // The initial public camera IDs published by the camera provider. |
| 615 | // Currently logical multi-camera is not supported for hot-plug camera. |
| 616 | // And we use this list to keep track of initial public camera IDs |
| 617 | // advertised by the provider, and to distinguish against "hidden" |
| 618 | // physical camera IDs. |
| 619 | std::vector<std::string> mProviderPublicCameraIds; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 620 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 621 | // HALv3-specific camera fields, including the actual device interface |
| 622 | struct DeviceInfo3 : public DeviceInfo { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 623 | |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 624 | virtual status_t setTorchMode(bool enabled) = 0; |
| 625 | virtual status_t turnOnTorchWithStrengthLevel(int32_t torchStrength) = 0; |
| 626 | virtual status_t getTorchStrengthLevel(int32_t *torchStrength) = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 627 | virtual status_t getCameraInfo(hardware::CameraInfo *info) const override; |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 628 | virtual bool isAPI1Compatible() const override; |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 629 | virtual status_t dumpState(int fd) = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 630 | virtual status_t getCameraCharacteristics( |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 631 | bool overrideForPerfClass, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 632 | CameraMetadata *characteristics) const override; |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 633 | virtual status_t getPhysicalCameraCharacteristics(const std::string& physicalCameraId, |
| 634 | CameraMetadata *characteristics) const override; |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 635 | virtual status_t isSessionConfigurationSupported( |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 636 | const SessionConfiguration &configuration, bool /*overrideForPerfClass*/, |
| 637 | bool *status /*out*/) = 0; |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 638 | virtual status_t filterSmallJpegSizes() override; |
Emilian Peev | b50402e | 2021-09-24 17:41:57 -0700 | [diff] [blame] | 639 | virtual void notifyDeviceStateChange( |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 640 | int64_t newState) override; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 641 | |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 642 | DeviceInfo3(const std::string& name, const metadata_vendor_id_t tagId, |
| 643 | const std::string &id, uint16_t minorVersion, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 644 | const CameraResourceCost& resourceCost, |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 645 | sp<ProviderInfo> parentProvider, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 646 | const std::vector<std::string>& publicCameraIds); |
| 647 | virtual ~DeviceInfo3() {}; |
| 648 | protected: |
| 649 | // Modified by derived transport specific (hidl / aidl) class |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 650 | CameraMetadata mCameraCharacteristics; |
Emilian Peev | b50402e | 2021-09-24 17:41:57 -0700 | [diff] [blame] | 651 | // Map device states to sensor orientations |
| 652 | std::unordered_map<int64_t, int32_t> mDeviceStateOrientationMap; |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 653 | // A copy of mCameraCharacteristics without performance class |
| 654 | // override |
| 655 | std::unique_ptr<CameraMetadata> mCameraCharNoPCOverride; |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 656 | std::unordered_map<std::string, CameraMetadata> mPhysicalCameraCharacteristics; |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 657 | void queryPhysicalCameraIds(); |
Jayant Chowdhary | 5216b21 | 2019-07-17 09:26:23 -0700 | [diff] [blame] | 658 | SystemCameraKind getSystemCameraKind(); |
Shuzhen Wang | 268a136 | 2018-10-16 16:32:59 -0700 | [diff] [blame] | 659 | status_t fixupMonochromeTags(); |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 660 | status_t addDynamicDepthTags(bool maxResolution = false); |
| 661 | status_t deriveHeicTags(bool maxResolution = false); |
Eino-Ville Talvala | f2e3709 | 2020-01-07 15:32:32 -0800 | [diff] [blame] | 662 | status_t addRotateCropTags(); |
Shuzhen Wang | 9bf8a6f | 2020-05-01 09:49:04 -0700 | [diff] [blame] | 663 | status_t addPreCorrectionActiveArraySize(); |
Eino-Ville Talvala | f2e3709 | 2020-01-07 15:32:32 -0800 | [diff] [blame] | 664 | |
Emilian Peev | 4c6d2b5 | 2019-01-04 17:13:56 +0000 | [diff] [blame] | 665 | static void getSupportedSizes(const CameraMetadata& ch, uint32_t tag, |
| 666 | android_pixel_format_t format, |
| 667 | std::vector<std::tuple<size_t, size_t>> *sizes /*out*/); |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 668 | static void getSupportedDurations( const CameraMetadata& ch, uint32_t tag, |
Emilian Peev | 4c6d2b5 | 2019-01-04 17:13:56 +0000 | [diff] [blame] | 669 | android_pixel_format_t format, |
| 670 | const std::vector<std::tuple<size_t, size_t>>& sizes, |
| 671 | std::vector<int64_t> *durations/*out*/); |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 672 | static void getSupportedDynamicDepthDurations( |
| 673 | const std::vector<int64_t>& depthDurations, |
Emilian Peev | 4c6d2b5 | 2019-01-04 17:13:56 +0000 | [diff] [blame] | 674 | const std::vector<int64_t>& blobDurations, |
| 675 | std::vector<int64_t> *dynamicDepthDurations /*out*/); |
| 676 | static void getSupportedDynamicDepthSizes( |
| 677 | const std::vector<std::tuple<size_t, size_t>>& blobSizes, |
| 678 | const std::vector<std::tuple<size_t, size_t>>& depthSizes, |
| 679 | std::vector<std::tuple<size_t, size_t>> *dynamicDepthSizes /*out*/, |
| 680 | std::vector<std::tuple<size_t, size_t>> *internalDepthSizes /*out*/); |
Shuzhen Wang | 268a136 | 2018-10-16 16:32:59 -0700 | [diff] [blame] | 681 | status_t removeAvailableKeys(CameraMetadata& c, const std::vector<uint32_t>& keys, |
| 682 | uint32_t keyTag); |
Shuzhen Wang | 68ac7ad | 2019-01-30 14:03:28 -0800 | [diff] [blame] | 683 | status_t fillHeicStreamCombinations(std::vector<int32_t>* outputs, |
| 684 | std::vector<int64_t>* durations, |
| 685 | std::vector<int64_t>* stallDurations, |
| 686 | const camera_metadata_entry& halStreamConfigs, |
| 687 | const camera_metadata_entry& halStreamDurations); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 688 | }; |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 689 | protected: |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 690 | std::string mType; |
| 691 | uint32_t mId; |
| 692 | |
Eino-Ville Talvala | 8d942f9 | 2017-03-13 10:09:51 -0700 | [diff] [blame] | 693 | std::mutex mLock; |
| 694 | |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 695 | CameraProviderManager *mManager; |
| 696 | |
Shuzhen Wang | 394ad70 | 2020-07-23 13:01:54 -0700 | [diff] [blame] | 697 | struct CameraStatusInfoT { |
| 698 | bool isPhysicalCameraStatus = false; |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 699 | std::string cameraId; |
| 700 | std::string physicalCameraId; |
| 701 | CameraDeviceStatus status; |
| 702 | CameraStatusInfoT(bool isForPhysicalCamera, const std::string& id, |
| 703 | const std::string& physicalId, |
| 704 | CameraDeviceStatus s) : |
Shuzhen Wang | 394ad70 | 2020-07-23 13:01:54 -0700 | [diff] [blame] | 705 | isPhysicalCameraStatus(isForPhysicalCamera), cameraId(id), |
| 706 | physicalCameraId(physicalId), status(s) {} |
| 707 | }; |
| 708 | |
| 709 | // Lock to synchronize between initialize() and camera status callbacks |
| 710 | std::mutex mInitLock; |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 711 | bool mInitialized = false; |
Shuzhen Wang | 394ad70 | 2020-07-23 13:01:54 -0700 | [diff] [blame] | 712 | std::vector<CameraStatusInfoT> mCachedStatus; |
| 713 | // End of scope for mInitLock |
| 714 | |
| 715 | std::future<void> mInitialStatusCallbackFuture; |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 716 | |
| 717 | std::unique_ptr<ProviderInfo::DeviceInfo> |
| 718 | virtual initializeDeviceInfo( |
| 719 | const std::string &name, const metadata_vendor_id_t tagId, |
| 720 | const std::string &id, uint16_t minorVersion) = 0; |
| 721 | |
| 722 | virtual status_t reCacheConcurrentStreamingCameraIdsLocked() = 0; |
| 723 | |
Shuzhen Wang | 394ad70 | 2020-07-23 13:01:54 -0700 | [diff] [blame] | 724 | void notifyInitialStatusChange(sp<StatusListener> listener, |
| 725 | std::unique_ptr<std::vector<CameraStatusInfoT>> cachedStatus); |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 726 | |
Jayant Chowdhary | cbe770a | 2020-02-14 11:14:46 -0800 | [diff] [blame] | 727 | std::vector<std::unordered_set<std::string>> mConcurrentCameraIdCombinations; |
| 728 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 729 | // Parse provider instance name for type and id |
| 730 | static status_t parseProviderName(const std::string& name, |
| 731 | std::string *type, uint32_t *id); |
| 732 | |
| 733 | // Parse device instance name for device version, type, and id. |
| 734 | static status_t parseDeviceName(const std::string& name, |
| 735 | uint16_t *major, uint16_t *minor, std::string *type, std::string *id); |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 736 | |
| 737 | // Generate vendor tag id |
| 738 | static metadata_vendor_id_t generateVendorTagId(const std::string &name); |
Guennadi Liakhovetski | 6034bf5 | 2017-12-07 10:28:29 +0100 | [diff] [blame] | 739 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 740 | status_t addDevice( |
| 741 | const std::string& name, CameraDeviceStatus initialStatus, |
| 742 | /*out*/ std::string* parsedId); |
| 743 | |
| 744 | void cameraDeviceStatusChangeInternal(const std::string& cameraDeviceName, |
| 745 | CameraDeviceStatus newStatus); |
| 746 | |
| 747 | status_t cameraDeviceStatusChangeLocked( |
| 748 | std::string* id, const std::string& cameraDeviceName, |
| 749 | CameraDeviceStatus newStatus); |
| 750 | |
| 751 | void physicalCameraDeviceStatusChangeInternal(const std::string& cameraDeviceName, |
| 752 | const std::string& physicalCameraDeviceName, |
| 753 | CameraDeviceStatus newStatus); |
| 754 | |
| 755 | status_t physicalCameraDeviceStatusChangeLocked( |
| 756 | std::string* id, std::string* physicalId, |
| 757 | const std::string& cameraDeviceName, |
| 758 | const std::string& physicalCameraDeviceName, |
| 759 | CameraDeviceStatus newStatus); |
| 760 | |
| 761 | void torchModeStatusChangeInternal(const std::string& cameraDeviceName, |
| 762 | TorchModeStatus newStatus); |
| 763 | |
Guennadi Liakhovetski | 6034bf5 | 2017-12-07 10:28:29 +0100 | [diff] [blame] | 764 | void removeDevice(std::string id); |
Jayant Chowdhary | cbe770a | 2020-02-14 11:14:46 -0800 | [diff] [blame] | 765 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 766 | }; |
| 767 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 768 | template <class ProviderInfoType, class HalCameraProviderType> |
| 769 | status_t setTorchModeT(sp<ProviderInfo> &parentProvider, |
| 770 | std::shared_ptr<HalCameraProvider> *halCameraProvider); |
| 771 | |
| 772 | // Try to get hidl provider services declared. Expects mInterfaceMutex to be |
| 773 | // locked. Also registers for hidl provider service notifications. |
| 774 | status_t tryToInitAndAddHidlProvidersLocked(HidlServiceInteractionProxy *hidlProxy); |
| 775 | |
| 776 | // Try to get aidl provider services declared. Expects mInterfaceMutex to be |
| 777 | // locked. Also registers for aidl provider service notifications. |
| 778 | status_t tryToAddAidlProvidersLocked(); |
| 779 | |
Emilian Peev | 7fe6c42 | 2021-09-08 13:43:20 -0700 | [diff] [blame] | 780 | /** |
| 781 | * Save the ICameraProvider while it is being used by a camera or torch client |
| 782 | */ |
| 783 | void saveRef(DeviceMode usageType, const std::string &cameraId, |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 784 | std::shared_ptr<HalCameraProvider> provider); |
Emilian Peev | 7fe6c42 | 2021-09-08 13:43:20 -0700 | [diff] [blame] | 785 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 786 | // Utility to find a DeviceInfo by ID; pointer is only valid while mInterfaceMutex is held |
| 787 | // and the calling code doesn't mutate the list of providers or their lists of devices. |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 788 | // Finds the first device of the given ID that falls within the requested version range |
| 789 | // minVersion <= deviceVersion < maxVersion |
| 790 | // No guarantees on the order of traversal |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 791 | ProviderInfo::DeviceInfo* findDeviceInfoLocked(const std::string& id, |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 792 | hardware::hidl_version minVersion = hardware::hidl_version{0,0}, |
| 793 | hardware::hidl_version maxVersion = hardware::hidl_version{1000,0}) const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 794 | |
Valentin Iftime | 29e2e15 | 2021-08-13 15:17:33 +0200 | [diff] [blame] | 795 | // Map external providers to USB devices in order to handle USB hotplug |
| 796 | // events for lazy HALs |
| 797 | std::pair<std::vector<std::string>, sp<ProviderInfo>> |
| 798 | mExternalUsbDevicesForProvider; |
| 799 | sp<ProviderInfo> startExternalLazyProvider() const; |
| 800 | |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 801 | status_t addHidlProviderLocked(const std::string& newProvider, bool preexisting = false); |
Emilian Peev | c93cac2 | 2020-08-17 16:00:10 -0700 | [diff] [blame] | 802 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 803 | status_t addAidlProviderLocked(const std::string& newProvider); |
| 804 | |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 805 | status_t tryToInitializeHidlProviderLocked(const std::string& providerName, |
Emilian Peev | c93cac2 | 2020-08-17 16:00:10 -0700 | [diff] [blame] | 806 | const sp<ProviderInfo>& providerInfo); |
Eino-Ville Talvala | 8d942f9 | 2017-03-13 10:09:51 -0700 | [diff] [blame] | 807 | |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 808 | status_t tryToInitializeAidlProviderLocked(const std::string& providerName, |
| 809 | const sp<ProviderInfo>& providerInfo); |
| 810 | |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 811 | bool isLogicalCameraLocked(const std::string& id, std::vector<std::string>* physicalCameraIds); |
| 812 | |
Jayant Chowdhary | e8c4b23 | 2022-02-04 18:18:04 +0000 | [diff] [blame] | 813 | // No method corresponding to the same provider / member belonging to the |
| 814 | // same provider should be used after this method is called since it'll lead |
| 815 | // to invalid memory access (especially since this is called by ProviderInfo methods on hal |
| 816 | // service death). |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 817 | status_t removeProvider(const std::string& provider); |
Eino-Ville Talvala | 8d942f9 | 2017-03-13 10:09:51 -0700 | [diff] [blame] | 818 | sp<StatusListener> getStatusListener() const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 819 | |
| 820 | bool isValidDeviceLocked(const std::string &id, uint16_t majorVersion) const; |
| 821 | |
Emilian Peev | c93cac2 | 2020-08-17 16:00:10 -0700 | [diff] [blame] | 822 | size_t mProviderInstanceId = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 823 | std::vector<sp<ProviderInfo>> mProviders; |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 824 | // Provider names of AIDL providers with retrieved binders. |
| 825 | std::set<std::string> mAidlProviderWithBinders; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 826 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 827 | static const char* deviceStatusToString( |
| 828 | const hardware::camera::common::V1_0::CameraDeviceStatus&); |
| 829 | static const char* torchStatusToString( |
| 830 | const hardware::camera::common::V1_0::TorchModeStatus&); |
| 831 | |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 832 | status_t getCameraCharacteristicsLocked(const std::string &id, bool overrideForPerfClass, |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 833 | CameraMetadata* characteristics) const; |
| 834 | void filterLogicalCameraIdsLocked(std::vector<std::string>& deviceIds) const; |
Jayant Chowdhary | 847947d | 2019-08-30 18:02:59 -0700 | [diff] [blame] | 835 | |
Jayant Chowdhary | 33e8ef8 | 2019-09-27 09:20:42 -0700 | [diff] [blame] | 836 | status_t getSystemCameraKindLocked(const std::string& id, SystemCameraKind *kind) const; |
Jayant Chowdhary | 0bd3852 | 2021-11-05 17:49:27 -0700 | [diff] [blame] | 837 | std::pair<bool, ProviderInfo::DeviceInfo *> isHiddenPhysicalCameraInternal( |
| 838 | const std::string& cameraId) const; |
Jayant Chowdhary | 847947d | 2019-08-30 18:02:59 -0700 | [diff] [blame] | 839 | |
| 840 | void collectDeviceIdsLocked(const std::vector<std::string> deviceIds, |
| 841 | std::vector<std::string>& normalDeviceIds, |
| 842 | std::vector<std::string>& systemCameraDeviceIds) const; |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 843 | |
Valentin Iftime | 29e2e15 | 2021-08-13 15:17:33 +0200 | [diff] [blame] | 844 | status_t usbDeviceDetached(const std::string &usbDeviceId); |
Jayant Chowdhary | a04055f | 2022-01-03 02:07:49 +0000 | [diff] [blame^] | 845 | ndk::ScopedAStatus onAidlRegistration(const std::string& in_name, |
| 846 | const ::ndk::SpAIBinder& in_binder); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 847 | }; |
| 848 | |
| 849 | } // namespace android |
| 850 | |
| 851 | #endif |