Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2008, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 18 | #define LOG_TAG "BpCameraService" |
| 19 | #include <utils/Log.h> |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 20 | #include <utils/Errors.h> |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 21 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 22 | #include <stdint.h> |
| 23 | #include <sys/types.h> |
| 24 | |
| 25 | #include <binder/Parcel.h> |
| 26 | #include <binder/IPCThreadState.h> |
| 27 | #include <binder/IServiceManager.h> |
| 28 | |
| 29 | #include <camera/ICameraService.h> |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 30 | #include <camera/ICameraServiceListener.h> |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 31 | #include <camera/IProCameraUser.h> |
| 32 | #include <camera/IProCameraCallbacks.h> |
| 33 | #include <camera/ICamera.h> |
| 34 | #include <camera/ICameraClient.h> |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 35 | #include <camera/camera2/ICameraDeviceUser.h> |
| 36 | #include <camera/camera2/ICameraDeviceCallbacks.h> |
Zhijun He | 2b59be8 | 2013-09-25 10:14:30 -0700 | [diff] [blame] | 37 | #include <camera/CameraMetadata.h> |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 38 | #include <camera/VendorTagDescriptor.h> |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 39 | |
| 40 | namespace android { |
| 41 | |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 42 | namespace { |
| 43 | |
| 44 | enum { |
| 45 | EX_SECURITY = -1, |
| 46 | EX_BAD_PARCELABLE = -2, |
| 47 | EX_ILLEGAL_ARGUMENT = -3, |
| 48 | EX_NULL_POINTER = -4, |
| 49 | EX_ILLEGAL_STATE = -5, |
| 50 | EX_HAS_REPLY_HEADER = -128, // special; see below |
| 51 | }; |
| 52 | |
| 53 | static bool readExceptionCode(Parcel& reply) { |
| 54 | int32_t exceptionCode = reply.readExceptionCode(); |
| 55 | |
| 56 | if (exceptionCode != 0) { |
| 57 | const char* errorMsg; |
| 58 | switch(exceptionCode) { |
| 59 | case EX_SECURITY: |
| 60 | errorMsg = "Security"; |
| 61 | break; |
| 62 | case EX_BAD_PARCELABLE: |
| 63 | errorMsg = "BadParcelable"; |
| 64 | break; |
| 65 | case EX_NULL_POINTER: |
| 66 | errorMsg = "NullPointer"; |
| 67 | break; |
| 68 | case EX_ILLEGAL_STATE: |
| 69 | errorMsg = "IllegalState"; |
| 70 | break; |
| 71 | // Binder should be handling this code inside Parcel::readException |
| 72 | // but lets have a to-string here anyway just in case. |
| 73 | case EX_HAS_REPLY_HEADER: |
| 74 | errorMsg = "HasReplyHeader"; |
| 75 | break; |
| 76 | default: |
| 77 | errorMsg = "Unknown"; |
| 78 | } |
| 79 | |
| 80 | ALOGE("Binder transmission error %s (%d)", errorMsg, exceptionCode); |
| 81 | return true; |
| 82 | } |
| 83 | |
| 84 | return false; |
| 85 | } |
| 86 | |
| 87 | }; |
| 88 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 89 | class BpCameraService: public BpInterface<ICameraService> |
| 90 | { |
| 91 | public: |
| 92 | BpCameraService(const sp<IBinder>& impl) |
| 93 | : BpInterface<ICameraService>(impl) |
| 94 | { |
| 95 | } |
| 96 | |
Chih-Chung Chang | 35a055b | 2010-05-06 16:36:58 +0800 | [diff] [blame] | 97 | // get number of cameras available |
| 98 | virtual int32_t getNumberOfCameras() |
| 99 | { |
| 100 | Parcel data, reply; |
| 101 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 102 | remote()->transact(BnCameraService::GET_NUMBER_OF_CAMERAS, data, &reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 103 | |
| 104 | if (readExceptionCode(reply)) return 0; |
Chih-Chung Chang | 35a055b | 2010-05-06 16:36:58 +0800 | [diff] [blame] | 105 | return reply.readInt32(); |
| 106 | } |
| 107 | |
Chih-Chung Chang | ddbdb35 | 2010-06-10 13:32:16 +0800 | [diff] [blame] | 108 | // get information about a camera |
| 109 | virtual status_t getCameraInfo(int cameraId, |
| 110 | struct CameraInfo* cameraInfo) { |
| 111 | Parcel data, reply; |
| 112 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 113 | data.writeInt32(cameraId); |
| 114 | remote()->transact(BnCameraService::GET_CAMERA_INFO, data, &reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 115 | |
| 116 | if (readExceptionCode(reply)) return -EPROTO; |
| 117 | status_t result = reply.readInt32(); |
| 118 | if (reply.readInt32() != 0) { |
| 119 | cameraInfo->facing = reply.readInt32(); |
| 120 | cameraInfo->orientation = reply.readInt32(); |
| 121 | } |
| 122 | return result; |
Chih-Chung Chang | ddbdb35 | 2010-06-10 13:32:16 +0800 | [diff] [blame] | 123 | } |
| 124 | |
Zhijun He | 2b59be8 | 2013-09-25 10:14:30 -0700 | [diff] [blame] | 125 | // get camera characteristics (static metadata) |
| 126 | virtual status_t getCameraCharacteristics(int cameraId, |
| 127 | CameraMetadata* cameraInfo) { |
| 128 | Parcel data, reply; |
| 129 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 130 | data.writeInt32(cameraId); |
| 131 | remote()->transact(BnCameraService::GET_CAMERA_CHARACTERISTICS, data, &reply); |
| 132 | |
| 133 | if (readExceptionCode(reply)) return -EPROTO; |
| 134 | status_t result = reply.readInt32(); |
| 135 | |
| 136 | CameraMetadata out; |
| 137 | if (reply.readInt32() != 0) { |
| 138 | out.readFromParcel(&reply); |
| 139 | } |
| 140 | |
| 141 | if (cameraInfo != NULL) { |
| 142 | cameraInfo->swap(out); |
| 143 | } |
| 144 | |
| 145 | return result; |
| 146 | } |
| 147 | |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 148 | // Get enumeration and description of vendor tags for camera |
| 149 | virtual status_t getCameraVendorTagDescriptor(/*out*/sp<VendorTagDescriptor>& desc) { |
| 150 | Parcel data, reply; |
| 151 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 152 | remote()->transact(BnCameraService::GET_CAMERA_VENDOR_TAG_DESCRIPTOR, data, &reply); |
| 153 | |
| 154 | if (readExceptionCode(reply)) return -EPROTO; |
| 155 | status_t result = reply.readInt32(); |
| 156 | |
| 157 | if (reply.readInt32() != 0) { |
| 158 | sp<VendorTagDescriptor> d; |
| 159 | if (VendorTagDescriptor::createFromParcel(&reply, /*out*/d) == OK) { |
| 160 | desc = d; |
| 161 | } |
| 162 | } |
| 163 | return result; |
| 164 | } |
| 165 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 166 | // connect to camera service (android.hardware.Camera) |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 167 | virtual status_t connect(const sp<ICameraClient>& cameraClient, int cameraId, |
| 168 | const String16 &clientPackageName, int clientUid, |
| 169 | /*out*/ |
| 170 | sp<ICamera>& device) |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 171 | { |
| 172 | Parcel data, reply; |
| 173 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 174 | data.writeStrongBinder(cameraClient->asBinder()); |
Chih-Chung Chang | 35a055b | 2010-05-06 16:36:58 +0800 | [diff] [blame] | 175 | data.writeInt32(cameraId); |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 176 | data.writeString16(clientPackageName); |
| 177 | data.writeInt32(clientUid); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 178 | remote()->transact(BnCameraService::CONNECT, data, &reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 179 | |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 180 | if (readExceptionCode(reply)) return -EPROTO; |
| 181 | status_t status = reply.readInt32(); |
| 182 | if (reply.readInt32() != 0) { |
| 183 | device = interface_cast<ICamera>(reply.readStrongBinder()); |
| 184 | } |
| 185 | return status; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 186 | } |
Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame] | 187 | |
| 188 | // connect to camera service (pro client) |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 189 | virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb, int cameraId, |
| 190 | const String16 &clientPackageName, int clientUid, |
| 191 | /*out*/ |
| 192 | sp<IProCameraUser>& device) |
Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame] | 193 | { |
| 194 | Parcel data, reply; |
| 195 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 196 | data.writeStrongBinder(cameraCb->asBinder()); |
| 197 | data.writeInt32(cameraId); |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 198 | data.writeString16(clientPackageName); |
| 199 | data.writeInt32(clientUid); |
Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame] | 200 | remote()->transact(BnCameraService::CONNECT_PRO, data, &reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 201 | |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 202 | if (readExceptionCode(reply)) return -EPROTO; |
| 203 | status_t status = reply.readInt32(); |
| 204 | if (reply.readInt32() != 0) { |
| 205 | device = interface_cast<IProCameraUser>(reply.readStrongBinder()); |
| 206 | } |
| 207 | return status; |
Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame] | 208 | } |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 209 | |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 210 | // connect to camera service (android.hardware.camera2.CameraDevice) |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 211 | virtual status_t connectDevice( |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 212 | const sp<ICameraDeviceCallbacks>& cameraCb, |
| 213 | int cameraId, |
| 214 | const String16& clientPackageName, |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 215 | int clientUid, |
| 216 | /*out*/ |
| 217 | sp<ICameraDeviceUser>& device) |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 218 | { |
| 219 | Parcel data, reply; |
| 220 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 221 | data.writeStrongBinder(cameraCb->asBinder()); |
| 222 | data.writeInt32(cameraId); |
| 223 | data.writeString16(clientPackageName); |
| 224 | data.writeInt32(clientUid); |
| 225 | remote()->transact(BnCameraService::CONNECT_DEVICE, data, &reply); |
| 226 | |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 227 | if (readExceptionCode(reply)) return -EPROTO; |
| 228 | status_t status = reply.readInt32(); |
| 229 | if (reply.readInt32() != 0) { |
| 230 | device = interface_cast<ICameraDeviceUser>(reply.readStrongBinder()); |
| 231 | } |
| 232 | return status; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 235 | virtual status_t addListener(const sp<ICameraServiceListener>& listener) |
| 236 | { |
| 237 | Parcel data, reply; |
| 238 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 239 | data.writeStrongBinder(listener->asBinder()); |
| 240 | remote()->transact(BnCameraService::ADD_LISTENER, data, &reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 241 | |
| 242 | if (readExceptionCode(reply)) return -EPROTO; |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 243 | return reply.readInt32(); |
| 244 | } |
| 245 | |
| 246 | virtual status_t removeListener(const sp<ICameraServiceListener>& listener) |
| 247 | { |
| 248 | Parcel data, reply; |
| 249 | data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); |
| 250 | data.writeStrongBinder(listener->asBinder()); |
| 251 | remote()->transact(BnCameraService::REMOVE_LISTENER, data, &reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 252 | |
| 253 | if (readExceptionCode(reply)) return -EPROTO; |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 254 | return reply.readInt32(); |
| 255 | } |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | IMPLEMENT_META_INTERFACE(CameraService, "android.hardware.ICameraService"); |
| 259 | |
| 260 | // ---------------------------------------------------------------------- |
| 261 | |
| 262 | status_t BnCameraService::onTransact( |
| 263 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 264 | { |
| 265 | switch(code) { |
Chih-Chung Chang | 35a055b | 2010-05-06 16:36:58 +0800 | [diff] [blame] | 266 | case GET_NUMBER_OF_CAMERAS: { |
| 267 | CHECK_INTERFACE(ICameraService, data, reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 268 | reply->writeNoException(); |
Chih-Chung Chang | 35a055b | 2010-05-06 16:36:58 +0800 | [diff] [blame] | 269 | reply->writeInt32(getNumberOfCameras()); |
| 270 | return NO_ERROR; |
| 271 | } break; |
Chih-Chung Chang | ddbdb35 | 2010-06-10 13:32:16 +0800 | [diff] [blame] | 272 | case GET_CAMERA_INFO: { |
| 273 | CHECK_INTERFACE(ICameraService, data, reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 274 | CameraInfo cameraInfo = CameraInfo(); |
Chih-Chung Chang | ddbdb35 | 2010-06-10 13:32:16 +0800 | [diff] [blame] | 275 | memset(&cameraInfo, 0, sizeof(cameraInfo)); |
| 276 | status_t result = getCameraInfo(data.readInt32(), &cameraInfo); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 277 | reply->writeNoException(); |
| 278 | reply->writeInt32(result); |
| 279 | |
| 280 | // Fake a parcelable object here |
| 281 | reply->writeInt32(1); // means the parcelable is included |
Chih-Chung Chang | ddbdb35 | 2010-06-10 13:32:16 +0800 | [diff] [blame] | 282 | reply->writeInt32(cameraInfo.facing); |
| 283 | reply->writeInt32(cameraInfo.orientation); |
Chih-Chung Chang | ddbdb35 | 2010-06-10 13:32:16 +0800 | [diff] [blame] | 284 | return NO_ERROR; |
| 285 | } break; |
Zhijun He | 2b59be8 | 2013-09-25 10:14:30 -0700 | [diff] [blame] | 286 | case GET_CAMERA_CHARACTERISTICS: { |
| 287 | CHECK_INTERFACE(ICameraService, data, reply); |
| 288 | CameraMetadata info; |
| 289 | status_t result = getCameraCharacteristics(data.readInt32(), &info); |
| 290 | reply->writeNoException(); |
| 291 | reply->writeInt32(result); |
| 292 | |
| 293 | // out-variables are after exception and return value |
| 294 | reply->writeInt32(1); // means the parcelable is included |
| 295 | info.writeToParcel(reply); |
| 296 | return NO_ERROR; |
| 297 | } break; |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 298 | case GET_CAMERA_VENDOR_TAG_DESCRIPTOR: { |
| 299 | CHECK_INTERFACE(ICameraService, data, reply); |
| 300 | sp<VendorTagDescriptor> d; |
| 301 | status_t result = getCameraVendorTagDescriptor(d); |
| 302 | reply->writeNoException(); |
| 303 | reply->writeInt32(result); |
| 304 | |
| 305 | // out-variables are after exception and return value |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 306 | if (d == NULL) { |
| 307 | reply->writeInt32(0); |
| 308 | } else { |
Igor Murashkin | e1445da | 2014-03-17 14:00:29 -0700 | [diff] [blame] | 309 | reply->writeInt32(1); // means the parcelable is included |
Ruben Brunk | d1176ef | 2014-02-21 10:51:38 -0800 | [diff] [blame] | 310 | d->writeToParcel(reply); |
| 311 | } |
| 312 | return NO_ERROR; |
| 313 | } break; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 314 | case CONNECT: { |
| 315 | CHECK_INTERFACE(ICameraService, data, reply); |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 316 | sp<ICameraClient> cameraClient = |
| 317 | interface_cast<ICameraClient>(data.readStrongBinder()); |
| 318 | int32_t cameraId = data.readInt32(); |
| 319 | const String16 clientName = data.readString16(); |
| 320 | int32_t clientUid = data.readInt32(); |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 321 | sp<ICamera> camera; |
| 322 | status_t status = connect(cameraClient, cameraId, |
Igor Murashkin | e1445da | 2014-03-17 14:00:29 -0700 | [diff] [blame] | 323 | clientName, clientUid, /*out*/camera); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 324 | reply->writeNoException(); |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 325 | reply->writeInt32(status); |
| 326 | if (camera != NULL) { |
| 327 | reply->writeInt32(1); |
| 328 | reply->writeStrongBinder(camera->asBinder()); |
| 329 | } else { |
| 330 | reply->writeInt32(0); |
| 331 | } |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 332 | return NO_ERROR; |
| 333 | } break; |
Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame] | 334 | case CONNECT_PRO: { |
| 335 | CHECK_INTERFACE(ICameraService, data, reply); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 336 | sp<IProCameraCallbacks> cameraClient = |
| 337 | interface_cast<IProCameraCallbacks>(data.readStrongBinder()); |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 338 | int32_t cameraId = data.readInt32(); |
| 339 | const String16 clientName = data.readString16(); |
| 340 | int32_t clientUid = data.readInt32(); |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 341 | sp<IProCameraUser> camera; |
| 342 | status_t status = connectPro(cameraClient, cameraId, |
Igor Murashkin | e1445da | 2014-03-17 14:00:29 -0700 | [diff] [blame] | 343 | clientName, clientUid, /*out*/camera); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 344 | reply->writeNoException(); |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 345 | reply->writeInt32(status); |
| 346 | if (camera != NULL) { |
| 347 | reply->writeInt32(1); |
| 348 | reply->writeStrongBinder(camera->asBinder()); |
| 349 | } else { |
| 350 | reply->writeInt32(0); |
| 351 | } |
Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame] | 352 | return NO_ERROR; |
| 353 | } break; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 354 | case CONNECT_DEVICE: { |
| 355 | CHECK_INTERFACE(ICameraService, data, reply); |
| 356 | sp<ICameraDeviceCallbacks> cameraClient = |
| 357 | interface_cast<ICameraDeviceCallbacks>(data.readStrongBinder()); |
| 358 | int32_t cameraId = data.readInt32(); |
| 359 | const String16 clientName = data.readString16(); |
| 360 | int32_t clientUid = data.readInt32(); |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 361 | sp<ICameraDeviceUser> camera; |
| 362 | status_t status = connectDevice(cameraClient, cameraId, |
Igor Murashkin | e1445da | 2014-03-17 14:00:29 -0700 | [diff] [blame] | 363 | clientName, clientUid, /*out*/camera); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 364 | reply->writeNoException(); |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 365 | reply->writeInt32(status); |
| 366 | if (camera != NULL) { |
| 367 | reply->writeInt32(1); |
| 368 | reply->writeStrongBinder(camera->asBinder()); |
| 369 | } else { |
| 370 | reply->writeInt32(0); |
| 371 | } |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 372 | return NO_ERROR; |
| 373 | } break; |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 374 | case ADD_LISTENER: { |
| 375 | CHECK_INTERFACE(ICameraService, data, reply); |
| 376 | sp<ICameraServiceListener> listener = |
| 377 | interface_cast<ICameraServiceListener>(data.readStrongBinder()); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 378 | reply->writeNoException(); |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 379 | reply->writeInt32(addListener(listener)); |
| 380 | return NO_ERROR; |
| 381 | } break; |
| 382 | case REMOVE_LISTENER: { |
| 383 | CHECK_INTERFACE(ICameraService, data, reply); |
| 384 | sp<ICameraServiceListener> listener = |
| 385 | interface_cast<ICameraServiceListener>(data.readStrongBinder()); |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 386 | reply->writeNoException(); |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 387 | reply->writeInt32(removeListener(listener)); |
| 388 | return NO_ERROR; |
| 389 | } break; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 390 | default: |
| 391 | return BBinder::onTransact(code, data, reply, flags); |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | // ---------------------------------------------------------------------------- |
| 396 | |
| 397 | }; // namespace android |