blob: 8078ceafc516ba8872c24140255ecb191346b551 [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 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800152 * Remove listener for changes to camera device and flashlight state.
153 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800154 void removeListener(ICameraServiceListener listener);
155
156 /**
157 * Read the static camera metadata for a camera device.
158 * Only supported for device HAL versions >= 3.2
159 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700160 CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion,
Austin Borger18b30a72022-10-27 12:20:29 -0700161 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800162
163 /**
164 * Read in the vendor tag descriptors from the camera module HAL.
165 * Intended to be used by the native code of CameraMetadataNative to correctly
166 * interpret camera metadata with vendor tags.
167 */
168 VendorTagDescriptor getCameraVendorTagDescriptor();
169
170 /**
Emilian Peev71c73a22017-03-21 16:35:51 +0000171 * Retrieve the vendor tag descriptor cache which can have multiple vendor
172 * providers.
173 * Intended to be used by the native code of CameraMetadataNative to correctly
174 * interpret camera metadata with vendor tags.
175 */
176 VendorTagDescriptorCache getCameraVendorTagCache();
177
178 /**
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800179 * Read the legacy camera1 parameters into a String
180 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700181 @utf8InCpp String getLegacyParameters(int cameraId);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800182
183 /**
184 * apiVersion constants for supportsCameraApi
185 */
186 const int API_VERSION_1 = 1;
187 const int API_VERSION_2 = 2;
188
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700189 // Determines if a particular API version is supported directly for a cameraId.
Austin Borger1c1bee02023-06-01 16:51:35 -0700190 boolean supportsCameraApi(@utf8InCpp String cameraId, int apiVersion);
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700191 // Determines if a cameraId is a hidden physical camera of a logical multi-camera.
Austin Borger1c1bee02023-06-01 16:51:35 -0700192 boolean isHiddenPhysicalCamera(@utf8InCpp String cameraId);
Cliff Wud8cae102021-03-11 01:37:42 +0800193 // Inject the external camera to replace the internal camera session.
Austin Borger1c1bee02023-06-01 16:51:35 -0700194 ICameraInjectionSession injectCamera(@utf8InCpp String packageName, @utf8InCpp String internalCamId,
195 @utf8InCpp String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800196
Austin Borger1c1bee02023-06-01 16:51:35 -0700197 void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800198
Rucha Katakwar38284522021-11-10 11:25:21 -0800199 // Change the brightness level of the flash unit associated with cameraId to strengthLevel.
200 // 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 -0700201 void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder);
Rucha Katakwar38284522021-11-10 11:25:21 -0800202
203 // Get the brightness level of the flash unit associated with cameraId.
Austin Borger1c1bee02023-06-01 16:51:35 -0700204 int getTorchStrengthLevel(@utf8InCpp String cameraId);
Rucha Katakwar38284522021-11-10 11:25:21 -0800205
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800206 /**
207 * Notify the camera service of a system event. Should only be called from system_server.
208 *
209 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
210 */
211 const int EVENT_NONE = 0;
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800212 const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs.
Valentin Iftime29e2e152021-08-13 15:17:33 +0200213 const int EVENT_USB_DEVICE_ATTACHED = 2; // The argument is the deviceId and vendorId
214 const int EVENT_USB_DEVICE_DETACHED = 3; // The argument is the deviceId and vendorId
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800215 oneway void notifySystemEvent(int eventId, in int[] args);
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800216
217 /**
Emilian Peev8b64f282021-03-25 16:49:57 -0700218 * Notify the camera service of a display configuration change.
219 *
220 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
221 */
222 oneway void notifyDisplayConfigurationChange();
223
224 /**
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800225 * Notify the camera service of a device physical status change. May only be called from
226 * a privileged process.
227 *
228 * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state
229 * combinations are device-specific. At device startup, the camera service will assume the device
230 * state is NORMAL until otherwise notified.
231 *
232 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
233 */
234 oneway void notifyDeviceStateChange(long newState);
235
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -0700236 /**
237 * Report Extension specific metrics to camera service for logging. This should only be called
238 * by CameraExtensionSession to log extension metrics. All calls after the first must set
239 * CameraExtensionSessionStats.key to the value returned by this function.
240 *
241 * Each subsequent call fully overwrites the existing CameraExtensionSessionStats for the
242 * current session, so the caller is responsible for keeping the stats complete.
243 *
244 * Due to cameraservice and cameraservice_proxy architecture, there is no guarantee that
245 * {@code stats} will be logged immediately (or at all). CameraService will log whatever
246 * extension stats it has at the time of camera session closing which may be before the app
247 * process receives a session/device closed callback; so CameraExtensionSession
248 * should send metrics to the cameraservice preriodically, and cameraservice must handle calls
249 * to this function from sessions that have not been logged yet and from sessions that have
250 * already been closed.
251 *
252 * @return the key that must be used to report updates to previously reported stats.
253 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700254 @utf8InCpp String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -0700255
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800256 // Bitfield constants for notifyDeviceStateChange
257 // All bits >= 32 are for custom vendor states
258 // Written as ints since AIDL does not support long constants.
259 const int DEVICE_STATE_NORMAL = 0;
260 const int DEVICE_STATE_BACK_COVERED = 1;
261 const int DEVICE_STATE_FRONT_COVERED = 2;
262 const int DEVICE_STATE_FOLDED = 4;
263 const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31;
264
Shuzhen Wang045be6c2023-10-12 10:01:10 -0700265 // Create a CaptureRequest metadata based on template id
266 CameraMetadataNative createDefaultRequest(@utf8InCpp String cameraId, int templateId);
267
268 /**
269 * Check whether a particular session configuration with optional session parameters
270 * has camera device support.
271 *
272 * @param cameraId The camera id to query session configuration on
273 * @param sessionConfiguration Specific session configuration to be verified.
274 * @return true - in case the stream combination is supported.
275 * false - in case there is no device support.
276 */
277 boolean isSessionConfigurationWithParametersSupported(@utf8InCpp String cameraId,
278 in SessionConfiguration sessionConfiguration);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800279}