blob: f8e16312ea9c3eadba3583336f8ee3ca199b3c9f [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;
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080032import android.hardware.CameraStatus;
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -070033import android.hardware.CameraExtensionSessionStats;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080034
35/**
36 * Binder interface for the native camera service running in mediaserver.
37 *
38 * @hide
39 */
40interface ICameraService
41{
42 /**
43 * All camera service and device Binder calls may return a
44 * ServiceSpecificException with the following error codes
45 */
46 const int ERROR_PERMISSION_DENIED = 1;
47 const int ERROR_ALREADY_EXISTS = 2;
48 const int ERROR_ILLEGAL_ARGUMENT = 3;
49 const int ERROR_DISCONNECTED = 4;
50 const int ERROR_TIMED_OUT = 5;
51 const int ERROR_DISABLED = 6;
52 const int ERROR_CAMERA_IN_USE = 7;
53 const int ERROR_MAX_CAMERAS_IN_USE = 8;
54 const int ERROR_DEPRECATED_HAL = 9;
55 const int ERROR_INVALID_OPERATION = 10;
56
57 /**
58 * Types for getNumberOfCameras
59 */
60 const int CAMERA_TYPE_BACKWARD_COMPATIBLE = 0;
61 const int CAMERA_TYPE_ALL = 1;
62
63 /**
64 * Return the number of camera devices available in the system
65 */
66 int getNumberOfCameras(int type);
67
68 /**
69 * Fetch basic camera information for a camera device
70 */
Austin Borger18b30a72022-10-27 12:20:29 -070071 CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080072
73 /**
74 * Default UID/PID values for non-privileged callers of
Eino-Ville Talvalaa976df82019-06-13 18:01:58 -070075 * connect() and connectDevice()
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080076 */
77 const int USE_CALLING_UID = -1;
78 const int USE_CALLING_PID = -1;
79
80 /**
81 * Open a camera device through the old camera API
82 */
83 ICamera connect(ICameraClient client,
84 int cameraId,
85 String opPackageName,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070086 int clientUid, int clientPid,
Austin Borger18b30a72022-10-27 12:20:29 -070087 int targetSdkVersion,
Chengfei Taobe683db2023-01-31 18:52:49 +000088 boolean overrideToPortrait,
89 boolean forceSlowJpegMode);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080090
91 /**
92 * Open a camera device through the new camera API
93 * Only supported for device HAL versions >= 3.2
94 */
95 ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080096 String cameraId,
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080097 String opPackageName,
Philip P. Moltmann9e648f62019-11-04 12:52:45 -080098 @nullable String featureId,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070099 int clientUid, int oomScoreOffset,
Austin Borger18b30a72022-10-27 12:20:29 -0700100 int targetSdkVersion,
101 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800102
103 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800104 * Add listener for changes to camera device and flashlight state.
105 *
106 * Also returns the set of currently-known camera IDs and state of each device.
107 * Adding a listener will trigger the torch status listener to fire for all
Emilian Peev53722fa2019-02-22 17:47:20 -0800108 * devices that have a flash unit.
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800109 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800110 CameraStatus[] addListener(ICameraServiceListener listener);
111
112 /**
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800113 * Get a list of combinations of camera ids which support concurrent streaming.
114 *
115 */
Jayant Chowdharycad23c22020-03-10 15:04:59 -0700116 ConcurrentCameraIdCombination[] getConcurrentCameraIds();
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800117
118 /**
119 * Check whether a particular set of session configurations are concurrently supported by the
120 * corresponding camera ids.
121 *
122 * @param sessions the set of camera id and session configuration pairs to be queried.
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700123 * @param targetSdkVersion the target sdk level of the application calling this function.
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800124 * @return true - the set of concurrent camera id and stream combinations is supported.
125 * false - the set of concurrent camera id and stream combinations is not supported
126 * OR the method was called with a set of camera ids not returned by
Jayant Chowdharycad23c22020-03-10 15:04:59 -0700127 * getConcurrentCameraIds().
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800128 */
129 boolean isConcurrentSessionConfigurationSupported(
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700130 in CameraIdAndSessionConfiguration[] sessions,
131 int targetSdkVersion);
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800132
133 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800134 * Remove listener for changes to camera device and flashlight state.
135 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800136 void removeListener(ICameraServiceListener listener);
137
138 /**
139 * Read the static camera metadata for a camera device.
140 * Only supported for device HAL versions >= 3.2
141 */
Austin Borger18b30a72022-10-27 12:20:29 -0700142 CameraMetadataNative getCameraCharacteristics(String cameraId, int targetSdkVersion,
143 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800144
145 /**
146 * Read in the vendor tag descriptors from the camera module HAL.
147 * Intended to be used by the native code of CameraMetadataNative to correctly
148 * interpret camera metadata with vendor tags.
149 */
150 VendorTagDescriptor getCameraVendorTagDescriptor();
151
152 /**
Emilian Peev71c73a22017-03-21 16:35:51 +0000153 * Retrieve the vendor tag descriptor cache which can have multiple vendor
154 * providers.
155 * Intended to be used by the native code of CameraMetadataNative to correctly
156 * interpret camera metadata with vendor tags.
157 */
158 VendorTagDescriptorCache getCameraVendorTagCache();
159
160 /**
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800161 * Read the legacy camera1 parameters into a String
162 */
163 String getLegacyParameters(int cameraId);
164
165 /**
166 * apiVersion constants for supportsCameraApi
167 */
168 const int API_VERSION_1 = 1;
169 const int API_VERSION_2 = 2;
170
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700171 // Determines if a particular API version is supported directly for a cameraId.
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800172 boolean supportsCameraApi(String cameraId, int apiVersion);
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700173 // Determines if a cameraId is a hidden physical camera of a logical multi-camera.
174 boolean isHiddenPhysicalCamera(String cameraId);
Cliff Wud8cae102021-03-11 01:37:42 +0800175 // Inject the external camera to replace the internal camera session.
176 ICameraInjectionSession injectCamera(String packageName, String internalCamId,
177 String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800178
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800179 void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800180
Rucha Katakwar38284522021-11-10 11:25:21 -0800181 // Change the brightness level of the flash unit associated with cameraId to strengthLevel.
182 // If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON.
183 void turnOnTorchWithStrengthLevel(String cameraId, int strengthLevel, IBinder clientBinder);
184
185 // Get the brightness level of the flash unit associated with cameraId.
186 int getTorchStrengthLevel(String cameraId);
187
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800188 /**
189 * Notify the camera service of a system event. Should only be called from system_server.
190 *
191 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
192 */
193 const int EVENT_NONE = 0;
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800194 const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs.
Valentin Iftime29e2e152021-08-13 15:17:33 +0200195 const int EVENT_USB_DEVICE_ATTACHED = 2; // The argument is the deviceId and vendorId
196 const int EVENT_USB_DEVICE_DETACHED = 3; // The argument is the deviceId and vendorId
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800197 oneway void notifySystemEvent(int eventId, in int[] args);
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800198
199 /**
Emilian Peev8b64f282021-03-25 16:49:57 -0700200 * Notify the camera service of a display configuration change.
201 *
202 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
203 */
204 oneway void notifyDisplayConfigurationChange();
205
206 /**
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800207 * Notify the camera service of a device physical status change. May only be called from
208 * a privileged process.
209 *
210 * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state
211 * combinations are device-specific. At device startup, the camera service will assume the device
212 * state is NORMAL until otherwise notified.
213 *
214 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
215 */
216 oneway void notifyDeviceStateChange(long newState);
217
Avichal Rakesh6e57a2b2023-05-01 17:53:37 -0700218 /**
219 * Report Extension specific metrics to camera service for logging. This should only be called
220 * by CameraExtensionSession to log extension metrics. All calls after the first must set
221 * CameraExtensionSessionStats.key to the value returned by this function.
222 *
223 * Each subsequent call fully overwrites the existing CameraExtensionSessionStats for the
224 * current session, so the caller is responsible for keeping the stats complete.
225 *
226 * Due to cameraservice and cameraservice_proxy architecture, there is no guarantee that
227 * {@code stats} will be logged immediately (or at all). CameraService will log whatever
228 * extension stats it has at the time of camera session closing which may be before the app
229 * process receives a session/device closed callback; so CameraExtensionSession
230 * should send metrics to the cameraservice preriodically, and cameraservice must handle calls
231 * to this function from sessions that have not been logged yet and from sessions that have
232 * already been closed.
233 *
234 * @return the key that must be used to report updates to previously reported stats.
235 */
236 String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
237
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800238 // Bitfield constants for notifyDeviceStateChange
239 // All bits >= 32 are for custom vendor states
240 // Written as ints since AIDL does not support long constants.
241 const int DEVICE_STATE_NORMAL = 0;
242 const int DEVICE_STATE_BACK_COVERED = 1;
243 const int DEVICE_STATE_FRONT_COVERED = 2;
244 const int DEVICE_STATE_FOLDED = 4;
245 const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31;
246
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800247}