| 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; | 
|  | 23 | import android.hardware.camera2.params.VendorTagDescriptor; | 
|  | 24 | import android.hardware.camera2.impl.CameraMetadataNative; | 
|  | 25 | import android.hardware.ICameraServiceListener; | 
|  | 26 | import android.hardware.CameraInfo; | 
| Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 27 | import android.hardware.CameraStatus; | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 28 |  | 
|  | 29 | /** | 
|  | 30 | * Binder interface for the native camera service running in mediaserver. | 
|  | 31 | * | 
|  | 32 | * @hide | 
|  | 33 | */ | 
|  | 34 | interface ICameraService | 
|  | 35 | { | 
|  | 36 | /** | 
|  | 37 | * All camera service and device Binder calls may return a | 
|  | 38 | * ServiceSpecificException with the following error codes | 
|  | 39 | */ | 
|  | 40 | const int ERROR_PERMISSION_DENIED = 1; | 
|  | 41 | const int ERROR_ALREADY_EXISTS = 2; | 
|  | 42 | const int ERROR_ILLEGAL_ARGUMENT = 3; | 
|  | 43 | const int ERROR_DISCONNECTED = 4; | 
|  | 44 | const int ERROR_TIMED_OUT = 5; | 
|  | 45 | const int ERROR_DISABLED = 6; | 
|  | 46 | const int ERROR_CAMERA_IN_USE = 7; | 
|  | 47 | const int ERROR_MAX_CAMERAS_IN_USE = 8; | 
|  | 48 | const int ERROR_DEPRECATED_HAL = 9; | 
|  | 49 | const int ERROR_INVALID_OPERATION = 10; | 
|  | 50 |  | 
|  | 51 | /** | 
|  | 52 | * Types for getNumberOfCameras | 
|  | 53 | */ | 
|  | 54 | const int CAMERA_TYPE_BACKWARD_COMPATIBLE = 0; | 
|  | 55 | const int CAMERA_TYPE_ALL = 1; | 
|  | 56 |  | 
|  | 57 | /** | 
|  | 58 | * Return the number of camera devices available in the system | 
|  | 59 | */ | 
|  | 60 | int getNumberOfCameras(int type); | 
|  | 61 |  | 
|  | 62 | /** | 
|  | 63 | * Fetch basic camera information for a camera device | 
|  | 64 | */ | 
|  | 65 | CameraInfo getCameraInfo(int cameraId); | 
|  | 66 |  | 
|  | 67 | /** | 
|  | 68 | * Default UID/PID values for non-privileged callers of | 
|  | 69 | * connect(), connectDevice(), and connectLegacy() | 
|  | 70 | */ | 
|  | 71 | const int USE_CALLING_UID = -1; | 
|  | 72 | const int USE_CALLING_PID = -1; | 
|  | 73 |  | 
|  | 74 | /** | 
|  | 75 | * Open a camera device through the old camera API | 
|  | 76 | */ | 
|  | 77 | ICamera connect(ICameraClient client, | 
|  | 78 | int cameraId, | 
|  | 79 | String opPackageName, | 
|  | 80 | int clientUid, int clientPid); | 
|  | 81 |  | 
|  | 82 | /** | 
|  | 83 | * Open a camera device through the new camera API | 
|  | 84 | * Only supported for device HAL versions >= 3.2 | 
|  | 85 | */ | 
|  | 86 | ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks, | 
| Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 87 | String cameraId, | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 88 | String opPackageName, | 
|  | 89 | int clientUid); | 
|  | 90 |  | 
|  | 91 | /** | 
|  | 92 | * halVersion constant for connectLegacy | 
|  | 93 | */ | 
|  | 94 | const int CAMERA_HAL_API_VERSION_UNSPECIFIED = -1; | 
|  | 95 |  | 
|  | 96 | /** | 
|  | 97 | * Open a camera device in legacy mode, if supported by the camera module HAL. | 
|  | 98 | */ | 
|  | 99 | ICamera connectLegacy(ICameraClient client, | 
|  | 100 | int cameraId, | 
|  | 101 | int halVersion, | 
|  | 102 | String opPackageName, | 
|  | 103 | int clientUid); | 
|  | 104 |  | 
|  | 105 | /** | 
| Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 106 | * Add listener for changes to camera device and flashlight state. | 
|  | 107 | * | 
|  | 108 | * Also returns the set of currently-known camera IDs and state of each device. | 
|  | 109 | * Adding a listener will trigger the torch status listener to fire for all | 
|  | 110 | * devices that have a flash unit | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 111 | */ | 
| Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 112 | CameraStatus[] addListener(ICameraServiceListener listener); | 
|  | 113 |  | 
|  | 114 | /** | 
|  | 115 | * Remove listener for changes to camera device and flashlight state. | 
|  | 116 | */ | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 117 | void removeListener(ICameraServiceListener listener); | 
|  | 118 |  | 
|  | 119 | /** | 
|  | 120 | * Read the static camera metadata for a camera device. | 
|  | 121 | * Only supported for device HAL versions >= 3.2 | 
|  | 122 | */ | 
| Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 123 | CameraMetadataNative getCameraCharacteristics(String cameraId); | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 124 |  | 
|  | 125 | /** | 
|  | 126 | * Read in the vendor tag descriptors from the camera module HAL. | 
|  | 127 | * Intended to be used by the native code of CameraMetadataNative to correctly | 
|  | 128 | * interpret camera metadata with vendor tags. | 
|  | 129 | */ | 
|  | 130 | VendorTagDescriptor getCameraVendorTagDescriptor(); | 
|  | 131 |  | 
|  | 132 | /** | 
|  | 133 | * Read the legacy camera1 parameters into a String | 
|  | 134 | */ | 
|  | 135 | String getLegacyParameters(int cameraId); | 
|  | 136 |  | 
|  | 137 | /** | 
|  | 138 | * apiVersion constants for supportsCameraApi | 
|  | 139 | */ | 
|  | 140 | const int API_VERSION_1 = 1; | 
|  | 141 | const int API_VERSION_2 = 2; | 
|  | 142 |  | 
|  | 143 | // Determines if a particular API version is supported directly | 
| Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 144 | boolean supportsCameraApi(String cameraId, int apiVersion); | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 145 |  | 
| Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 146 | void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder); | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 147 |  | 
|  | 148 | /** | 
|  | 149 | * Notify the camera service of a system event.  Should only be called from system_server. | 
|  | 150 | * | 
|  | 151 | * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. | 
|  | 152 | */ | 
|  | 153 | const int EVENT_NONE = 0; | 
|  | 154 | const int EVENT_USER_SWITCHED = 1; | 
|  | 155 | oneway void notifySystemEvent(int eventId, in int[] args); | 
|  | 156 | } |