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