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