Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | #ifndef ANDROID_HARDWARE_ICAMERASERVICE_H |
| 18 | #define ANDROID_HARDWARE_ICAMERASERVICE_H |
| 19 | |
| 20 | #include <utils/RefBase.h> |
| 21 | #include <binder/IInterface.h> |
| 22 | #include <binder/Parcel.h> |
| 23 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 24 | namespace android { |
| 25 | |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 26 | class ICamera; |
| 27 | class ICameraClient; |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 28 | class ICameraServiceListener; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 29 | class ICameraDeviceUser; |
| 30 | class ICameraDeviceCallbacks; |
Zhijun He | 2b59be8 | 2013-09-25 10:14:30 -0700 | [diff] [blame] | 31 | class CameraMetadata; |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 32 | class VendorTagDescriptor; |
Igor Murashkin | 65d14b9 | 2014-06-17 12:03:20 -0700 | [diff] [blame] | 33 | class String16; |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 34 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 35 | class ICameraService : public IInterface |
| 36 | { |
| 37 | public: |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Keep up-to-date with ICameraService.aidl in frameworks/base |
| 40 | */ |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 41 | enum { |
Chih-Chung Chang | 35a055b | 2010-05-06 16:36:58 +0800 | [diff] [blame] | 42 | GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION, |
Chih-Chung Chang | ddbdb35 | 2010-06-10 13:32:16 +0800 | [diff] [blame] | 43 | GET_CAMERA_INFO, |
Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame] | 44 | CONNECT, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 45 | CONNECT_DEVICE, |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 46 | ADD_LISTENER, |
| 47 | REMOVE_LISTENER, |
Zhijun He | 2b59be8 | 2013-09-25 10:14:30 -0700 | [diff] [blame] | 48 | GET_CAMERA_CHARACTERISTICS, |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 49 | GET_CAMERA_VENDOR_TAG_DESCRIPTOR, |
Igor Murashkin | 65d14b9 | 2014-06-17 12:03:20 -0700 | [diff] [blame] | 50 | GET_LEGACY_PARAMETERS, |
| 51 | SUPPORTS_CAMERA_API, |
Zhijun He | b10cdad | 2014-06-16 16:38:35 -0700 | [diff] [blame] | 52 | CONNECT_LEGACY, |
Chien-Yu Chen | 3068d73 | 2015-02-09 13:29:57 -0800 | [diff] [blame] | 53 | SET_TORCH_MODE, |
Ruben Brunk | 36597b2 | 2015-03-20 22:15:57 -0700 | [diff] [blame] | 54 | NOTIFY_SYSTEM_EVENT, |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 57 | enum { |
Chien-Yu Chen | 98a668f | 2015-12-18 14:10:33 -0800 | [diff] [blame] | 58 | USE_CALLING_PID = -1 |
| 59 | }; |
| 60 | |
| 61 | enum { |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 62 | USE_CALLING_UID = -1 |
| 63 | }; |
| 64 | |
Igor Murashkin | 65d14b9 | 2014-06-17 12:03:20 -0700 | [diff] [blame] | 65 | enum { |
| 66 | API_VERSION_1 = 1, |
| 67 | API_VERSION_2 = 2, |
| 68 | }; |
| 69 | |
Zhijun He | b10cdad | 2014-06-16 16:38:35 -0700 | [diff] [blame] | 70 | enum { |
Eino-Ville Talvala | bad4358 | 2015-08-14 13:12:32 -0700 | [diff] [blame] | 71 | CAMERA_TYPE_BACKWARD_COMPATIBLE = 0, |
| 72 | CAMERA_TYPE_ALL = 1, |
| 73 | }; |
| 74 | |
| 75 | enum { |
Zhijun He | b10cdad | 2014-06-16 16:38:35 -0700 | [diff] [blame] | 76 | CAMERA_HAL_API_VERSION_UNSPECIFIED = -1 |
Ruben Brunk | 36597b2 | 2015-03-20 22:15:57 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | /** |
| 80 | * Keep up-to-date with declarations in |
| 81 | * frameworks/base/services/core/java/com/android/server/camera/CameraService.java |
| 82 | * |
| 83 | * These event codes are intended to be used with the notifySystemEvent call. |
| 84 | */ |
| 85 | enum { |
| 86 | NO_EVENT = 0, |
| 87 | USER_SWITCHED, |
| 88 | }; |
Zhijun He | b10cdad | 2014-06-16 16:38:35 -0700 | [diff] [blame] | 89 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 90 | public: |
| 91 | DECLARE_META_INTERFACE(CameraService); |
| 92 | |
Eino-Ville Talvala | bad4358 | 2015-08-14 13:12:32 -0700 | [diff] [blame] | 93 | // Get the number of cameras that support basic color camera operation |
| 94 | // (type CAMERA_TYPE_BACKWARD_COMPATIBLE) |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 95 | virtual int32_t getNumberOfCameras() = 0; |
Eino-Ville Talvala | bad4358 | 2015-08-14 13:12:32 -0700 | [diff] [blame] | 96 | // Get the number of cameras of the specified type, one of CAMERA_TYPE_* |
| 97 | // enums |
| 98 | virtual int32_t getNumberOfCameras(int cameraType) = 0; |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 99 | virtual status_t getCameraInfo(int cameraId, |
Igor Murashkin | e1445da | 2014-03-17 14:00:29 -0700 | [diff] [blame] | 100 | /*out*/ |
| 101 | struct CameraInfo* cameraInfo) = 0; |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 102 | |
Zhijun He | 2b59be8 | 2013-09-25 10:14:30 -0700 | [diff] [blame] | 103 | virtual status_t getCameraCharacteristics(int cameraId, |
Igor Murashkin | e1445da | 2014-03-17 14:00:29 -0700 | [diff] [blame] | 104 | /*out*/ |
| 105 | CameraMetadata* cameraInfo) = 0; |
Zhijun He | 2b59be8 | 2013-09-25 10:14:30 -0700 | [diff] [blame] | 106 | |
Igor Murashkin | e1445da | 2014-03-17 14:00:29 -0700 | [diff] [blame] | 107 | virtual status_t getCameraVendorTagDescriptor( |
| 108 | /*out*/ |
| 109 | sp<VendorTagDescriptor>& desc) = 0; |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 110 | |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 111 | // Returns 'OK' if operation succeeded |
| 112 | // - Errors: ALREADY_EXISTS if the listener was already added |
| 113 | virtual status_t addListener(const sp<ICameraServiceListener>& listener) |
| 114 | = 0; |
| 115 | // Returns 'OK' if operation succeeded |
| 116 | // - Errors: BAD_VALUE if specified listener was not in the listener list |
| 117 | virtual status_t removeListener(const sp<ICameraServiceListener>& listener) |
| 118 | = 0; |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 119 | /** |
Chien-Yu Chen | 98a668f | 2015-12-18 14:10:33 -0800 | [diff] [blame] | 120 | * clientPackageName, clientUid, and clientPid are used for permissions checking. If |
| 121 | * clientUid == USE_CALLING_UID, then the calling UID is used instead. If |
| 122 | * clientPid == USE_CALLING_PID, then the calling PID is used instead. Only |
| 123 | * trusted callers can set a clientUid and clientPid other than USE_CALLING_UID and |
| 124 | * USE_CALLING_UID respectively. |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 125 | */ |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 126 | virtual status_t connect(const sp<ICameraClient>& cameraClient, |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 127 | int cameraId, |
Svetoslav Ganov | 280405a | 2015-05-12 02:19:27 +0000 | [diff] [blame] | 128 | const String16& clientPackageName, |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 129 | int clientUid, |
Chien-Yu Chen | 98a668f | 2015-12-18 14:10:33 -0800 | [diff] [blame] | 130 | int clientPid, |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 131 | /*out*/ |
| 132 | sp<ICamera>& device) = 0; |
Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame] | 133 | |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 134 | virtual status_t connectDevice( |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 135 | const sp<ICameraDeviceCallbacks>& cameraCb, |
| 136 | int cameraId, |
Svetoslav Ganov | 280405a | 2015-05-12 02:19:27 +0000 | [diff] [blame] | 137 | const String16& clientPackageName, |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 138 | int clientUid, |
| 139 | /*out*/ |
| 140 | sp<ICameraDeviceUser>& device) = 0; |
Igor Murashkin | 65d14b9 | 2014-06-17 12:03:20 -0700 | [diff] [blame] | 141 | |
| 142 | virtual status_t getLegacyParameters( |
| 143 | int cameraId, |
| 144 | /*out*/ |
| 145 | String16* parameters) = 0; |
| 146 | |
| 147 | /** |
| 148 | * Returns OK if device supports camera2 api, |
| 149 | * returns -EOPNOTSUPP if it doesn't. |
| 150 | */ |
| 151 | virtual status_t supportsCameraApi( |
| 152 | int cameraId, int apiVersion) = 0; |
Zhijun He | b10cdad | 2014-06-16 16:38:35 -0700 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * Connect the device as a legacy device for a given HAL version. |
| 156 | * For halVersion, use CAMERA_API_DEVICE_VERSION_* for a particular |
| 157 | * version, or CAMERA_HAL_API_VERSION_UNSPECIFIED for a service-selected version. |
| 158 | */ |
| 159 | virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient, |
| 160 | int cameraId, int halVersion, |
Svetoslav Ganov | 280405a | 2015-05-12 02:19:27 +0000 | [diff] [blame] | 161 | const String16& clientPackageName, |
Zhijun He | b10cdad | 2014-06-16 16:38:35 -0700 | [diff] [blame] | 162 | int clientUid, |
| 163 | /*out*/ |
| 164 | sp<ICamera>& device) = 0; |
Chien-Yu Chen | 3068d73 | 2015-02-09 13:29:57 -0800 | [diff] [blame] | 165 | |
| 166 | /** |
Chien-Yu Chen | 88da526 | 2015-02-17 13:56:46 -0800 | [diff] [blame] | 167 | * Turn on or off a camera's torch mode. Torch mode will be turned off by |
| 168 | * camera service if the lastest client binder that turns it on dies. |
| 169 | * |
| 170 | * return values: |
| 171 | * 0: on a successful operation. |
| 172 | * -ENOSYS: the camera device doesn't support this operation. It it returned |
| 173 | * if and only if android.flash.into.available is false. |
| 174 | * -EBUSY: the camera device is opened. |
| 175 | * -EINVAL: camera_id is invalid or clientBinder is NULL when enabling a |
| 176 | * torch mode. |
Chien-Yu Chen | 3068d73 | 2015-02-09 13:29:57 -0800 | [diff] [blame] | 177 | */ |
| 178 | virtual status_t setTorchMode(const String16& cameraId, bool enabled, |
| 179 | const sp<IBinder>& clientBinder) = 0; |
Ruben Brunk | 36597b2 | 2015-03-20 22:15:57 -0700 | [diff] [blame] | 180 | |
| 181 | /** |
| 182 | * Notify the camera service of a system event. Should only be called from system_server. |
| 183 | */ |
Ruben Brunk | 6267b53 | 2015-04-30 17:44:07 -0700 | [diff] [blame] | 184 | virtual void notifySystemEvent(int32_t eventId, const int32_t* args, size_t length) = 0; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | // ---------------------------------------------------------------------------- |
| 188 | |
| 189 | class BnCameraService: public BnInterface<ICameraService> |
| 190 | { |
| 191 | public: |
| 192 | virtual status_t onTransact( uint32_t code, |
| 193 | const Parcel& data, |
| 194 | Parcel* reply, |
| 195 | uint32_t flags = 0); |
| 196 | }; |
| 197 | |
| 198 | }; // namespace android |
| 199 | |
| 200 | #endif |