Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.hardware; |
| 18 | |
| 19 | import android.hardware.ICamera; |
| 20 | import android.hardware.ICameraClient; |
| 21 | import android.hardware.camera2.ICameraDeviceUser; |
| 22 | import android.hardware.camera2.ICameraDeviceCallbacks; |
Cliff Wu | d8cae10 | 2021-03-11 01:37:42 +0800 | [diff] [blame^] | 23 | import android.hardware.camera2.ICameraInjectionCallback; |
| 24 | import android.hardware.camera2.ICameraInjectionSession; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 25 | import android.hardware.camera2.params.VendorTagDescriptor; |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 26 | import android.hardware.camera2.params.VendorTagDescriptorCache; |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 27 | import android.hardware.camera2.utils.ConcurrentCameraIdCombination; |
| 28 | import android.hardware.camera2.utils.CameraIdAndSessionConfiguration; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 29 | import android.hardware.camera2.impl.CameraMetadataNative; |
| 30 | import android.hardware.ICameraServiceListener; |
| 31 | import android.hardware.CameraInfo; |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 32 | import android.hardware.CameraStatus; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Binder interface for the native camera service running in mediaserver. |
| 36 | * |
| 37 | * @hide |
| 38 | */ |
| 39 | interface 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 | */ |
| 70 | CameraInfo getCameraInfo(int cameraId); |
| 71 | |
| 72 | /** |
| 73 | * Default UID/PID values for non-privileged callers of |
Eino-Ville Talvala | a976df8 | 2019-06-13 18:01:58 -0700 | [diff] [blame] | 74 | * connect() and connectDevice() |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 75 | */ |
| 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, |
| 85 | int clientUid, int clientPid); |
| 86 | |
| 87 | /** |
| 88 | * Open a camera device through the new camera API |
| 89 | * Only supported for device HAL versions >= 3.2 |
| 90 | */ |
| 91 | ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks, |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 92 | String cameraId, |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 93 | String opPackageName, |
Philip P. Moltmann | 9e648f6 | 2019-11-04 12:52:45 -0800 | [diff] [blame] | 94 | @nullable String featureId, |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 95 | int clientUid); |
| 96 | |
| 97 | /** |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 98 | * Add listener for changes to camera device and flashlight state. |
| 99 | * |
| 100 | * Also returns the set of currently-known camera IDs and state of each device. |
| 101 | * Adding a listener will trigger the torch status listener to fire for all |
Emilian Peev | 53722fa | 2019-02-22 17:47:20 -0800 | [diff] [blame] | 102 | * devices that have a flash unit. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 103 | */ |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 104 | CameraStatus[] addListener(ICameraServiceListener listener); |
| 105 | |
| 106 | /** |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 107 | * Get a list of combinations of camera ids which support concurrent streaming. |
| 108 | * |
| 109 | */ |
Jayant Chowdhary | cad23c2 | 2020-03-10 15:04:59 -0700 | [diff] [blame] | 110 | ConcurrentCameraIdCombination[] getConcurrentCameraIds(); |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Check whether a particular set of session configurations are concurrently supported by the |
| 114 | * corresponding camera ids. |
| 115 | * |
| 116 | * @param sessions the set of camera id and session configuration pairs to be queried. |
| 117 | * @return true - the set of concurrent camera id and stream combinations is supported. |
| 118 | * false - the set of concurrent camera id and stream combinations is not supported |
| 119 | * OR the method was called with a set of camera ids not returned by |
Jayant Chowdhary | cad23c2 | 2020-03-10 15:04:59 -0700 | [diff] [blame] | 120 | * getConcurrentCameraIds(). |
Jayant Chowdhary | 2bbdce4 | 2020-01-12 14:55:41 -0800 | [diff] [blame] | 121 | */ |
| 122 | boolean isConcurrentSessionConfigurationSupported( |
| 123 | in CameraIdAndSessionConfiguration[] sessions); |
| 124 | |
| 125 | /** |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 126 | * Remove listener for changes to camera device and flashlight state. |
| 127 | */ |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 128 | void removeListener(ICameraServiceListener listener); |
| 129 | |
| 130 | /** |
| 131 | * Read the static camera metadata for a camera device. |
| 132 | * Only supported for device HAL versions >= 3.2 |
| 133 | */ |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 134 | CameraMetadataNative getCameraCharacteristics(String cameraId); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 135 | |
| 136 | /** |
| 137 | * Read in the vendor tag descriptors from the camera module HAL. |
| 138 | * Intended to be used by the native code of CameraMetadataNative to correctly |
| 139 | * interpret camera metadata with vendor tags. |
| 140 | */ |
| 141 | VendorTagDescriptor getCameraVendorTagDescriptor(); |
| 142 | |
| 143 | /** |
Emilian Peev | 71c73a2 | 2017-03-21 16:35:51 +0000 | [diff] [blame] | 144 | * Retrieve the vendor tag descriptor cache which can have multiple vendor |
| 145 | * providers. |
| 146 | * Intended to be used by the native code of CameraMetadataNative to correctly |
| 147 | * interpret camera metadata with vendor tags. |
| 148 | */ |
| 149 | VendorTagDescriptorCache getCameraVendorTagCache(); |
| 150 | |
| 151 | /** |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 152 | * Read the legacy camera1 parameters into a String |
| 153 | */ |
| 154 | String getLegacyParameters(int cameraId); |
| 155 | |
| 156 | /** |
| 157 | * apiVersion constants for supportsCameraApi |
| 158 | */ |
| 159 | const int API_VERSION_1 = 1; |
| 160 | const int API_VERSION_2 = 2; |
| 161 | |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 162 | // Determines if a particular API version is supported directly for a cameraId. |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 163 | boolean supportsCameraApi(String cameraId, int apiVersion); |
Shuzhen Wang | f9d2c02 | 2018-08-21 12:07:35 -0700 | [diff] [blame] | 164 | // Determines if a cameraId is a hidden physical camera of a logical multi-camera. |
| 165 | boolean isHiddenPhysicalCamera(String cameraId); |
Cliff Wu | d8cae10 | 2021-03-11 01:37:42 +0800 | [diff] [blame^] | 166 | // Inject the external camera to replace the internal camera session. |
| 167 | ICameraInjectionSession injectCamera(String packageName, String internalCamId, |
| 168 | String externalCamId, in ICameraInjectionCallback CameraInjectionCallback); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 169 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 170 | void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 171 | |
| 172 | /** |
| 173 | * Notify the camera service of a system event. Should only be called from system_server. |
| 174 | * |
| 175 | * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. |
| 176 | */ |
| 177 | const int EVENT_NONE = 0; |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 178 | const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs. |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 179 | oneway void notifySystemEvent(int eventId, in int[] args); |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 180 | |
| 181 | /** |
Emilian Peev | 8b64f28 | 2021-03-25 16:49:57 -0700 | [diff] [blame] | 182 | * Notify the camera service of a display configuration change. |
| 183 | * |
| 184 | * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. |
| 185 | */ |
| 186 | oneway void notifyDisplayConfigurationChange(); |
| 187 | |
| 188 | /** |
Eino-Ville Talvala | 63f3611 | 2018-12-06 14:57:03 -0800 | [diff] [blame] | 189 | * Notify the camera service of a device physical status change. May only be called from |
| 190 | * a privileged process. |
| 191 | * |
| 192 | * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state |
| 193 | * combinations are device-specific. At device startup, the camera service will assume the device |
| 194 | * state is NORMAL until otherwise notified. |
| 195 | * |
| 196 | * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. |
| 197 | */ |
| 198 | oneway void notifyDeviceStateChange(long newState); |
| 199 | |
| 200 | // Bitfield constants for notifyDeviceStateChange |
| 201 | // All bits >= 32 are for custom vendor states |
| 202 | // Written as ints since AIDL does not support long constants. |
| 203 | const int DEVICE_STATE_NORMAL = 0; |
| 204 | const int DEVICE_STATE_BACK_COVERED = 1; |
| 205 | const int DEVICE_STATE_FRONT_COVERED = 2; |
| 206 | const int DEVICE_STATE_FOLDED = 4; |
| 207 | const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31; |
| 208 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 209 | } |