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> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 23 | #include <string> |
| 24 | #include <mutex> |
| 25 | |
| 26 | #include <camera/CameraParameters2.h> |
| 27 | #include <camera/CameraMetadata.h> |
| 28 | #include <camera/CameraBase.h> |
| 29 | #include <utils/Errors.h> |
| 30 | #include <android/hardware/camera/common/1.0/types.h> |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 31 | #include <android/hardware/camera/provider/2.5/ICameraProvider.h> |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 32 | #include <android/hardware/camera/device/3.4/ICameraDeviceSession.h> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 33 | #include <android/hidl/manager/1.0/IServiceNotification.h> |
Yin-Chia Yeh | 067428c | 2017-01-13 15:19:24 -0800 | [diff] [blame] | 34 | #include <camera/VendorTagDescriptor.h> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 35 | |
| 36 | namespace android { |
| 37 | |
| 38 | /** |
Yin-Chia Yeh | 067428c | 2017-01-13 15:19:24 -0800 | [diff] [blame] | 39 | * The vendor tag descriptor class that takes HIDL vendor tag information as |
| 40 | * input. Not part of VendorTagDescriptor class because that class is used |
| 41 | * in AIDL generated sources which don't have access to HIDL headers. |
| 42 | */ |
| 43 | class HidlVendorTagDescriptor : public VendorTagDescriptor { |
| 44 | public: |
| 45 | /** |
| 46 | * Create a VendorTagDescriptor object from the HIDL VendorTagSection |
| 47 | * vector. |
| 48 | * |
| 49 | * Returns OK on success, or a negative error code. |
| 50 | */ |
| 51 | static status_t createDescriptorFromHidl( |
| 52 | const hardware::hidl_vec<hardware::camera::common::V1_0::VendorTagSection>& vts, |
| 53 | /*out*/ |
| 54 | sp<VendorTagDescriptor>& descriptor); |
| 55 | }; |
| 56 | |
Jayant Chowdhary | 5216b21 | 2019-07-17 09:26:23 -0700 | [diff] [blame] | 57 | enum SystemCameraKind { |
| 58 | /** |
| 59 | * These camera devices are visible to all apps and system components alike |
| 60 | */ |
| 61 | PUBLIC = 0, |
| 62 | |
| 63 | /** |
| 64 | * These camera devices are visible only to processes having the |
| 65 | * android.permission.SYSTEM_CAMERA permission. They are not exposed to 3P |
| 66 | * apps. |
| 67 | */ |
| 68 | SYSTEM_ONLY_CAMERA, |
| 69 | |
| 70 | /** |
| 71 | * These camera devices are visible only to HAL clients (that try to connect |
| 72 | * on a hwbinder thread). |
| 73 | */ |
| 74 | HIDDEN_SECURE_CAMERA |
| 75 | }; |
| 76 | |
Yin-Chia Yeh | 067428c | 2017-01-13 15:19:24 -0800 | [diff] [blame] | 77 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 78 | * A manager for all camera providers available on an Android device. |
| 79 | * |
| 80 | * Responsible for enumerating providers and the individual camera devices |
| 81 | * they export, both at startup and as providers and devices are added/removed. |
| 82 | * |
| 83 | * Provides methods for requesting information about individual devices and for |
| 84 | * opening them for active use. |
| 85 | * |
| 86 | */ |
| 87 | class CameraProviderManager : virtual public hidl::manager::V1_0::IServiceNotification { |
| 88 | public: |
| 89 | |
| 90 | ~CameraProviderManager(); |
| 91 | |
| 92 | // Tiny proxy for the static methods in a HIDL interface that communicate with the hardware |
| 93 | // service manager, to be replacable in unit tests with a fake. |
| 94 | struct ServiceInteractionProxy { |
| 95 | virtual bool registerForNotifications( |
| 96 | const std::string &serviceName, |
| 97 | const sp<hidl::manager::V1_0::IServiceNotification> |
| 98 | ¬ification) = 0; |
Eino-Ville Talvala | ec96060 | 2019-10-15 11:46:16 -0700 | [diff] [blame] | 99 | // Will not wait for service to start if it's not already running |
| 100 | virtual sp<hardware::camera::provider::V2_4::ICameraProvider> tryGetService( |
| 101 | const std::string &serviceName) = 0; |
| 102 | // Will block for service if it exists but isn't running |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 103 | virtual sp<hardware::camera::provider::V2_4::ICameraProvider> getService( |
| 104 | const std::string &serviceName) = 0; |
Yin-Chia Yeh | 177b0c1 | 2019-06-25 10:53:03 -0700 | [diff] [blame] | 105 | virtual hardware::hidl_vec<hardware::hidl_string> listServices() = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 106 | virtual ~ServiceInteractionProxy() {} |
| 107 | }; |
| 108 | |
| 109 | // Standard use case - call into the normal generated static methods which invoke |
| 110 | // the real hardware service manager |
| 111 | struct HardwareServiceInteractionProxy : public ServiceInteractionProxy { |
| 112 | virtual bool registerForNotifications( |
| 113 | const std::string &serviceName, |
| 114 | const sp<hidl::manager::V1_0::IServiceNotification> |
| 115 | ¬ification) override { |
| 116 | return hardware::camera::provider::V2_4::ICameraProvider::registerForNotifications( |
| 117 | serviceName, notification); |
| 118 | } |
Eino-Ville Talvala | ec96060 | 2019-10-15 11:46:16 -0700 | [diff] [blame] | 119 | virtual sp<hardware::camera::provider::V2_4::ICameraProvider> tryGetService( |
| 120 | const std::string &serviceName) override { |
| 121 | return hardware::camera::provider::V2_4::ICameraProvider::tryGetService(serviceName); |
| 122 | } |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 123 | virtual sp<hardware::camera::provider::V2_4::ICameraProvider> getService( |
| 124 | const std::string &serviceName) override { |
| 125 | return hardware::camera::provider::V2_4::ICameraProvider::getService(serviceName); |
| 126 | } |
Yin-Chia Yeh | 177b0c1 | 2019-06-25 10:53:03 -0700 | [diff] [blame] | 127 | |
| 128 | virtual hardware::hidl_vec<hardware::hidl_string> listServices() override; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | /** |
| 132 | * Listener interface for device/torch status changes |
| 133 | */ |
| 134 | struct StatusListener : virtual public RefBase { |
| 135 | ~StatusListener() {} |
| 136 | |
| 137 | virtual void onDeviceStatusChanged(const String8 &cameraId, |
| 138 | hardware::camera::common::V1_0::CameraDeviceStatus newStatus) = 0; |
| 139 | virtual void onTorchStatusChanged(const String8 &cameraId, |
| 140 | hardware::camera::common::V1_0::TorchModeStatus newStatus) = 0; |
Emilian Peev | aee727d | 2017-05-04 16:35:48 +0100 | [diff] [blame] | 141 | virtual void onNewProviderRegistered() = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | /** |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 145 | * Represents the mode a camera device is currently in |
| 146 | */ |
| 147 | enum class DeviceMode { |
| 148 | TORCH, |
| 149 | CAMERA |
| 150 | }; |
| 151 | |
| 152 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 153 | * Initialize the manager and give it a status listener; optionally accepts a service |
| 154 | * interaction proxy. |
| 155 | * |
| 156 | * The default proxy communicates via the hardware service manager; alternate proxies can be |
| 157 | * used for testing. The lifetime of the proxy must exceed the lifetime of the manager. |
| 158 | */ |
| 159 | status_t initialize(wp<StatusListener> listener, |
| 160 | ServiceInteractionProxy *proxy = &sHardwareServiceInteractionProxy); |
| 161 | |
| 162 | /** |
Jayant Chowdhary | 847947d | 2019-08-30 18:02:59 -0700 | [diff] [blame] | 163 | * Retrieve the total number of available cameras. |
| 164 | * This value may change dynamically as cameras are added or removed. |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 165 | */ |
Jayant Chowdhary | 847947d | 2019-08-30 18:02:59 -0700 | [diff] [blame] | 166 | std::pair<int, int> getCameraCount() const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 167 | |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 168 | std::vector<std::string> getCameraDeviceIds() const; |
| 169 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 170 | /** |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 171 | * Retrieve the number of API1 compatible cameras; these are internal and |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 172 | * backwards-compatible. This is the set of cameras that will be |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 173 | * accessible via the old camera API. |
| 174 | * The return value may change dynamically due to external camera hotplug. |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 175 | */ |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 176 | std::vector<std::string> getAPI1CompatibleCameraDeviceIds() const; |
Yin-Chia Yeh | dc3134e | 2017-03-23 15:26:59 -0700 | [diff] [blame] | 177 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 178 | /** |
| 179 | * Return true if a device with a given ID and major version exists |
| 180 | */ |
| 181 | bool isValidDevice(const std::string &id, uint16_t majorVersion) const; |
| 182 | |
| 183 | /** |
| 184 | * Return true if a device with a given ID has a flash unit. Returns false |
| 185 | * for devices that are unknown. |
| 186 | */ |
| 187 | bool hasFlashUnit(const std::string &id) const; |
| 188 | |
| 189 | /** |
| 190 | * Return the resource cost of this camera device |
| 191 | */ |
| 192 | status_t getResourceCost(const std::string &id, |
| 193 | hardware::camera::common::V1_0::CameraResourceCost* cost) const; |
| 194 | |
| 195 | /** |
| 196 | * Return the old camera API camera info |
| 197 | */ |
| 198 | status_t getCameraInfo(const std::string &id, |
| 199 | hardware::CameraInfo* info) const; |
| 200 | |
| 201 | /** |
| 202 | * Return API2 camera characteristics - returns NAME_NOT_FOUND if a device ID does |
| 203 | * not have a v3 or newer HAL version. |
| 204 | */ |
| 205 | status_t getCameraCharacteristics(const std::string &id, |
| 206 | CameraMetadata* characteristics) const; |
| 207 | |
| 208 | /** |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 209 | * Check for device support of specific stream combination. |
| 210 | */ |
| 211 | status_t isSessionConfigurationSupported(const std::string& id, |
| 212 | const hardware::camera::device::V3_4::StreamConfiguration &configuration, |
| 213 | bool *status /*out*/) const; |
| 214 | |
| 215 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 216 | * Return the highest supported device interface version for this ID |
| 217 | */ |
| 218 | status_t getHighestSupportedVersion(const std::string &id, |
| 219 | hardware::hidl_version *v); |
| 220 | |
| 221 | /** |
Yin-Chia Yeh | dc3134e | 2017-03-23 15:26:59 -0700 | [diff] [blame] | 222 | * Check if a given camera device support setTorchMode API. |
| 223 | */ |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 224 | bool supportSetTorchMode(const std::string &id) const; |
Yin-Chia Yeh | dc3134e | 2017-03-23 15:26:59 -0700 | [diff] [blame] | 225 | |
| 226 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 227 | * Turn on or off the flashlight on a given camera device. |
Yin-Chia Yeh | dc3134e | 2017-03-23 15:26:59 -0700 | [diff] [blame] | 228 | * May fail if the device does not support this API, is in active use, or if the device |
| 229 | * doesn't exist, etc. |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 230 | */ |
| 231 | status_t setTorchMode(const std::string &id, bool enabled); |
| 232 | |
| 233 | /** |
Yin-Chia Yeh | 067428c | 2017-01-13 15:19:24 -0800 | [diff] [blame] | 234 | * Setup vendor tags for all registered providers |
| 235 | */ |
| 236 | status_t setUpVendorTags(); |
| 237 | |
| 238 | /** |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 239 | * Inform registered providers about a device state change, such as folding or unfolding |
| 240 | */ |
| 241 | status_t notifyDeviceStateChange( |
| 242 | android::hardware::hidl_bitfield<hardware::camera::provider::V2_5::DeviceState> newState); |
| 243 | |
| 244 | /** |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 245 | * Open an active session to a camera device. |
| 246 | * |
| 247 | * This fully powers on the camera device hardware, and returns a handle to a |
| 248 | * session to be used for hardware configuration and operation. |
| 249 | */ |
| 250 | status_t openSession(const std::string &id, |
| 251 | const sp<hardware::camera::device::V3_2::ICameraDeviceCallback>& callback, |
| 252 | /*out*/ |
| 253 | sp<hardware::camera::device::V3_2::ICameraDeviceSession> *session); |
| 254 | |
| 255 | status_t openSession(const std::string &id, |
| 256 | const sp<hardware::camera::device::V1_0::ICameraDeviceCallback>& callback, |
| 257 | /*out*/ |
| 258 | sp<hardware::camera::device::V1_0::ICameraDevice> *session); |
| 259 | |
| 260 | /** |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 261 | * Save the ICameraProvider while it is being used by a camera or torch client |
| 262 | */ |
| 263 | void saveRef(DeviceMode usageType, const std::string &cameraId, |
| 264 | sp<hardware::camera::provider::V2_4::ICameraProvider> provider); |
| 265 | |
| 266 | /** |
| 267 | * Notify that the camera or torch is no longer being used by a camera client |
| 268 | */ |
| 269 | void removeRef(DeviceMode usageType, const std::string &cameraId); |
| 270 | |
| 271 | /** |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 272 | * IServiceNotification::onRegistration |
| 273 | * Invoked by the hardware service manager when a new camera provider is registered |
| 274 | */ |
| 275 | virtual hardware::Return<void> onRegistration(const hardware::hidl_string& fqName, |
| 276 | const hardware::hidl_string& name, |
| 277 | bool preexisting) override; |
| 278 | |
| 279 | /** |
| 280 | * Dump out information about available providers and devices |
| 281 | */ |
| 282 | status_t dump(int fd, const Vector<String16>& args); |
| 283 | |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 284 | /** |
| 285 | * Conversion methods between HAL Status and status_t and strings |
| 286 | */ |
| 287 | static status_t mapToStatusT(const hardware::camera::common::V1_0::Status& s); |
| 288 | static const char* statusToString(const hardware::camera::common::V1_0::Status& s); |
| 289 | |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 290 | /* |
| 291 | * Return provider type for a specific device. |
| 292 | */ |
| 293 | metadata_vendor_id_t getProviderTagIdLocked(const std::string& id, |
| 294 | hardware::hidl_version minVersion = hardware::hidl_version{0,0}, |
| 295 | hardware::hidl_version maxVersion = hardware::hidl_version{1000,0}) const; |
| 296 | |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 297 | /* |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 298 | * Check if a camera is a logical camera. And if yes, return |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 299 | * the physical camera ids. |
| 300 | */ |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 301 | bool isLogicalCamera(const std::string& id, std::vector<std::string>* physicalCameraIds); |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 302 | |
Jayant Chowdhary | 33e8ef8 | 2019-09-27 09:20:42 -0700 | [diff] [blame] | 303 | status_t getSystemCameraKind(const std::string& id, SystemCameraKind *kind) const; |
| 304 | bool isHiddenPhysicalCamera(const std::string& cameraId) const; |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 305 | |
| 306 | static const float kDepthARTolerance; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 307 | private: |
| 308 | // All private members, unless otherwise noted, expect mInterfaceMutex to be locked before use |
| 309 | mutable std::mutex mInterfaceMutex; |
| 310 | |
Yin-Chia Yeh | 52778d4 | 2016-12-22 18:20:43 -0800 | [diff] [blame] | 311 | // the status listener update callbacks will lock mStatusMutex |
| 312 | mutable std::mutex mStatusListenerMutex; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 313 | wp<StatusListener> mListener; |
| 314 | ServiceInteractionProxy* mServiceProxy; |
| 315 | |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 316 | // Current overall Android device physical status |
| 317 | android::hardware::hidl_bitfield<hardware::camera::provider::V2_5::DeviceState> mDeviceState; |
| 318 | |
Shuzhen Wang | 6ba8eb2 | 2018-07-08 13:10:44 -0700 | [diff] [blame] | 319 | // mProviderLifecycleLock is locked during onRegistration and removeProvider |
| 320 | mutable std::mutex mProviderLifecycleLock; |
| 321 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 322 | static HardwareServiceInteractionProxy sHardwareServiceInteractionProxy; |
| 323 | |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 324 | // Mapping from CameraDevice IDs to CameraProviders. This map is used to keep the |
| 325 | // ICameraProvider alive while it is in use by the camera with the given ID for camera |
| 326 | // capabilities |
| 327 | std::unordered_map<std::string, sp<hardware::camera::provider::V2_4::ICameraProvider>> |
| 328 | mCameraProviderByCameraId; |
| 329 | |
| 330 | // Mapping from CameraDevice IDs to CameraProviders. This map is used to keep the |
| 331 | // ICameraProvider alive while it is in use by the camera with the given ID for torch |
| 332 | // capabilities |
| 333 | std::unordered_map<std::string, sp<hardware::camera::provider::V2_4::ICameraProvider>> |
| 334 | mTorchProviderByCameraId; |
| 335 | |
| 336 | // Lock for accessing mCameraProviderByCameraId and mTorchProviderByCameraId |
| 337 | std::mutex mProviderInterfaceMapLock; |
| 338 | |
Eino-Ville Talvala | 8d942f9 | 2017-03-13 10:09:51 -0700 | [diff] [blame] | 339 | struct ProviderInfo : |
| 340 | virtual public hardware::camera::provider::V2_4::ICameraProviderCallback, |
| 341 | virtual public hardware::hidl_death_recipient |
| 342 | { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 343 | const std::string mProviderName; |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 344 | const metadata_vendor_id_t mProviderTagid; |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 345 | int mMinorVersion; |
Peter Kalauskas | 1b3c907 | 2018-11-07 12:41:53 -0800 | [diff] [blame] | 346 | sp<VendorTagDescriptor> mVendorTagDescriptor; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 347 | bool mSetTorchModeSupported; |
| 348 | bool mIsRemote; |
| 349 | |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 350 | // Current overall Android device physical status |
| 351 | hardware::hidl_bitfield<hardware::camera::provider::V2_5::DeviceState> mDeviceState; |
| 352 | |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 353 | // This pointer is used to keep a reference to the ICameraProvider that was last accessed. |
| 354 | wp<hardware::camera::provider::V2_4::ICameraProvider> mActiveInterface; |
| 355 | |
| 356 | sp<hardware::camera::provider::V2_4::ICameraProvider> mSavedInterface; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 357 | |
| 358 | ProviderInfo(const std::string &providerName, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 359 | CameraProviderManager *manager); |
| 360 | ~ProviderInfo(); |
| 361 | |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 362 | status_t initialize(sp<hardware::camera::provider::V2_4::ICameraProvider>& interface, |
| 363 | hardware::hidl_bitfield<hardware::camera::provider::V2_5::DeviceState> |
| 364 | currentDeviceState); |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 365 | |
| 366 | const sp<hardware::camera::provider::V2_4::ICameraProvider> startProviderInterface(); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 367 | |
| 368 | const std::string& getType() const; |
| 369 | |
| 370 | status_t addDevice(const std::string& name, |
| 371 | hardware::camera::common::V1_0::CameraDeviceStatus initialStatus = |
| 372 | hardware::camera::common::V1_0::CameraDeviceStatus::PRESENT, |
| 373 | /*out*/ std::string *parsedId = nullptr); |
| 374 | |
| 375 | status_t dump(int fd, const Vector<String16>& args) const; |
| 376 | |
| 377 | // ICameraProviderCallbacks interface - these lock the parent mInterfaceMutex |
| 378 | virtual hardware::Return<void> cameraDeviceStatusChange( |
| 379 | const hardware::hidl_string& cameraDeviceName, |
| 380 | hardware::camera::common::V1_0::CameraDeviceStatus newStatus) override; |
| 381 | virtual hardware::Return<void> torchModeStatusChange( |
| 382 | const hardware::hidl_string& cameraDeviceName, |
| 383 | hardware::camera::common::V1_0::TorchModeStatus newStatus) override; |
| 384 | |
Eino-Ville Talvala | 8d942f9 | 2017-03-13 10:09:51 -0700 | [diff] [blame] | 385 | // hidl_death_recipient interface - this locks the parent mInterfaceMutex |
| 386 | virtual void serviceDied(uint64_t cookie, const wp<hidl::base::V1_0::IBase>& who) override; |
| 387 | |
Peter Kalauskas | 1b3c907 | 2018-11-07 12:41:53 -0800 | [diff] [blame] | 388 | /** |
| 389 | * Setup vendor tags for this provider |
| 390 | */ |
| 391 | status_t setUpVendorTags(); |
| 392 | |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 393 | /** |
| 394 | * Notify provider about top-level device physical state changes |
| 395 | */ |
| 396 | status_t notifyDeviceStateChange( |
| 397 | hardware::hidl_bitfield<hardware::camera::provider::V2_5::DeviceState> |
| 398 | newDeviceState); |
| 399 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 400 | // Basic device information, common to all camera devices |
| 401 | struct DeviceInfo { |
| 402 | const std::string mName; // Full instance name |
| 403 | const std::string mId; // ID section of full name |
| 404 | const hardware::hidl_version mVersion; |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 405 | const metadata_vendor_id_t mProviderTagid; |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 406 | bool mIsLogicalCamera; |
| 407 | std::vector<std::string> mPhysicalIds; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 408 | hardware::CameraInfo mInfo; |
| 409 | sp<IBase> mSavedInterface; |
Jayant Chowdhary | 5216b21 | 2019-07-17 09:26:23 -0700 | [diff] [blame] | 410 | SystemCameraKind mSystemCameraKind = SystemCameraKind::PUBLIC; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 411 | |
| 412 | const hardware::camera::common::V1_0::CameraResourceCost mResourceCost; |
| 413 | |
| 414 | hardware::camera::common::V1_0::CameraDeviceStatus mStatus; |
| 415 | |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 416 | sp<ProviderInfo> mParentProvider; |
| 417 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 418 | bool hasFlashUnit() const { return mHasFlashUnit; } |
| 419 | virtual status_t setTorchMode(bool enabled) = 0; |
| 420 | virtual status_t getCameraInfo(hardware::CameraInfo *info) const = 0; |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 421 | virtual bool isAPI1Compatible() const = 0; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 422 | virtual status_t dumpState(int fd) = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 423 | virtual status_t getCameraCharacteristics(CameraMetadata *characteristics) const { |
| 424 | (void) characteristics; |
| 425 | return INVALID_OPERATION; |
| 426 | } |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 427 | virtual status_t getPhysicalCameraCharacteristics(const std::string& physicalCameraId, |
| 428 | CameraMetadata *characteristics) const { |
| 429 | (void) physicalCameraId; |
| 430 | (void) characteristics; |
| 431 | return INVALID_OPERATION; |
| 432 | } |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 433 | |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 434 | virtual status_t isSessionConfigurationSupported( |
| 435 | const hardware::camera::device::V3_4::StreamConfiguration &/*configuration*/, |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 436 | bool * /*status*/) { |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 437 | return INVALID_OPERATION; |
| 438 | } |
| 439 | |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 440 | template<class InterfaceT> |
| 441 | sp<InterfaceT> startDeviceInterface(); |
| 442 | |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 443 | DeviceInfo(const std::string& name, const metadata_vendor_id_t tagId, |
| 444 | const std::string &id, const hardware::hidl_version& version, |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 445 | const std::vector<std::string>& publicCameraIds, |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 446 | const hardware::camera::common::V1_0::CameraResourceCost& resourceCost, |
| 447 | sp<ProviderInfo> parentProvider) : |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 448 | mName(name), mId(id), mVersion(version), mProviderTagid(tagId), |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 449 | mIsLogicalCamera(false), mResourceCost(resourceCost), |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 450 | mStatus(hardware::camera::common::V1_0::CameraDeviceStatus::PRESENT), |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 451 | mParentProvider(parentProvider), mHasFlashUnit(false), |
| 452 | mPublicCameraIds(publicCameraIds) {} |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 453 | virtual ~DeviceInfo(); |
| 454 | protected: |
| 455 | bool mHasFlashUnit; |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 456 | const std::vector<std::string>& mPublicCameraIds; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 457 | |
| 458 | template<class InterfaceT> |
| 459 | static status_t setTorchMode(InterfaceT& interface, bool enabled); |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 460 | |
| 461 | template<class InterfaceT> |
| 462 | status_t setTorchModeForDevice(bool enabled) { |
| 463 | // Don't save the ICameraProvider interface here because we assume that this was |
| 464 | // called from CameraProviderManager::setTorchMode(), which does save it. |
| 465 | const sp<InterfaceT> interface = startDeviceInterface<InterfaceT>(); |
| 466 | return DeviceInfo::setTorchMode(interface, enabled); |
| 467 | } |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 468 | }; |
| 469 | std::vector<std::unique_ptr<DeviceInfo>> mDevices; |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 470 | std::unordered_set<std::string> mUniqueCameraIds; |
Yin-Chia Yeh | e8e9e19 | 2017-03-16 15:23:51 -0700 | [diff] [blame] | 471 | int mUniqueDeviceCount; |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 472 | std::vector<std::string> mUniqueAPI1CompatibleCameraIds; |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 473 | // The initial public camera IDs published by the camera provider. |
| 474 | // Currently logical multi-camera is not supported for hot-plug camera. |
| 475 | // And we use this list to keep track of initial public camera IDs |
| 476 | // advertised by the provider, and to distinguish against "hidden" |
| 477 | // physical camera IDs. |
| 478 | std::vector<std::string> mProviderPublicCameraIds; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 479 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 480 | // HALv1-specific camera fields, including the actual device interface |
| 481 | struct DeviceInfo1 : public DeviceInfo { |
| 482 | typedef hardware::camera::device::V1_0::ICameraDevice InterfaceT; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 483 | |
| 484 | virtual status_t setTorchMode(bool enabled) override; |
| 485 | virtual status_t getCameraInfo(hardware::CameraInfo *info) const override; |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 486 | //In case of Device1Info assume that we are always API1 compatible |
| 487 | virtual bool isAPI1Compatible() const override { return true; } |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 488 | virtual status_t dumpState(int fd) override; |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 489 | DeviceInfo1(const std::string& name, const metadata_vendor_id_t tagId, |
| 490 | const std::string &id, uint16_t minorVersion, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 491 | const hardware::camera::common::V1_0::CameraResourceCost& resourceCost, |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 492 | sp<ProviderInfo> parentProvider, |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 493 | const std::vector<std::string>& publicCameraIds, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 494 | sp<InterfaceT> interface); |
| 495 | virtual ~DeviceInfo1(); |
| 496 | private: |
| 497 | CameraParameters2 mDefaultParameters; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 498 | status_t cacheCameraInfo(sp<InterfaceT> interface); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 499 | }; |
| 500 | |
| 501 | // HALv3-specific camera fields, including the actual device interface |
| 502 | struct DeviceInfo3 : public DeviceInfo { |
| 503 | typedef hardware::camera::device::V3_2::ICameraDevice InterfaceT; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 504 | |
| 505 | virtual status_t setTorchMode(bool enabled) override; |
| 506 | virtual status_t getCameraInfo(hardware::CameraInfo *info) const override; |
Emilian Peev | f53f66e | 2017-04-11 14:29:43 +0100 | [diff] [blame] | 507 | virtual bool isAPI1Compatible() const override; |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 508 | virtual status_t dumpState(int fd) override; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 509 | virtual status_t getCameraCharacteristics( |
| 510 | CameraMetadata *characteristics) const override; |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 511 | virtual status_t getPhysicalCameraCharacteristics(const std::string& physicalCameraId, |
| 512 | CameraMetadata *characteristics) const override; |
Emilian Peev | 35ae826 | 2018-11-08 13:11:32 +0000 | [diff] [blame] | 513 | virtual status_t isSessionConfigurationSupported( |
| 514 | const hardware::camera::device::V3_4::StreamConfiguration &configuration, |
| 515 | bool *status /*out*/) |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 516 | override; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 517 | |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 518 | DeviceInfo3(const std::string& name, const metadata_vendor_id_t tagId, |
| 519 | const std::string &id, uint16_t minorVersion, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 520 | const hardware::camera::common::V1_0::CameraResourceCost& resourceCost, |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 521 | sp<ProviderInfo> parentProvider, |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 522 | const std::vector<std::string>& publicCameraIds, sp<InterfaceT> interface); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 523 | virtual ~DeviceInfo3(); |
| 524 | private: |
| 525 | CameraMetadata mCameraCharacteristics; |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 526 | std::unordered_map<std::string, CameraMetadata> mPhysicalCameraCharacteristics; |
Shuzhen Wang | 03d8cc1 | 2018-09-12 14:17:09 -0700 | [diff] [blame] | 527 | void queryPhysicalCameraIds(); |
Jayant Chowdhary | 5216b21 | 2019-07-17 09:26:23 -0700 | [diff] [blame] | 528 | SystemCameraKind getSystemCameraKind(); |
Shuzhen Wang | 268a136 | 2018-10-16 16:32:59 -0700 | [diff] [blame] | 529 | status_t fixupMonochromeTags(); |
Emilian Peev | 4c6d2b5 | 2019-01-04 17:13:56 +0000 | [diff] [blame] | 530 | status_t addDynamicDepthTags(); |
| 531 | static void getSupportedSizes(const CameraMetadata& ch, uint32_t tag, |
| 532 | android_pixel_format_t format, |
| 533 | std::vector<std::tuple<size_t, size_t>> *sizes /*out*/); |
| 534 | void getSupportedDurations( const CameraMetadata& ch, uint32_t tag, |
| 535 | android_pixel_format_t format, |
| 536 | const std::vector<std::tuple<size_t, size_t>>& sizes, |
| 537 | std::vector<int64_t> *durations/*out*/); |
| 538 | void getSupportedDynamicDepthDurations(const std::vector<int64_t>& depthDurations, |
| 539 | const std::vector<int64_t>& blobDurations, |
| 540 | std::vector<int64_t> *dynamicDepthDurations /*out*/); |
Emilian Peev | cbf174b | 2019-01-25 14:38:59 -0800 | [diff] [blame] | 541 | static bool isDepthPhotoLibraryPresent(); |
Emilian Peev | 4c6d2b5 | 2019-01-04 17:13:56 +0000 | [diff] [blame] | 542 | static void getSupportedDynamicDepthSizes( |
| 543 | const std::vector<std::tuple<size_t, size_t>>& blobSizes, |
| 544 | const std::vector<std::tuple<size_t, size_t>>& depthSizes, |
| 545 | std::vector<std::tuple<size_t, size_t>> *dynamicDepthSizes /*out*/, |
| 546 | std::vector<std::tuple<size_t, size_t>> *internalDepthSizes /*out*/); |
Shuzhen Wang | 268a136 | 2018-10-16 16:32:59 -0700 | [diff] [blame] | 547 | status_t removeAvailableKeys(CameraMetadata& c, const std::vector<uint32_t>& keys, |
| 548 | uint32_t keyTag); |
Shuzhen Wang | 68ac7ad | 2019-01-30 14:03:28 -0800 | [diff] [blame] | 549 | status_t fillHeicStreamCombinations(std::vector<int32_t>* outputs, |
| 550 | std::vector<int64_t>* durations, |
| 551 | std::vector<int64_t>* stallDurations, |
| 552 | const camera_metadata_entry& halStreamConfigs, |
| 553 | const camera_metadata_entry& halStreamDurations); |
| 554 | status_t deriveHeicTags(); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 555 | }; |
| 556 | |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 557 | private: |
| 558 | std::string mType; |
| 559 | uint32_t mId; |
| 560 | |
Eino-Ville Talvala | 8d942f9 | 2017-03-13 10:09:51 -0700 | [diff] [blame] | 561 | std::mutex mLock; |
| 562 | |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 563 | CameraProviderManager *mManager; |
| 564 | |
Yin-Chia Yeh | c3e9d6f | 2018-02-06 10:56:32 -0800 | [diff] [blame] | 565 | bool mInitialized = false; |
| 566 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 567 | // Templated method to instantiate the right kind of DeviceInfo and call the |
| 568 | // right CameraProvider getCameraDeviceInterface_* method. |
| 569 | template<class DeviceInfoT> |
| 570 | std::unique_ptr<DeviceInfo> initializeDeviceInfo(const std::string &name, |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 571 | const metadata_vendor_id_t tagId, const std::string &id, |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 572 | uint16_t minorVersion); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 573 | |
| 574 | // Helper for initializeDeviceInfo to use the right CameraProvider get method. |
| 575 | template<class InterfaceT> |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 576 | sp<InterfaceT> startDeviceInterface(const std::string &name); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 577 | |
| 578 | // Parse provider instance name for type and id |
| 579 | static status_t parseProviderName(const std::string& name, |
| 580 | std::string *type, uint32_t *id); |
| 581 | |
| 582 | // Parse device instance name for device version, type, and id. |
| 583 | static status_t parseDeviceName(const std::string& name, |
| 584 | uint16_t *major, uint16_t *minor, std::string *type, std::string *id); |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 585 | |
| 586 | // Generate vendor tag id |
| 587 | static metadata_vendor_id_t generateVendorTagId(const std::string &name); |
Guennadi Liakhovetski | 6034bf5 | 2017-12-07 10:28:29 +0100 | [diff] [blame] | 588 | |
| 589 | void removeDevice(std::string id); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 590 | }; |
| 591 | |
| 592 | // Utility to find a DeviceInfo by ID; pointer is only valid while mInterfaceMutex is held |
| 593 | // 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] | 594 | // Finds the first device of the given ID that falls within the requested version range |
| 595 | // minVersion <= deviceVersion < maxVersion |
| 596 | // No guarantees on the order of traversal |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 597 | ProviderInfo::DeviceInfo* findDeviceInfoLocked(const std::string& id, |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 598 | hardware::hidl_version minVersion = hardware::hidl_version{0,0}, |
| 599 | hardware::hidl_version maxVersion = hardware::hidl_version{1000,0}) const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 600 | |
Yin-Chia Yeh | 177b0c1 | 2019-06-25 10:53:03 -0700 | [diff] [blame] | 601 | status_t addProviderLocked(const std::string& newProvider); |
Eino-Ville Talvala | 8d942f9 | 2017-03-13 10:09:51 -0700 | [diff] [blame] | 602 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 603 | status_t removeProvider(const std::string& provider); |
Eino-Ville Talvala | 8d942f9 | 2017-03-13 10:09:51 -0700 | [diff] [blame] | 604 | sp<StatusListener> getStatusListener() const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 605 | |
| 606 | bool isValidDeviceLocked(const std::string &id, uint16_t majorVersion) const; |
| 607 | |
| 608 | std::vector<sp<ProviderInfo>> mProviders; |
| 609 | |
Peter Kalauskas | a29c135 | 2018-10-10 12:05:42 -0700 | [diff] [blame] | 610 | void addProviderToMap( |
| 611 | const std::string &cameraId, |
| 612 | sp<hardware::camera::provider::V2_4::ICameraProvider> provider, |
| 613 | bool isTorchUsage); |
| 614 | void removeCameraIdFromMap( |
| 615 | std::unordered_map<std::string, sp<hardware::camera::provider::V2_4::ICameraProvider>> &map, |
| 616 | const std::string &cameraId); |
| 617 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 618 | static const char* deviceStatusToString( |
| 619 | const hardware::camera::common::V1_0::CameraDeviceStatus&); |
| 620 | static const char* torchStatusToString( |
| 621 | const hardware::camera::common::V1_0::TorchModeStatus&); |
| 622 | |
Shuzhen Wang | e8aceb5 | 2018-05-21 12:00:56 -0700 | [diff] [blame] | 623 | status_t getCameraCharacteristicsLocked(const std::string &id, |
| 624 | CameraMetadata* characteristics) const; |
| 625 | void filterLogicalCameraIdsLocked(std::vector<std::string>& deviceIds) const; |
Jayant Chowdhary | 847947d | 2019-08-30 18:02:59 -0700 | [diff] [blame] | 626 | |
Jayant Chowdhary | 33e8ef8 | 2019-09-27 09:20:42 -0700 | [diff] [blame] | 627 | status_t getSystemCameraKindLocked(const std::string& id, SystemCameraKind *kind) const; |
| 628 | std::pair<bool, ProviderInfo::DeviceInfo *> isHiddenPhysicalCameraInternal(const std::string& cameraId) const; |
Jayant Chowdhary | 847947d | 2019-08-30 18:02:59 -0700 | [diff] [blame] | 629 | |
| 630 | void collectDeviceIdsLocked(const std::vector<std::string> deviceIds, |
| 631 | std::vector<std::string>& normalDeviceIds, |
| 632 | std::vector<std::string>& systemCameraDeviceIds) const; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 633 | }; |
| 634 | |
| 635 | } // namespace android |
| 636 | |
| 637 | #endif |