Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | package android.hardware; |
| 18 | |
| 19 | import android.hardware.ICamera; |
| 20 | import android.hardware.ICameraClient; |
| 21 | import android.hardware.camera2.ICameraDeviceUser; |
| 22 | import android.hardware.camera2.ICameraDeviceCallbacks; |
Cliff Wu | d8cae10 | 2021-03-11 01:37:42 +0800 | [diff] [blame] | 23 | import android.hardware.camera2.ICameraInjectionCallback; |
| 24 | import android.hardware.camera2.ICameraInjectionSession; |
Shuzhen Wang | 045be6c | 2023-10-12 10:01:10 -0700 | [diff] [blame] | 25 | import android.hardware.camera2.params.SessionConfiguration; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 26 | import android.hardware.camera2.params.VendorTagDescriptor; |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 27 | import android.hardware.camera2.params.VendorTagDescriptorCache; |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 28 | import android.hardware.camera2.utils.ConcurrentCameraIdCombination; |
| 29 | import android.hardware.camera2.utils.CameraIdAndSessionConfiguration; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 30 | import android.hardware.camera2.impl.CameraMetadataNative; |
| 31 | import android.hardware.ICameraServiceListener; |
| 32 | import android.hardware.CameraInfo; |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 33 | import android.hardware.CameraStatus; |
Avichal Rakesh | 6e57a2b | 2023-05-01 17:53:37 -0700 | [diff] [blame] | 34 | import android.hardware.CameraExtensionSessionStats; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Binder interface for the native camera service running in mediaserver. |
| 38 | * |
| 39 | * @hide |
| 40 | */ |
| 41 | interface ICameraService |
| 42 | { |
| 43 | /** |
| 44 | * All camera service and device Binder calls may return a |
| 45 | * ServiceSpecificException with the following error codes |
| 46 | */ |
| 47 | const int ERROR_PERMISSION_DENIED = 1; |
| 48 | const int ERROR_ALREADY_EXISTS = 2; |
| 49 | const int ERROR_ILLEGAL_ARGUMENT = 3; |
| 50 | const int ERROR_DISCONNECTED = 4; |
| 51 | const int ERROR_TIMED_OUT = 5; |
| 52 | const int ERROR_DISABLED = 6; |
| 53 | const int ERROR_CAMERA_IN_USE = 7; |
| 54 | const int ERROR_MAX_CAMERAS_IN_USE = 8; |
| 55 | const int ERROR_DEPRECATED_HAL = 9; |
| 56 | const int ERROR_INVALID_OPERATION = 10; |
| 57 | |
| 58 | /** |
| 59 | * Types for getNumberOfCameras |
| 60 | */ |
| 61 | const int CAMERA_TYPE_BACKWARD_COMPATIBLE = 0; |
| 62 | const int CAMERA_TYPE_ALL = 1; |
| 63 | |
| 64 | /** |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 65 | * Return the number of camera devices available in the system. |
| 66 | * |
| 67 | * @param type The type of the camera, can be either CAMERA_TYPE_BACKWARD_COMPATIBLE |
| 68 | * or CAMERA_TYPE_ALL. |
| 69 | * @param deviceId The device id of the context associated with the caller. |
| 70 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 71 | * policy for default device context). Only virtual cameras would be exposed |
| 72 | * only for custom policy and only real cameras would be exposed for default |
| 73 | * policy. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 74 | */ |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 75 | int getNumberOfCameras(int type, int deviceId, int devicePolicy); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 76 | |
| 77 | /** |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 78 | * If changed, reflect in |
| 79 | * frameworks/base/core/java/android/hardware/camera2/CameraManager.java. |
| 80 | * We have an enum here since the decision to override to portrait mode / fetch the |
| 81 | * rotationOverride as it exists in CameraManager right now is based on a static system |
| 82 | * property and not something that changes based dynamically, say on fold state. As a result, |
| 83 | * we can't use just a boolean to differentiate between the case where cameraserver should |
| 84 | * override to portrait (sensor orientation is 0, 180) or just rotate the sensor feed (sensor |
| 85 | * orientation is 90, 270) |
| 86 | */ |
| 87 | const int ROTATION_OVERRIDE_NONE = 0; |
| 88 | const int ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT = 1; |
| 89 | const int ROTATION_OVERRIDE_ROTATION_ONLY = 2; |
| 90 | |
| 91 | /** |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 92 | * Fetch basic camera information for a camera. |
| 93 | * |
| 94 | * @param cameraId The ID of the camera to fetch information for. |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 95 | * @param rotationOverride Whether to override the sensor orientation information to |
| 96 | * correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT} |
| 97 | * will override the sensor orientation and rotate and crop, while {@link |
| 98 | * ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed |
| 99 | * without changing the sensor orientation. |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 100 | * @param deviceId The device id of the context associated with the caller. |
| 101 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 102 | * policy for default device context). Only virtual cameras would be exposed |
| 103 | * only for custom policy and only real cameras would be exposed for default |
| 104 | * policy. |
| 105 | * @return CameraInfo for the camera. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 106 | */ |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 107 | CameraInfo getCameraInfo(int cameraId, int rotationOverride, int deviceId, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 108 | int devicePolicy); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Default UID/PID values for non-privileged callers of |
Eino-Ville Talvala | a976df8 | 2019-06-13 18:01:58 -0700 | [diff] [blame] | 112 | * connect() and connectDevice() |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 113 | */ |
| 114 | const int USE_CALLING_UID = -1; |
| 115 | const int USE_CALLING_PID = -1; |
| 116 | |
| 117 | /** |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 118 | * Open a camera device through the old camera API. |
| 119 | * |
| 120 | * @param cameraId The ID of the camera to open. |
| 121 | * @param opPackageName The package name to report for the app-ops. |
| 122 | * @param clientUid UID for the calling client. |
| 123 | * @param clientPid PID for the calling client. |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 124 | * @param targetSdkVersion the target sdk level of the application calling this function. |
| 125 | * @param rotationOverride Whether to override the sensor orientation information to |
| 126 | * correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT} |
| 127 | * will override the sensor orientation and rotate and crop, while {@link |
| 128 | * ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed |
| 129 | * without changing the sensor orientation. |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 130 | * @param forceSlowJpegMode Whether to force slow jpeg mode. |
| 131 | * @param deviceId The device id of the context associated with the caller. |
| 132 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 133 | * policy for default device context). Only virtual cameras would be exposed |
| 134 | * only for custom policy and only real cameras would be exposed for default |
| 135 | * policy. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 136 | */ |
| 137 | ICamera connect(ICameraClient client, |
| 138 | int cameraId, |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 139 | @utf8InCpp String opPackageName, |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 140 | int clientUid, int clientPid, |
Austin Borger | 18b30a7 | 2022-10-27 12:20:29 -0700 | [diff] [blame] | 141 | int targetSdkVersion, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 142 | int rotationOverride, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 143 | boolean forceSlowJpegMode, |
| 144 | int deviceId, |
| 145 | int devicePolicy); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 146 | |
| 147 | /** |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 148 | * Open a camera device through the new camera API. |
| 149 | * Only supported for device HAL versions >= 3.2. |
| 150 | * |
| 151 | * @param cameraId The ID of the camera to open. |
| 152 | * @param opPackageName The package name to report for the app-ops. |
| 153 | * @param clientUid UID for the calling client. |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 154 | * @param targetSdkVersion the target sdk level of the application calling this function. |
| 155 | * @param rotationOverride Whether to override the sensor orientation information to |
| 156 | * correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT} |
| 157 | * will override the sensor orientation and rotate and crop, while {@link |
| 158 | * ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed |
| 159 | * without changing the sensor orientation. |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 160 | * @param deviceId The device id of the context associated with the caller. |
| 161 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 162 | * policy for default device context). Only virtual cameras would be exposed |
| 163 | * only for custom policy and only real cameras would be exposed for default |
| 164 | * policy. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 165 | */ |
| 166 | ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks, |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 167 | @utf8InCpp String cameraId, |
| 168 | @utf8InCpp String opPackageName, |
| 169 | @nullable @utf8InCpp String featureId, |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 170 | int clientUid, int oomScoreOffset, |
Austin Borger | 18b30a7 | 2022-10-27 12:20:29 -0700 | [diff] [blame] | 171 | int targetSdkVersion, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 172 | int rotationOverride, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 173 | int deviceId, |
| 174 | int devicePolicy); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 175 | |
| 176 | /** |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 177 | * Add listener for changes to camera device and flashlight state. |
| 178 | * |
| 179 | * Also returns the set of currently-known camera IDs and state of each device. |
| 180 | * Adding a listener will trigger the torch status listener to fire for all |
Emilian Peev | 53722fa | 2019-02-22 17:47:20 -0800 | [diff] [blame] | 181 | * devices that have a flash unit. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 182 | */ |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 183 | CameraStatus[] addListener(ICameraServiceListener listener); |
| 184 | |
| 185 | /** |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 186 | * Get a list of combinations of camera ids which support concurrent streaming. |
| 187 | * |
| 188 | */ |
Jayant Chowdhary | cad23c2 | 2020-03-10 15:04:59 -0700 | [diff] [blame] | 189 | ConcurrentCameraIdCombination[] getConcurrentCameraIds(); |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 190 | |
| 191 | /** |
Biswarup Pal | 7d07286 | 2024-04-17 15:24:47 +0000 | [diff] [blame] | 192 | * Check whether a particular set of session configurations are concurrently supported by the |
| 193 | * corresponding camera ids. |
| 194 | * |
| 195 | * @param sessions the set of camera id and session configuration pairs to be queried. |
| 196 | * @param targetSdkVersion the target sdk level of the application calling this function. |
| 197 | * @param deviceId The device id of the context associated with the caller. |
| 198 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 199 | * policy for default device context). Only virtual cameras would be exposed |
| 200 | * only for custom policy and only real cameras would be exposed for default |
| 201 | * policy. |
| 202 | * @return true - the set of concurrent camera id and stream combinations is supported. |
| 203 | * false - the set of concurrent camera id and stream combinations is not supported |
| 204 | * OR the method was called with a set of camera ids not returned by |
| 205 | * getConcurrentCameraIds(). |
| 206 | */ |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 207 | boolean isConcurrentSessionConfigurationSupported( |
Shuzhen Wang | d4abdf7 | 2021-05-28 11:22:50 -0700 | [diff] [blame] | 208 | in CameraIdAndSessionConfiguration[] sessions, |
Biswarup Pal | 7d07286 | 2024-04-17 15:24:47 +0000 | [diff] [blame] | 209 | int targetSdkVersion, int deviceId, int devicePolicy); |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 210 | |
| 211 | /** |
malikakash | 22af94c | 2023-12-04 18:13:14 +0000 | [diff] [blame] | 212 | * Inject Session Params into an existing camera session. |
| 213 | * |
| 214 | * @param cameraId the camera id session to inject session params into. Note that |
| 215 | * if there is no active session for the input cameraid, this operation |
| 216 | * will be a no-op. In addition, future camera sessions for cameraid will |
| 217 | * not be affected. |
| 218 | * @param sessionParams the session params to override for the existing session. |
| 219 | */ |
| 220 | void injectSessionParams(@utf8InCpp String cameraId, |
| 221 | in CameraMetadataNative sessionParams); |
| 222 | |
| 223 | /** |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 224 | * Remove listener for changes to camera device and flashlight state. |
| 225 | */ |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 226 | void removeListener(ICameraServiceListener listener); |
| 227 | |
| 228 | /** |
| 229 | * Read the static camera metadata for a camera device. |
| 230 | * Only supported for device HAL versions >= 3.2 |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 231 | * |
| 232 | * @param cameraId The ID of the camera to fetch metadata for. |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 233 | * @param targetSdkVersion the target sdk level of the application calling this function. |
| 234 | * @param rotationOverride Whether to override the sensor orientation information to |
| 235 | * correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT} |
| 236 | * will override the sensor orientation and rotate and crop, while {@link |
| 237 | * ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed |
| 238 | * without changing the sensor orientation. |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 239 | * @param deviceId The device id of the context associated with the caller. |
| 240 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 241 | * policy for default device context). Only virtual cameras would be exposed |
| 242 | * only for custom policy and only real cameras would be exposed for default |
| 243 | * policy. |
| 244 | * @return Characteristics for the given camera. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 245 | */ |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 246 | CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 247 | int rotationOverride, int deviceId, int devicePolicy); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 248 | |
| 249 | /** |
| 250 | * Read in the vendor tag descriptors from the camera module HAL. |
| 251 | * Intended to be used by the native code of CameraMetadataNative to correctly |
| 252 | * interpret camera metadata with vendor tags. |
| 253 | */ |
| 254 | VendorTagDescriptor getCameraVendorTagDescriptor(); |
| 255 | |
| 256 | /** |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 257 | * Retrieve the vendor tag descriptor cache which can have multiple vendor |
| 258 | * providers. |
| 259 | * Intended to be used by the native code of CameraMetadataNative to correctly |
| 260 | * interpret camera metadata with vendor tags. |
| 261 | */ |
| 262 | VendorTagDescriptorCache getCameraVendorTagCache(); |
| 263 | |
| 264 | /** |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 265 | * Read the legacy camera1 parameters into a String |
| 266 | */ |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 267 | @utf8InCpp String getLegacyParameters(int cameraId); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 268 | |
| 269 | /** |
| 270 | * apiVersion constants for supportsCameraApi |
| 271 | */ |
| 272 | const int API_VERSION_1 = 1; |
| 273 | const int API_VERSION_2 = 2; |
| 274 | |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 275 | // Determines if a particular API version is supported directly for a cameraId. |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 276 | boolean supportsCameraApi(@utf8InCpp String cameraId, int apiVersion); |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 277 | // Determines if a cameraId is a hidden physical camera of a logical multi-camera. |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 278 | boolean isHiddenPhysicalCamera(@utf8InCpp String cameraId); |
Cliff Wu | d8cae10 | 2021-03-11 01:37:42 +0800 | [diff] [blame] | 279 | // Inject the external camera to replace the internal camera session. |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 280 | ICameraInjectionSession injectCamera(@utf8InCpp String packageName, @utf8InCpp String internalCamId, |
| 281 | @utf8InCpp String externalCamId, in ICameraInjectionCallback CameraInjectionCallback); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 282 | |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 283 | /** |
| 284 | * Set the torch mode for a camera device. |
| 285 | * |
| 286 | * @param cameraId The ID of the camera to set torch mode for. |
| 287 | * @param deviceId The device id of the context associated with the caller. |
| 288 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 289 | * policy for default device context). Only virtual cameras would be exposed |
| 290 | * only for custom policy and only real cameras would be exposed for default |
| 291 | * policy. |
| 292 | */ |
| 293 | void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder, |
| 294 | int deviceId, int devicePolicy); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 295 | |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 296 | /** |
| 297 | * Change the brightness level of the flash unit associated with cameraId to strengthLevel. |
| 298 | * If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON. |
| 299 | * |
| 300 | * @param cameraId The ID of the camera. |
| 301 | * @param strengthLevel The torch strength level to set for the camera. |
| 302 | * @param deviceId The device id of the context associated with the caller. |
| 303 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 304 | * policy for default device context). Only virtual cameras would be exposed |
| 305 | * only for custom policy and only real cameras would be exposed for default |
| 306 | * policy. |
| 307 | */ |
| 308 | void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, |
| 309 | IBinder clientBinder, int deviceId, int devicePolicy); |
Rucha Katakwar | 3828452 | 2021-11-10 11:25:21 -0800 | [diff] [blame] | 310 | |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 311 | /** |
| 312 | * Get the brightness level of the flash unit associated with cameraId. |
| 313 | * |
| 314 | * @param cameraId The ID of the camera. |
| 315 | * @param deviceId The device id of the context associated with the caller. |
| 316 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 317 | * policy for default device context). Only virtual cameras would be exposed |
| 318 | * only for custom policy and only real cameras would be exposed for default |
| 319 | * policy. |
| 320 | * @return Torch strength level for the camera. |
| 321 | */ |
| 322 | int getTorchStrengthLevel(@utf8InCpp String cameraId, int deviceId, int devicePolicy); |
Rucha Katakwar | 3828452 | 2021-11-10 11:25:21 -0800 | [diff] [blame] | 323 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 324 | /** |
| 325 | * Notify the camera service of a system event. Should only be called from system_server. |
| 326 | * |
| 327 | * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. |
| 328 | */ |
| 329 | const int EVENT_NONE = 0; |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 330 | const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs. |
Valentin Iftime | 29e2e15 | 2021-08-13 15:17:33 +0200 | [diff] [blame] | 331 | const int EVENT_USB_DEVICE_ATTACHED = 2; // The argument is the deviceId and vendorId |
| 332 | const int EVENT_USB_DEVICE_DETACHED = 3; // The argument is the deviceId and vendorId |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 333 | oneway void notifySystemEvent(int eventId, in int[] args); |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 334 | |
| 335 | /** |
Emilian Peev | 8b64f28 | 2021-03-25 16:49:57 -0700 | [diff] [blame] | 336 | * Notify the camera service of a display configuration change. |
| 337 | * |
| 338 | * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. |
| 339 | */ |
| 340 | oneway void notifyDisplayConfigurationChange(); |
| 341 | |
| 342 | /** |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 343 | * Notify the camera service of a device physical status change. May only be called from |
| 344 | * a privileged process. |
| 345 | * |
| 346 | * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state |
| 347 | * combinations are device-specific. At device startup, the camera service will assume the device |
| 348 | * state is NORMAL until otherwise notified. |
| 349 | * |
| 350 | * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. |
| 351 | */ |
| 352 | oneway void notifyDeviceStateChange(long newState); |
| 353 | |
Avichal Rakesh | 6e57a2b | 2023-05-01 17:53:37 -0700 | [diff] [blame] | 354 | /** |
| 355 | * Report Extension specific metrics to camera service for logging. This should only be called |
| 356 | * by CameraExtensionSession to log extension metrics. All calls after the first must set |
| 357 | * CameraExtensionSessionStats.key to the value returned by this function. |
| 358 | * |
| 359 | * Each subsequent call fully overwrites the existing CameraExtensionSessionStats for the |
| 360 | * current session, so the caller is responsible for keeping the stats complete. |
| 361 | * |
| 362 | * Due to cameraservice and cameraservice_proxy architecture, there is no guarantee that |
| 363 | * {@code stats} will be logged immediately (or at all). CameraService will log whatever |
| 364 | * extension stats it has at the time of camera session closing which may be before the app |
| 365 | * process receives a session/device closed callback; so CameraExtensionSession |
| 366 | * should send metrics to the cameraservice preriodically, and cameraservice must handle calls |
| 367 | * to this function from sessions that have not been logged yet and from sessions that have |
| 368 | * already been closed. |
| 369 | * |
| 370 | * @return the key that must be used to report updates to previously reported stats. |
| 371 | */ |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 372 | @utf8InCpp String reportExtensionSessionStats(in CameraExtensionSessionStats stats); |
Avichal Rakesh | 6e57a2b | 2023-05-01 17:53:37 -0700 | [diff] [blame] | 373 | |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 374 | // Bitfield constants for notifyDeviceStateChange |
| 375 | // All bits >= 32 are for custom vendor states |
| 376 | // Written as ints since AIDL does not support long constants. |
| 377 | const int DEVICE_STATE_NORMAL = 0; |
| 378 | const int DEVICE_STATE_BACK_COVERED = 1; |
| 379 | const int DEVICE_STATE_FRONT_COVERED = 2; |
| 380 | const int DEVICE_STATE_FOLDED = 4; |
| 381 | const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31; |
| 382 | |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 383 | /** |
| 384 | * Create a CaptureRequest metadata based on template id |
| 385 | * |
| 386 | * @param cameraId The camera id to create the CaptureRequest for. |
| 387 | * @param templateId The template id create the CaptureRequest for. |
| 388 | * @param deviceId the device id of the context associated with the caller. |
| 389 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 390 | * policy for default device context). Only virtual cameras would be exposed |
| 391 | * only for custom policy and only real cameras would be exposed for default |
| 392 | * policy. |
| 393 | * @return Metadata representing the CaptureRequest. |
| 394 | */ |
| 395 | CameraMetadataNative createDefaultRequest(@utf8InCpp String cameraId, int templateId, |
| 396 | int deviceId, int devicePolicy); |
Shuzhen Wang | 045be6c | 2023-10-12 10:01:10 -0700 | [diff] [blame] | 397 | |
| 398 | /** |
Avichal Rakesh | 3c522e2 | 2024-02-07 16:40:46 -0800 | [diff] [blame] | 399 | * Check whether a particular session configuration with optional session parameters |
| 400 | * has camera device support. |
| 401 | * |
| 402 | * @param cameraId The camera id to query session configuration for |
Avichal Rakesh | caf179b | 2024-04-04 18:42:46 -0700 | [diff] [blame] | 403 | * @param targetSdkVersion the target sdk level of the application calling this function. |
Avichal Rakesh | 3c522e2 | 2024-02-07 16:40:46 -0800 | [diff] [blame] | 404 | * @param sessionConfiguration Specific session configuration to be verified. |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 405 | * @param deviceId The device id of the context associated with the caller. |
| 406 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 407 | * policy for default device context). Only virtual cameras would be exposed |
| 408 | * only for custom policy and only real cameras would be exposed for default |
| 409 | * policy. |
Avichal Rakesh | 3c522e2 | 2024-02-07 16:40:46 -0800 | [diff] [blame] | 410 | * @return true - in case the stream combination is supported. |
| 411 | * false - in case there is no device support. |
| 412 | */ |
Shuzhen Wang | 045be6c | 2023-10-12 10:01:10 -0700 | [diff] [blame] | 413 | boolean isSessionConfigurationWithParametersSupported(@utf8InCpp String cameraId, |
Avichal Rakesh | caf179b | 2024-04-04 18:42:46 -0700 | [diff] [blame] | 414 | int targetSdkVersion, in SessionConfiguration sessionConfiguration, |
| 415 | int deviceId, int devicePolicy); |
Avichal Rakesh | 3c522e2 | 2024-02-07 16:40:46 -0800 | [diff] [blame] | 416 | |
| 417 | /** |
| 418 | * Get the camera characteristics for a particular session configuration for |
| 419 | * the given camera device. |
| 420 | * |
| 421 | * @param cameraId ID of the device for which the session characteristics must be fetched. |
Avichal Rakesh | caf179b | 2024-04-04 18:42:46 -0700 | [diff] [blame] | 422 | * @param targetSdkVersion the target sdk level of the application calling this function. |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 423 | * @param rotationOverride Whether to override the sensor orientation information to |
| 424 | * correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT} |
| 425 | * will override the sensor orientation and rotate and crop, while {@link |
| 426 | * ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed |
| 427 | * without changing the sensor orientation. |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 428 | * @param sessionConfiguration Session configuration for which the characteristics |
Avichal Rakesh | caf179b | 2024-04-04 18:42:46 -0700 | [diff] [blame] | 429 | * must be fetched. |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 430 | * @param deviceId The device id of the context associated with the caller. |
| 431 | * @param devicePolicy The camera policy of the device of the associated context (default |
| 432 | * policy for default device context). Only virtual cameras would be exposed |
| 433 | * only for custom policy and only real cameras would be exposed for default |
| 434 | * policy. |
| 435 | * @return Characteristics associated with the given session. |
Avichal Rakesh | 3c522e2 | 2024-02-07 16:40:46 -0800 | [diff] [blame] | 436 | */ |
| 437 | CameraMetadataNative getSessionCharacteristics(@utf8InCpp String cameraId, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 438 | int targetSdkVersion, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 439 | int rotationOverride, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 440 | in SessionConfiguration sessionConfiguration, |
| 441 | int deviceId, |
| 442 | int devicePolicy); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 443 | } |