blob: 01baba16637c10c4fc4f0b9b0504cd99eb5ffd47 [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;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080033
34/**
35 * Binder interface for the native camera service running in mediaserver.
36 *
37 * @hide
38 */
39interface ICameraService
40{
41 /**
42 * All camera service and device Binder calls may return a
43 * ServiceSpecificException with the following error codes
44 */
45 const int ERROR_PERMISSION_DENIED = 1;
46 const int ERROR_ALREADY_EXISTS = 2;
47 const int ERROR_ILLEGAL_ARGUMENT = 3;
48 const int ERROR_DISCONNECTED = 4;
49 const int ERROR_TIMED_OUT = 5;
50 const int ERROR_DISABLED = 6;
51 const int ERROR_CAMERA_IN_USE = 7;
52 const int ERROR_MAX_CAMERAS_IN_USE = 8;
53 const int ERROR_DEPRECATED_HAL = 9;
54 const int ERROR_INVALID_OPERATION = 10;
55
56 /**
57 * Types for getNumberOfCameras
58 */
59 const int CAMERA_TYPE_BACKWARD_COMPATIBLE = 0;
60 const int CAMERA_TYPE_ALL = 1;
61
62 /**
63 * Return the number of camera devices available in the system
64 */
65 int getNumberOfCameras(int type);
66
67 /**
68 * Fetch basic camera information for a camera device
69 */
Austin Borger3560b7e2022-10-27 12:20:29 -070070 CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080071
72 /**
73 * Default UID/PID values for non-privileged callers of
Eino-Ville Talvalaa976df82019-06-13 18:01:58 -070074 * connect() and connectDevice()
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080075 */
76 const int USE_CALLING_UID = -1;
77 const int USE_CALLING_PID = -1;
78
79 /**
80 * Open a camera device through the old camera API
81 */
82 ICamera connect(ICameraClient client,
83 int cameraId,
84 String opPackageName,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070085 int clientUid, int clientPid,
Austin Borger3560b7e2022-10-27 12:20:29 -070086 int targetSdkVersion,
87 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080088
89 /**
90 * Open a camera device through the new camera API
91 * Only supported for device HAL versions >= 3.2
92 */
93 ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080094 String cameraId,
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080095 String opPackageName,
Philip P. Moltmann9e648f62019-11-04 12:52:45 -080096 @nullable String featureId,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070097 int clientUid, int oomScoreOffset,
Austin Borger3560b7e2022-10-27 12:20:29 -070098 int targetSdkVersion,
99 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800100
101 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800102 * Add listener for changes to camera device and flashlight state.
103 *
104 * Also returns the set of currently-known camera IDs and state of each device.
105 * Adding a listener will trigger the torch status listener to fire for all
Emilian Peev53722fa2019-02-22 17:47:20 -0800106 * devices that have a flash unit.
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800107 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800108 CameraStatus[] addListener(ICameraServiceListener listener);
109
110 /**
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800111 * Get a list of combinations of camera ids which support concurrent streaming.
112 *
113 */
Jayant Chowdharycad23c22020-03-10 15:04:59 -0700114 ConcurrentCameraIdCombination[] getConcurrentCameraIds();
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800115
116 /**
117 * Check whether a particular set of session configurations are concurrently supported by the
118 * corresponding camera ids.
119 *
120 * @param sessions the set of camera id and session configuration pairs to be queried.
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700121 * @param targetSdkVersion the target sdk level of the application calling this function.
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800122 * @return true - the set of concurrent camera id and stream combinations is supported.
123 * false - the set of concurrent camera id and stream combinations is not supported
124 * OR the method was called with a set of camera ids not returned by
Jayant Chowdharycad23c22020-03-10 15:04:59 -0700125 * getConcurrentCameraIds().
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800126 */
127 boolean isConcurrentSessionConfigurationSupported(
Shuzhen Wangd4abdf72021-05-28 11:22:50 -0700128 in CameraIdAndSessionConfiguration[] sessions,
129 int targetSdkVersion);
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800130
131 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800132 * Remove listener for changes to camera device and flashlight state.
133 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800134 void removeListener(ICameraServiceListener listener);
135
136 /**
137 * Read the static camera metadata for a camera device.
138 * Only supported for device HAL versions >= 3.2
139 */
Austin Borger3560b7e2022-10-27 12:20:29 -0700140 CameraMetadataNative getCameraCharacteristics(String cameraId, int targetSdkVersion,
141 boolean overrideToPortrait);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800142
143 /**
144 * Read in the vendor tag descriptors from the camera module HAL.
145 * Intended to be used by the native code of CameraMetadataNative to correctly
146 * interpret camera metadata with vendor tags.
147 */
148 VendorTagDescriptor getCameraVendorTagDescriptor();
149
150 /**
Emilian Peev71c73a22017-03-21 16:35:51 +0000151 * Retrieve the vendor tag descriptor cache which can have multiple vendor
152 * providers.
153 * Intended to be used by the native code of CameraMetadataNative to correctly
154 * interpret camera metadata with vendor tags.
155 */
156 VendorTagDescriptorCache getCameraVendorTagCache();
157
158 /**
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800159 * Read the legacy camera1 parameters into a String
160 */
161 String getLegacyParameters(int cameraId);
162
163 /**
164 * apiVersion constants for supportsCameraApi
165 */
166 const int API_VERSION_1 = 1;
167 const int API_VERSION_2 = 2;
168
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700169 // Determines if a particular API version is supported directly for a cameraId.
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800170 boolean supportsCameraApi(String cameraId, int apiVersion);
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700171 // Determines if a cameraId is a hidden physical camera of a logical multi-camera.
172 boolean isHiddenPhysicalCamera(String cameraId);
Cliff Wud8cae102021-03-11 01:37:42 +0800173 // Inject the external camera to replace the internal camera session.
174 ICameraInjectionSession injectCamera(String packageName, String internalCamId,
175 String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800176
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800177 void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800178
Rucha Katakwar38284522021-11-10 11:25:21 -0800179 // Change the brightness level of the flash unit associated with cameraId to strengthLevel.
180 // If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON.
181 void turnOnTorchWithStrengthLevel(String cameraId, int strengthLevel, IBinder clientBinder);
182
183 // Get the brightness level of the flash unit associated with cameraId.
184 int getTorchStrengthLevel(String cameraId);
185
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800186 /**
187 * Notify the camera service of a system event. Should only be called from system_server.
188 *
189 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
190 */
191 const int EVENT_NONE = 0;
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800192 const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs.
Valentin Iftime29e2e152021-08-13 15:17:33 +0200193 const int EVENT_USB_DEVICE_ATTACHED = 2; // The argument is the deviceId and vendorId
194 const int EVENT_USB_DEVICE_DETACHED = 3; // The argument is the deviceId and vendorId
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800195 oneway void notifySystemEvent(int eventId, in int[] args);
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800196
197 /**
Emilian Peev8b64f282021-03-25 16:49:57 -0700198 * Notify the camera service of a display configuration change.
199 *
200 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
201 */
202 oneway void notifyDisplayConfigurationChange();
203
204 /**
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800205 * Notify the camera service of a device physical status change. May only be called from
206 * a privileged process.
207 *
208 * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state
209 * combinations are device-specific. At device startup, the camera service will assume the device
210 * state is NORMAL until otherwise notified.
211 *
212 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
213 */
214 oneway void notifyDeviceStateChange(long newState);
215
216 // Bitfield constants for notifyDeviceStateChange
217 // All bits >= 32 are for custom vendor states
218 // Written as ints since AIDL does not support long constants.
219 const int DEVICE_STATE_NORMAL = 0;
220 const int DEVICE_STATE_BACK_COVERED = 1;
221 const int DEVICE_STATE_FRONT_COVERED = 2;
222 const int DEVICE_STATE_FOLDED = 4;
223 const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31;
224
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800225}