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; 23 import android.hardware.camera2.ICameraInjectionCallback; 24 import android.hardware.camera2.ICameraInjectionSession; 25 import android.hardware.camera2.params.VendorTagDescriptor; 26 import android.hardware.camera2.params.VendorTagDescriptorCache; 27 import android.hardware.camera2.utils.ConcurrentCameraIdCombination; 28 import android.hardware.camera2.utils.CameraIdAndSessionConfiguration; 29 import android.hardware.camera2.impl.CameraMetadataNative; 30 import android.hardware.ICameraServiceListener; 31 import android.hardware.CameraInfo; 32 import android.hardware.CameraStatus; 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 */ getNumberOfCameras(int type)65 int getNumberOfCameras(int type); 66 67 /** 68 * Fetch basic camera information for a camera device 69 */ getCameraInfo(int cameraId)70 CameraInfo getCameraInfo(int cameraId); 71 72 /** 73 * Default UID/PID values for non-privileged callers of 74 * connect() and connectDevice() 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 */ connect(ICameraClient client, int cameraId, String opPackageName, int clientUid, int clientPid, int targetSdkVersion)82 ICamera connect(ICameraClient client, 83 int cameraId, 84 String opPackageName, 85 int clientUid, int clientPid, 86 int targetSdkVersion); 87 88 /** 89 * Open a camera device through the new camera API 90 * Only supported for device HAL versions >= 3.2 91 */ connectDevice(ICameraDeviceCallbacks callbacks, String cameraId, String opPackageName, @nullable String featureId, int clientUid, int oomScoreOffset, int targetSdkVersion)92 ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks, 93 String cameraId, 94 String opPackageName, 95 @nullable String featureId, 96 int clientUid, int oomScoreOffset, 97 int targetSdkVersion); 98 99 /** 100 * Add listener for changes to camera device and flashlight state. 101 * 102 * Also returns the set of currently-known camera IDs and state of each device. 103 * Adding a listener will trigger the torch status listener to fire for all 104 * devices that have a flash unit. 105 */ addListener(ICameraServiceListener listener)106 CameraStatus[] addListener(ICameraServiceListener listener); 107 108 /** 109 * Get a list of combinations of camera ids which support concurrent streaming. 110 * 111 */ getConcurrentCameraIds()112 ConcurrentCameraIdCombination[] getConcurrentCameraIds(); 113 114 /** 115 * Check whether a particular set of session configurations are concurrently supported by the 116 * corresponding camera ids. 117 * 118 * @param sessions the set of camera id and session configuration pairs to be queried. 119 * @param targetSdkVersion the target sdk level of the application calling this function. 120 * @return true - the set of concurrent camera id and stream combinations is supported. 121 * false - the set of concurrent camera id and stream combinations is not supported 122 * OR the method was called with a set of camera ids not returned by 123 * getConcurrentCameraIds(). 124 */ isConcurrentSessionConfigurationSupported( in CameraIdAndSessionConfiguration[] sessions, int targetSdkVersion)125 boolean isConcurrentSessionConfigurationSupported( 126 in CameraIdAndSessionConfiguration[] sessions, 127 int targetSdkVersion); 128 129 /** 130 * Remove listener for changes to camera device and flashlight state. 131 */ removeListener(ICameraServiceListener listener)132 void removeListener(ICameraServiceListener listener); 133 134 /** 135 * Read the static camera metadata for a camera device. 136 * Only supported for device HAL versions >= 3.2 137 */ getCameraCharacteristics(String cameraId, int targetSdkVersion)138 CameraMetadataNative getCameraCharacteristics(String cameraId, int targetSdkVersion); 139 140 /** 141 * Read in the vendor tag descriptors from the camera module HAL. 142 * Intended to be used by the native code of CameraMetadataNative to correctly 143 * interpret camera metadata with vendor tags. 144 */ getCameraVendorTagDescriptor()145 VendorTagDescriptor getCameraVendorTagDescriptor(); 146 147 /** 148 * Retrieve the vendor tag descriptor cache which can have multiple vendor 149 * providers. 150 * Intended to be used by the native code of CameraMetadataNative to correctly 151 * interpret camera metadata with vendor tags. 152 */ getCameraVendorTagCache()153 VendorTagDescriptorCache getCameraVendorTagCache(); 154 155 /** 156 * Read the legacy camera1 parameters into a String 157 */ getLegacyParameters(int cameraId)158 String getLegacyParameters(int cameraId); 159 160 /** 161 * apiVersion constants for supportsCameraApi 162 */ 163 const int API_VERSION_1 = 1; 164 const int API_VERSION_2 = 2; 165 166 // Determines if a particular API version is supported directly for a cameraId. supportsCameraApi(String cameraId, int apiVersion)167 boolean supportsCameraApi(String cameraId, int apiVersion); 168 // Determines if a cameraId is a hidden physical camera of a logical multi-camera. isHiddenPhysicalCamera(String cameraId)169 boolean isHiddenPhysicalCamera(String cameraId); 170 // Inject the external camera to replace the internal camera session. injectCamera(String packageName, String internalCamId, String externalCamId, in ICameraInjectionCallback CameraInjectionCallback)171 ICameraInjectionSession injectCamera(String packageName, String internalCamId, 172 String externalCamId, in ICameraInjectionCallback CameraInjectionCallback); 173 setTorchMode(String cameraId, boolean enabled, IBinder clientBinder)174 void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder); 175 176 /** 177 * Notify the camera service of a system event. Should only be called from system_server. 178 * 179 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. 180 */ 181 const int EVENT_NONE = 0; 182 const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs. notifySystemEvent(int eventId, in int[] args)183 oneway void notifySystemEvent(int eventId, in int[] args); 184 185 /** 186 * Notify the camera service of a display configuration change. 187 * 188 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. 189 */ notifyDisplayConfigurationChange()190 oneway void notifyDisplayConfigurationChange(); 191 192 /** 193 * Notify the camera service of a device physical status change. May only be called from 194 * a privileged process. 195 * 196 * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state 197 * combinations are device-specific. At device startup, the camera service will assume the device 198 * state is NORMAL until otherwise notified. 199 * 200 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. 201 */ notifyDeviceStateChange(long newState)202 oneway void notifyDeviceStateChange(long newState); 203 204 // Bitfield constants for notifyDeviceStateChange 205 // All bits >= 32 are for custom vendor states 206 // Written as ints since AIDL does not support long constants. 207 const int DEVICE_STATE_NORMAL = 0; 208 const int DEVICE_STATE_BACK_COVERED = 1; 209 const int DEVICE_STATE_FRONT_COVERED = 2; 210 const int DEVICE_STATE_FOLDED = 4; 211 const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31; 212 213 } 214