blob: 409a93079b85df9cc353d8277e7ff89bd1c1a51f [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;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080025import android.hardware.camera2.params.VendorTagDescriptor;
Emilian Peev71c73a22017-03-21 16:35:51 +000026import android.hardware.camera2.params.VendorTagDescriptorCache;
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -080027import android.hardware.camera2.utils.ConcurrentCameraIdCombination;
28import android.hardware.camera2.utils.CameraIdAndSessionConfiguration;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080029import android.hardware.camera2.impl.CameraMetadataNative;
30import android.hardware.ICameraServiceListener;
31import android.hardware.CameraInfo;
malikakash73125c62023-07-21 22:44:34 +000032import android.hardware.CameraIdRemapping;
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080033import android.hardware.CameraStatus;
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -070034import android.hardware.CameraExtensionSessionStats;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080035
36/**
37 * Binder interface for the native camera service running in mediaserver.
38 *
39 * @hide
40 */
41interface 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 /**
65 * Return the number of camera devices available in the system
66 */
67 int getNumberOfCameras(int type);
68
69 /**
70 * Fetch basic camera information for a camera device
71 */
Austin Borger18b30a72022-10-27 12:20:29 -070072 CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080073
74 /**
75 * Default UID/PID values for non-privileged callers of
Eino-Ville Talvalaa976df82019-06-13 18:01:58 -070076 * connect() and connectDevice()
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080077 */
78 const int USE_CALLING_UID = -1;
79 const int USE_CALLING_PID = -1;
80
81 /**
82 * Open a camera device through the old camera API
83 */
84 ICamera connect(ICameraClient client,
85 int cameraId,
Austin Borger1c1bee02023-06-01 16:51:35 -070086 @utf8InCpp String opPackageName,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070087 int clientUid, int clientPid,
Austin Borger18b30a72022-10-27 12:20:29 -070088 int targetSdkVersion,
Chengfei Taobe683db2023-01-31 18:52:49 +000089 boolean overrideToPortrait,
90 boolean forceSlowJpegMode);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080091
92 /**
93 * Open a camera device through the new camera API
94 * Only supported for device HAL versions >= 3.2
95 */
96 ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
Austin Borger1c1bee02023-06-01 16:51:35 -070097 @utf8InCpp String cameraId,
98 @utf8InCpp String opPackageName,
99 @nullable @utf8InCpp String featureId,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700100 int clientUid, int oomScoreOffset,
Austin Borger18b30a72022-10-27 12:20:29 -0700101 int targetSdkVersion,
102 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800103
104 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800105 * Add listener for changes to camera device and flashlight state.
106 *
107 * Also returns the set of currently-known camera IDs and state of each device.
108 * Adding a listener will trigger the torch status listener to fire for all
Emilian Peev53722fa2019-02-22 17:47:20 -0800109 * devices that have a flash unit.
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800110 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800111 CameraStatus[] addListener(ICameraServiceListener listener);
112
113 /**
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800114 * Get a list of combinations of camera ids which support concurrent streaming.
115 *
116 */
Jayant Chowdharycad23c22020-03-10 15:04:59 -0700117 ConcurrentCameraIdCombination[] getConcurrentCameraIds();
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800118
119 /**
120 * Check whether a particular set of session configurations are concurrently supported by the
121 * corresponding camera ids.
122 *
123 * @param sessions the set of camera id and session configuration pairs to be queried.
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700124 * @param targetSdkVersion the target sdk level of the application calling this function.
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800125 * @return true - the set of concurrent camera id and stream combinations is supported.
126 * false - the set of concurrent camera id and stream combinations is not supported
127 * OR the method was called with a set of camera ids not returned by
Jayant Chowdharycad23c22020-03-10 15:04:59 -0700128 * getConcurrentCameraIds().
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800129 */
130 boolean isConcurrentSessionConfigurationSupported(
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700131 in CameraIdAndSessionConfiguration[] sessions,
132 int targetSdkVersion);
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800133
134 /**
malikakash73125c62023-07-21 22:44:34 +0000135 * Remap Camera Ids in the CameraService.
136 *
137 * Once this is in effect, all binder calls in the ICameraService that
138 * use logicalCameraId should consult remapping state to arrive at the
139 * correct cameraId to perform the operation on.
140 *
141 * Note: Before the new cameraIdRemapping state is applied, the previous
142 * state is cleared.
143 *
144 * @param cameraIdRemapping the camera ids to remap. Sending an unpopulated
145 * cameraIdRemapping object will result in clearing of any previous
146 * cameraIdRemapping state in the camera service.
147 */
148 void remapCameraIds(in CameraIdRemapping cameraIdRemapping);
149
150 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800151 * Remove listener for changes to camera device and flashlight state.
152 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800153 void removeListener(ICameraServiceListener listener);
154
155 /**
156 * Read the static camera metadata for a camera device.
157 * Only supported for device HAL versions >= 3.2
158 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700159 CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion,
Austin Borger18b30a72022-10-27 12:20:29 -0700160 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800161
162 /**
163 * Read in the vendor tag descriptors from the camera module HAL.
164 * Intended to be used by the native code of CameraMetadataNative to correctly
165 * interpret camera metadata with vendor tags.
166 */
167 VendorTagDescriptor getCameraVendorTagDescriptor();
168
169 /**
Emilian Peev71c73a22017-03-21 16:35:51 +0000170 * Retrieve the vendor tag descriptor cache which can have multiple vendor
171 * providers.
172 * Intended to be used by the native code of CameraMetadataNative to correctly
173 * interpret camera metadata with vendor tags.
174 */
175 VendorTagDescriptorCache getCameraVendorTagCache();
176
177 /**
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800178 * Read the legacy camera1 parameters into a String
179 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700180 @utf8InCpp String getLegacyParameters(int cameraId);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800181
182 /**
183 * apiVersion constants for supportsCameraApi
184 */
185 const int API_VERSION_1 = 1;
186 const int API_VERSION_2 = 2;
187
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700188 // Determines if a particular API version is supported directly for a cameraId.
Austin Borger1c1bee02023-06-01 16:51:35 -0700189 boolean supportsCameraApi(@utf8InCpp String cameraId, int apiVersion);
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700190 // Determines if a cameraId is a hidden physical camera of a logical multi-camera.
Austin Borger1c1bee02023-06-01 16:51:35 -0700191 boolean isHiddenPhysicalCamera(@utf8InCpp String cameraId);
Cliff Wud8cae102021-03-11 01:37:42 +0800192 // Inject the external camera to replace the internal camera session.
Austin Borger1c1bee02023-06-01 16:51:35 -0700193 ICameraInjectionSession injectCamera(@utf8InCpp String packageName, @utf8InCpp String internalCamId,
194 @utf8InCpp String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800195
Austin Borger1c1bee02023-06-01 16:51:35 -0700196 void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800197
Rucha Katakwar38284522021-11-10 11:25:21 -0800198 // Change the brightness level of the flash unit associated with cameraId to strengthLevel.
199 // 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 -0700200 void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder);
Rucha Katakwar38284522021-11-10 11:25:21 -0800201
202 // Get the brightness level of the flash unit associated with cameraId.
Austin Borger1c1bee02023-06-01 16:51:35 -0700203 int getTorchStrengthLevel(@utf8InCpp String cameraId);
Rucha Katakwar38284522021-11-10 11:25:21 -0800204
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800205 /**
206 * Notify the camera service of a system event. Should only be called from system_server.
207 *
208 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
209 */
210 const int EVENT_NONE = 0;
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800211 const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs.
Valentin Iftime29e2e152021-08-13 15:17:33 +0200212 const int EVENT_USB_DEVICE_ATTACHED = 2; // The argument is the deviceId and vendorId
213 const int EVENT_USB_DEVICE_DETACHED = 3; // The argument is the deviceId and vendorId
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800214 oneway void notifySystemEvent(int eventId, in int[] args);
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800215
216 /**
Emilian Peev8b64f282021-03-25 16:49:57 -0700217 * Notify the camera service of a display configuration change.
218 *
219 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
220 */
221 oneway void notifyDisplayConfigurationChange();
222
223 /**
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800224 * Notify the camera service of a device physical status change. May only be called from
225 * a privileged process.
226 *
227 * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state
228 * combinations are device-specific. At device startup, the camera service will assume the device
229 * state is NORMAL until otherwise notified.
230 *
231 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
232 */
233 oneway void notifyDeviceStateChange(long newState);
234
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -0700235 /**
236 * Report Extension specific metrics to camera service for logging. This should only be called
237 * by CameraExtensionSession to log extension metrics. All calls after the first must set
238 * CameraExtensionSessionStats.key to the value returned by this function.
239 *
240 * Each subsequent call fully overwrites the existing CameraExtensionSessionStats for the
241 * current session, so the caller is responsible for keeping the stats complete.
242 *
243 * Due to cameraservice and cameraservice_proxy architecture, there is no guarantee that
244 * {@code stats} will be logged immediately (or at all). CameraService will log whatever
245 * extension stats it has at the time of camera session closing which may be before the app
246 * process receives a session/device closed callback; so CameraExtensionSession
247 * should send metrics to the cameraservice preriodically, and cameraservice must handle calls
248 * to this function from sessions that have not been logged yet and from sessions that have
249 * already been closed.
250 *
251 * @return the key that must be used to report updates to previously reported stats.
252 */
Austin Borger1c1bee02023-06-01 16:51:35 -0700253 @utf8InCpp String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -0700254
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800255 // Bitfield constants for notifyDeviceStateChange
256 // All bits >= 32 are for custom vendor states
257 // Written as ints since AIDL does not support long constants.
258 const int DEVICE_STATE_NORMAL = 0;
259 const int DEVICE_STATE_BACK_COVERED = 1;
260 const int DEVICE_STATE_FRONT_COVERED = 2;
261 const int DEVICE_STATE_FOLDED = 4;
262 const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31;
263
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800264}