blob: 0eeeb7f4b8343d993b36cc6d4b5dddc074916d2d [file] [log] [blame]
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -08001/*
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
17package android.hardware;
18
19import android.hardware.ICamera;
20import android.hardware.ICameraClient;
21import android.hardware.camera2.ICameraDeviceUser;
22import android.hardware.camera2.ICameraDeviceCallbacks;
Cliff Wud8cae102021-03-11 01:37:42 +080023import android.hardware.camera2.ICameraInjectionCallback;
24import android.hardware.camera2.ICameraInjectionSession;
Shuzhen Wang045be6c2023-10-12 10:01:10 -070025import android.hardware.camera2.params.SessionConfiguration;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080026import android.hardware.camera2.params.VendorTagDescriptor;
Emilian Peev71c73a22017-03-21 16:35:51 +000027import android.hardware.camera2.params.VendorTagDescriptorCache;
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -080028import android.hardware.camera2.utils.ConcurrentCameraIdCombination;
29import android.hardware.camera2.utils.CameraIdAndSessionConfiguration;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080030import android.hardware.camera2.impl.CameraMetadataNative;
31import android.hardware.ICameraServiceListener;
32import android.hardware.CameraInfo;
malikakash73125c62023-07-21 22:44:34 +000033import android.hardware.CameraIdRemapping;
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080034import android.hardware.CameraStatus;
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -070035import android.hardware.CameraExtensionSessionStats;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080036
37/**
38 * Binder interface for the native camera service running in mediaserver.
39 *
40 * @hide
41 */
42interface ICameraService
43{
44 /**
45 * All camera service and device Binder calls may return a
46 * ServiceSpecificException with the following error codes
47 */
48 const int ERROR_PERMISSION_DENIED = 1;
49 const int ERROR_ALREADY_EXISTS = 2;
50 const int ERROR_ILLEGAL_ARGUMENT = 3;
51 const int ERROR_DISCONNECTED = 4;
52 const int ERROR_TIMED_OUT = 5;
53 const int ERROR_DISABLED = 6;
54 const int ERROR_CAMERA_IN_USE = 7;
55 const int ERROR_MAX_CAMERAS_IN_USE = 8;
56 const int ERROR_DEPRECATED_HAL = 9;
57 const int ERROR_INVALID_OPERATION = 10;
58
59 /**
60 * Types for getNumberOfCameras
61 */
62 const int CAMERA_TYPE_BACKWARD_COMPATIBLE = 0;
63 const int CAMERA_TYPE_ALL = 1;
64
65 /**
66 * Return the number of camera devices available in the system
67 */
68 int getNumberOfCameras(int type);
69
70 /**
71 * Fetch basic camera information for a camera device
72 */
Austin Borger18b30a72022-10-27 12:20:29 -070073 CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080074
75 /**
76 * Default UID/PID values for non-privileged callers of
Eino-Ville Talvalaa976df82019-06-13 18:01:58 -070077 * connect() and connectDevice()
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080078 */
79 const int USE_CALLING_UID = -1;
80 const int USE_CALLING_PID = -1;
81
82 /**
83 * Open a camera device through the old camera API
84 */
85 ICamera connect(ICameraClient client,
86 int cameraId,
Austin Borger1c1bee02023-06-01 16:51:35 -070087 @utf8InCpp String opPackageName,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070088 int clientUid, int clientPid,
Austin Borger18b30a72022-10-27 12:20:29 -070089 int targetSdkVersion,
Chengfei Taobe683db2023-01-31 18:52:49 +000090 boolean overrideToPortrait,
91 boolean forceSlowJpegMode);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080092
93 /**
94 * Open a camera device through the new camera API
95 * Only supported for device HAL versions >= 3.2
96 */
97 ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
Austin Borger1c1bee02023-06-01 16:51:35 -070098 @utf8InCpp String cameraId,
99 @utf8InCpp String opPackageName,
100 @nullable @utf8InCpp String featureId,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700101 int clientUid, int oomScoreOffset,
Austin Borger18b30a72022-10-27 12:20:29 -0700102 int targetSdkVersion,
103 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800104
105 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800106 * Add listener for changes to camera device and flashlight state.
107 *
108 * Also returns the set of currently-known camera IDs and state of each device.
109 * Adding a listener will trigger the torch status listener to fire for all
Emilian Peev53722fa2019-02-22 17:47:20 -0800110 * devices that have a flash unit.
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800111 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800112 CameraStatus[] addListener(ICameraServiceListener listener);
113
114 /**
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800115 * Get a list of combinations of camera ids which support concurrent streaming.
116 *
117 */
Jayant Chowdharycad23c22020-03-10 15:04:59 -0700118 ConcurrentCameraIdCombination[] getConcurrentCameraIds();
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800119
120 /**
121 * Check whether a particular set of session configurations are concurrently supported by the
122 * corresponding camera ids.
123 *
124 * @param sessions the set of camera id and session configuration pairs to be queried.
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700125 * @param targetSdkVersion the target sdk level of the application calling this function.
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800126 * @return true - the set of concurrent camera id and stream combinations is supported.
127 * false - the set of concurrent camera id and stream combinations is not supported
128 * OR the method was called with a set of camera ids not returned by
Jayant Chowdharycad23c22020-03-10 15:04:59 -0700129 * getConcurrentCameraIds().
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800130 */
131 boolean isConcurrentSessionConfigurationSupported(
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700132 in CameraIdAndSessionConfiguration[] sessions,
133 int targetSdkVersion);
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800134
135 /**
malikakash73125c62023-07-21 22:44:34 +0000136 * Remap Camera Ids in the CameraService.
137 *
138 * Once this is in effect, all binder calls in the ICameraService that
139 * use logicalCameraId should consult remapping state to arrive at the
140 * correct cameraId to perform the operation on.
141 *
142 * Note: Before the new cameraIdRemapping state is applied, the previous
143 * state is cleared.
144 *
145 * @param cameraIdRemapping the camera ids to remap. Sending an unpopulated
146 * cameraIdRemapping object will result in clearing of any previous
147 * cameraIdRemapping state in the camera service.
148 */
149 void remapCameraIds(in CameraIdRemapping cameraIdRemapping);
150
151 /**
malikakash22af94c2023-12-04 18:13:14 +0000152 * Inject Session Params into an existing camera session.
153 *
154 * @param cameraId the camera id session to inject session params into. Note that
155 * if there is no active session for the input cameraid, this operation
156 * will be a no-op. In addition, future camera sessions for cameraid will
157 * not be affected.
158 * @param sessionParams the session params to override for the existing session.
159 */
160 void injectSessionParams(@utf8InCpp String cameraId,
161 in CameraMetadataNative sessionParams);
162
163 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800164 * Remove listener for changes to camera device and flashlight state.
165 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800166 void removeListener(ICameraServiceListener listener);
167
168 /**
169 * Read the static camera metadata for a camera device.
170 * Only supported for device HAL versions >= 3.2
171 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700172 CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion,
Austin Borger18b30a72022-10-27 12:20:29 -0700173 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800174
175 /**
176 * Read in the vendor tag descriptors from the camera module HAL.
177 * Intended to be used by the native code of CameraMetadataNative to correctly
178 * interpret camera metadata with vendor tags.
179 */
180 VendorTagDescriptor getCameraVendorTagDescriptor();
181
182 /**
Emilian Peev71c73a22017-03-21 16:35:51 +0000183 * Retrieve the vendor tag descriptor cache which can have multiple vendor
184 * providers.
185 * Intended to be used by the native code of CameraMetadataNative to correctly
186 * interpret camera metadata with vendor tags.
187 */
188 VendorTagDescriptorCache getCameraVendorTagCache();
189
190 /**
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800191 * Read the legacy camera1 parameters into a String
192 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700193 @utf8InCpp String getLegacyParameters(int cameraId);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800194
195 /**
196 * apiVersion constants for supportsCameraApi
197 */
198 const int API_VERSION_1 = 1;
199 const int API_VERSION_2 = 2;
200
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700201 // Determines if a particular API version is supported directly for a cameraId.
Austin Borger1c1bee02023-06-01 16:51:35 -0700202 boolean supportsCameraApi(@utf8InCpp String cameraId, int apiVersion);
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700203 // Determines if a cameraId is a hidden physical camera of a logical multi-camera.
Austin Borger1c1bee02023-06-01 16:51:35 -0700204 boolean isHiddenPhysicalCamera(@utf8InCpp String cameraId);
Cliff Wud8cae102021-03-11 01:37:42 +0800205 // Inject the external camera to replace the internal camera session.
Austin Borger1c1bee02023-06-01 16:51:35 -0700206 ICameraInjectionSession injectCamera(@utf8InCpp String packageName, @utf8InCpp String internalCamId,
207 @utf8InCpp String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800208
Austin Borger1c1bee02023-06-01 16:51:35 -0700209 void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800210
Rucha Katakwar38284522021-11-10 11:25:21 -0800211 // Change the brightness level of the flash unit associated with cameraId to strengthLevel.
212 // If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON.
Austin Borger1c1bee02023-06-01 16:51:35 -0700213 void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder);
Rucha Katakwar38284522021-11-10 11:25:21 -0800214
215 // Get the brightness level of the flash unit associated with cameraId.
Austin Borger1c1bee02023-06-01 16:51:35 -0700216 int getTorchStrengthLevel(@utf8InCpp String cameraId);
Rucha Katakwar38284522021-11-10 11:25:21 -0800217
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800218 /**
219 * Notify the camera service of a system event. Should only be called from system_server.
220 *
221 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
222 */
223 const int EVENT_NONE = 0;
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800224 const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs.
Valentin Iftime29e2e152021-08-13 15:17:33 +0200225 const int EVENT_USB_DEVICE_ATTACHED = 2; // The argument is the deviceId and vendorId
226 const int EVENT_USB_DEVICE_DETACHED = 3; // The argument is the deviceId and vendorId
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800227 oneway void notifySystemEvent(int eventId, in int[] args);
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800228
229 /**
Emilian Peev8b64f282021-03-25 16:49:57 -0700230 * Notify the camera service of a display configuration change.
231 *
232 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
233 */
234 oneway void notifyDisplayConfigurationChange();
235
236 /**
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800237 * Notify the camera service of a device physical status change. May only be called from
238 * a privileged process.
239 *
240 * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state
241 * combinations are device-specific. At device startup, the camera service will assume the device
242 * state is NORMAL until otherwise notified.
243 *
244 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
245 */
246 oneway void notifyDeviceStateChange(long newState);
247
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -0700248 /**
249 * Report Extension specific metrics to camera service for logging. This should only be called
250 * by CameraExtensionSession to log extension metrics. All calls after the first must set
251 * CameraExtensionSessionStats.key to the value returned by this function.
252 *
253 * Each subsequent call fully overwrites the existing CameraExtensionSessionStats for the
254 * current session, so the caller is responsible for keeping the stats complete.
255 *
256 * Due to cameraservice and cameraservice_proxy architecture, there is no guarantee that
257 * {@code stats} will be logged immediately (or at all). CameraService will log whatever
258 * extension stats it has at the time of camera session closing which may be before the app
259 * process receives a session/device closed callback; so CameraExtensionSession
260 * should send metrics to the cameraservice preriodically, and cameraservice must handle calls
261 * to this function from sessions that have not been logged yet and from sessions that have
262 * already been closed.
263 *
264 * @return the key that must be used to report updates to previously reported stats.
265 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700266 @utf8InCpp String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -0700267
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800268 // Bitfield constants for notifyDeviceStateChange
269 // All bits >= 32 are for custom vendor states
270 // Written as ints since AIDL does not support long constants.
271 const int DEVICE_STATE_NORMAL = 0;
272 const int DEVICE_STATE_BACK_COVERED = 1;
273 const int DEVICE_STATE_FRONT_COVERED = 2;
274 const int DEVICE_STATE_FOLDED = 4;
275 const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31;
276
Shuzhen Wang045be6c2023-10-12 10:01:10 -0700277 // Create a CaptureRequest metadata based on template id
278 CameraMetadataNative createDefaultRequest(@utf8InCpp String cameraId, int templateId);
279
280 /**
281 * Check whether a particular session configuration with optional session parameters
282 * has camera device support.
283 *
284 * @param cameraId The camera id to query session configuration on
285 * @param sessionConfiguration Specific session configuration to be verified.
286 * @return true - in case the stream combination is supported.
287 * false - in case there is no device support.
288 */
289 boolean isSessionConfigurationWithParametersSupported(@utf8InCpp String cameraId,
290 in SessionConfiguration sessionConfiguration);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800291}