blob: fc3e437715382680b891c66f71fe7a76b496918e [file] [log] [blame]
Mathias Agopian3cf61352010-02-09 17:46:37 -08001/*
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 Murashkinbef3f232013-05-30 17:47:38 -070018#define LOG_TAG "BpCameraService"
19#include <utils/Log.h>
Ruben Brunkd1176ef2014-02-21 10:51:38 -080020#include <utils/Errors.h>
Igor Murashkin65d14b92014-06-17 12:03:20 -070021#include <utils/String16.h>
Igor Murashkinbef3f232013-05-30 17:47:38 -070022
Mathias Agopian3cf61352010-02-09 17:46:37 -080023#include <stdint.h>
24#include <sys/types.h>
25
26#include <binder/Parcel.h>
27#include <binder/IPCThreadState.h>
28#include <binder/IServiceManager.h>
29
30#include <camera/ICameraService.h>
Igor Murashkinbfc99152013-02-27 12:55:20 -080031#include <camera/ICameraServiceListener.h>
Igor Murashkinc073ba52013-02-26 14:32:34 -080032#include <camera/IProCameraUser.h>
33#include <camera/IProCameraCallbacks.h>
34#include <camera/ICamera.h>
35#include <camera/ICameraClient.h>
Eino-Ville Talvala7b82efe2013-07-25 17:12:35 -070036#include <camera/camera2/ICameraDeviceUser.h>
37#include <camera/camera2/ICameraDeviceCallbacks.h>
Zhijun He2b59be82013-09-25 10:14:30 -070038#include <camera/CameraMetadata.h>
Ruben Brunkd1176ef2014-02-21 10:51:38 -080039#include <camera/VendorTagDescriptor.h>
Mathias Agopian3cf61352010-02-09 17:46:37 -080040
41namespace android {
42
Igor Murashkinbef3f232013-05-30 17:47:38 -070043namespace {
44
45enum {
46 EX_SECURITY = -1,
47 EX_BAD_PARCELABLE = -2,
48 EX_ILLEGAL_ARGUMENT = -3,
49 EX_NULL_POINTER = -4,
50 EX_ILLEGAL_STATE = -5,
51 EX_HAS_REPLY_HEADER = -128, // special; see below
52};
53
54static bool readExceptionCode(Parcel& reply) {
55 int32_t exceptionCode = reply.readExceptionCode();
56
57 if (exceptionCode != 0) {
58 const char* errorMsg;
59 switch(exceptionCode) {
60 case EX_SECURITY:
61 errorMsg = "Security";
62 break;
63 case EX_BAD_PARCELABLE:
64 errorMsg = "BadParcelable";
65 break;
66 case EX_NULL_POINTER:
67 errorMsg = "NullPointer";
68 break;
69 case EX_ILLEGAL_STATE:
70 errorMsg = "IllegalState";
71 break;
72 // Binder should be handling this code inside Parcel::readException
73 // but lets have a to-string here anyway just in case.
74 case EX_HAS_REPLY_HEADER:
75 errorMsg = "HasReplyHeader";
76 break;
77 default:
78 errorMsg = "Unknown";
79 }
80
81 ALOGE("Binder transmission error %s (%d)", errorMsg, exceptionCode);
82 return true;
83 }
84
85 return false;
86}
87
88};
89
Mathias Agopian3cf61352010-02-09 17:46:37 -080090class BpCameraService: public BpInterface<ICameraService>
91{
92public:
93 BpCameraService(const sp<IBinder>& impl)
94 : BpInterface<ICameraService>(impl)
95 {
96 }
97
Chih-Chung Chang35a055b2010-05-06 16:36:58 +080098 // get number of cameras available
99 virtual int32_t getNumberOfCameras()
100 {
101 Parcel data, reply;
102 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
103 remote()->transact(BnCameraService::GET_NUMBER_OF_CAMERAS, data, &reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700104
105 if (readExceptionCode(reply)) return 0;
Chih-Chung Chang35a055b2010-05-06 16:36:58 +0800106 return reply.readInt32();
107 }
108
Chih-Chung Changddbdb352010-06-10 13:32:16 +0800109 // get information about a camera
110 virtual status_t getCameraInfo(int cameraId,
111 struct CameraInfo* cameraInfo) {
112 Parcel data, reply;
113 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
114 data.writeInt32(cameraId);
115 remote()->transact(BnCameraService::GET_CAMERA_INFO, data, &reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700116
117 if (readExceptionCode(reply)) return -EPROTO;
118 status_t result = reply.readInt32();
119 if (reply.readInt32() != 0) {
120 cameraInfo->facing = reply.readInt32();
121 cameraInfo->orientation = reply.readInt32();
122 }
123 return result;
Chih-Chung Changddbdb352010-06-10 13:32:16 +0800124 }
125
Zhijun He2b59be82013-09-25 10:14:30 -0700126 // get camera characteristics (static metadata)
127 virtual status_t getCameraCharacteristics(int cameraId,
128 CameraMetadata* cameraInfo) {
129 Parcel data, reply;
130 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
131 data.writeInt32(cameraId);
132 remote()->transact(BnCameraService::GET_CAMERA_CHARACTERISTICS, data, &reply);
133
134 if (readExceptionCode(reply)) return -EPROTO;
135 status_t result = reply.readInt32();
136
137 CameraMetadata out;
138 if (reply.readInt32() != 0) {
139 out.readFromParcel(&reply);
140 }
141
142 if (cameraInfo != NULL) {
143 cameraInfo->swap(out);
144 }
145
146 return result;
147 }
148
Ruben Brunkd1176ef2014-02-21 10:51:38 -0800149 // Get enumeration and description of vendor tags for camera
150 virtual status_t getCameraVendorTagDescriptor(/*out*/sp<VendorTagDescriptor>& desc) {
151 Parcel data, reply;
152 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
153 remote()->transact(BnCameraService::GET_CAMERA_VENDOR_TAG_DESCRIPTOR, data, &reply);
154
155 if (readExceptionCode(reply)) return -EPROTO;
156 status_t result = reply.readInt32();
157
158 if (reply.readInt32() != 0) {
159 sp<VendorTagDescriptor> d;
160 if (VendorTagDescriptor::createFromParcel(&reply, /*out*/d) == OK) {
161 desc = d;
162 }
163 }
164 return result;
165 }
166
Igor Murashkine7ee7632013-06-11 18:10:18 -0700167 // connect to camera service (android.hardware.Camera)
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700168 virtual status_t connect(const sp<ICameraClient>& cameraClient, int cameraId,
169 const String16 &clientPackageName, int clientUid,
170 /*out*/
171 sp<ICamera>& device)
Mathias Agopian3cf61352010-02-09 17:46:37 -0800172 {
173 Parcel data, reply;
174 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800175 data.writeStrongBinder(IInterface::asBinder(cameraClient));
Chih-Chung Chang35a055b2010-05-06 16:36:58 +0800176 data.writeInt32(cameraId);
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800177 data.writeString16(clientPackageName);
178 data.writeInt32(clientUid);
Mathias Agopian3cf61352010-02-09 17:46:37 -0800179 remote()->transact(BnCameraService::CONNECT, data, &reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700180
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700181 if (readExceptionCode(reply)) return -EPROTO;
182 status_t status = reply.readInt32();
183 if (reply.readInt32() != 0) {
184 device = interface_cast<ICamera>(reply.readStrongBinder());
185 }
186 return status;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800187 }
Igor Murashkin634a5152013-02-20 17:15:11 -0800188
Zhijun Heb10cdad2014-06-16 16:38:35 -0700189 // connect to camera service (android.hardware.Camera)
190 virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient, int cameraId,
191 int halVersion,
192 const String16 &clientPackageName, int clientUid,
193 /*out*/sp<ICamera>& device)
194 {
195 Parcel data, reply;
196 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800197 data.writeStrongBinder(IInterface::asBinder(cameraClient));
Zhijun Heb10cdad2014-06-16 16:38:35 -0700198 data.writeInt32(cameraId);
199 data.writeInt32(halVersion);
200 data.writeString16(clientPackageName);
201 data.writeInt32(clientUid);
202 remote()->transact(BnCameraService::CONNECT_LEGACY, data, &reply);
203
204 if (readExceptionCode(reply)) return -EPROTO;
205 status_t status = reply.readInt32();
206 if (reply.readInt32() != 0) {
207 device = interface_cast<ICamera>(reply.readStrongBinder());
208 }
209 return status;
210 }
211
Igor Murashkin634a5152013-02-20 17:15:11 -0800212 // connect to camera service (pro client)
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700213 virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb, int cameraId,
214 const String16 &clientPackageName, int clientUid,
215 /*out*/
216 sp<IProCameraUser>& device)
Igor Murashkin634a5152013-02-20 17:15:11 -0800217 {
218 Parcel data, reply;
219 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800220 data.writeStrongBinder(IInterface::asBinder(cameraCb));
Igor Murashkin634a5152013-02-20 17:15:11 -0800221 data.writeInt32(cameraId);
Igor Murashkinc073ba52013-02-26 14:32:34 -0800222 data.writeString16(clientPackageName);
223 data.writeInt32(clientUid);
Igor Murashkin634a5152013-02-20 17:15:11 -0800224 remote()->transact(BnCameraService::CONNECT_PRO, data, &reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700225
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700226 if (readExceptionCode(reply)) return -EPROTO;
227 status_t status = reply.readInt32();
228 if (reply.readInt32() != 0) {
229 device = interface_cast<IProCameraUser>(reply.readStrongBinder());
230 }
231 return status;
Igor Murashkin634a5152013-02-20 17:15:11 -0800232 }
Igor Murashkinbfc99152013-02-27 12:55:20 -0800233
Eino-Ville Talvala7b82efe2013-07-25 17:12:35 -0700234 // connect to camera service (android.hardware.camera2.CameraDevice)
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700235 virtual status_t connectDevice(
Igor Murashkine7ee7632013-06-11 18:10:18 -0700236 const sp<ICameraDeviceCallbacks>& cameraCb,
237 int cameraId,
238 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700239 int clientUid,
240 /*out*/
241 sp<ICameraDeviceUser>& device)
Igor Murashkine7ee7632013-06-11 18:10:18 -0700242 {
243 Parcel data, reply;
244 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800245 data.writeStrongBinder(IInterface::asBinder(cameraCb));
Igor Murashkine7ee7632013-06-11 18:10:18 -0700246 data.writeInt32(cameraId);
247 data.writeString16(clientPackageName);
248 data.writeInt32(clientUid);
249 remote()->transact(BnCameraService::CONNECT_DEVICE, data, &reply);
250
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700251 if (readExceptionCode(reply)) return -EPROTO;
252 status_t status = reply.readInt32();
253 if (reply.readInt32() != 0) {
254 device = interface_cast<ICameraDeviceUser>(reply.readStrongBinder());
255 }
256 return status;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700257 }
258
Igor Murashkinbfc99152013-02-27 12:55:20 -0800259 virtual status_t addListener(const sp<ICameraServiceListener>& listener)
260 {
261 Parcel data, reply;
262 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800263 data.writeStrongBinder(IInterface::asBinder(listener));
Igor Murashkinbfc99152013-02-27 12:55:20 -0800264 remote()->transact(BnCameraService::ADD_LISTENER, data, &reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700265
266 if (readExceptionCode(reply)) return -EPROTO;
Igor Murashkinbfc99152013-02-27 12:55:20 -0800267 return reply.readInt32();
268 }
269
270 virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
271 {
272 Parcel data, reply;
273 data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800274 data.writeStrongBinder(IInterface::asBinder(listener));
Igor Murashkinbfc99152013-02-27 12:55:20 -0800275 remote()->transact(BnCameraService::REMOVE_LISTENER, data, &reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700276
277 if (readExceptionCode(reply)) return -EPROTO;
Igor Murashkinbfc99152013-02-27 12:55:20 -0800278 return reply.readInt32();
279 }
Igor Murashkin65d14b92014-06-17 12:03:20 -0700280
281 virtual status_t getLegacyParameters(int cameraId, String16* parameters) {
282 if (parameters == NULL) {
283 ALOGE("%s: parameters must not be null", __FUNCTION__);
284 return BAD_VALUE;
285 }
286
287 Parcel data, reply;
288
289 data.writeInt32(cameraId);
290 remote()->transact(BnCameraService::GET_LEGACY_PARAMETERS, data, &reply);
291 if (readExceptionCode(reply)) return -EPROTO;
292
293 status_t res = data.readInt32();
294 int32_t length = data.readInt32(); // -1 means null
295 if (length > 0) {
296 *parameters = data.readString16();
297 } else {
298 *parameters = String16();
299 }
300
301 return res;
302 }
303
304 virtual status_t supportsCameraApi(int cameraId, int apiVersion) {
305 Parcel data, reply;
306
307 data.writeInt32(cameraId);
308 data.writeInt32(apiVersion);
309 remote()->transact(BnCameraService::SUPPORTS_CAMERA_API, data, &reply);
310 if (readExceptionCode(reply)) return -EPROTO;
311
312 status_t res = data.readInt32();
313 return res;
314 }
Mathias Agopian3cf61352010-02-09 17:46:37 -0800315};
316
317IMPLEMENT_META_INTERFACE(CameraService, "android.hardware.ICameraService");
318
319// ----------------------------------------------------------------------
320
321status_t BnCameraService::onTransact(
322 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
323{
324 switch(code) {
Chih-Chung Chang35a055b2010-05-06 16:36:58 +0800325 case GET_NUMBER_OF_CAMERAS: {
326 CHECK_INTERFACE(ICameraService, data, reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700327 reply->writeNoException();
Chih-Chung Chang35a055b2010-05-06 16:36:58 +0800328 reply->writeInt32(getNumberOfCameras());
329 return NO_ERROR;
330 } break;
Chih-Chung Changddbdb352010-06-10 13:32:16 +0800331 case GET_CAMERA_INFO: {
332 CHECK_INTERFACE(ICameraService, data, reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700333 CameraInfo cameraInfo = CameraInfo();
Chih-Chung Changddbdb352010-06-10 13:32:16 +0800334 memset(&cameraInfo, 0, sizeof(cameraInfo));
335 status_t result = getCameraInfo(data.readInt32(), &cameraInfo);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700336 reply->writeNoException();
337 reply->writeInt32(result);
338
339 // Fake a parcelable object here
340 reply->writeInt32(1); // means the parcelable is included
Chih-Chung Changddbdb352010-06-10 13:32:16 +0800341 reply->writeInt32(cameraInfo.facing);
342 reply->writeInt32(cameraInfo.orientation);
Chih-Chung Changddbdb352010-06-10 13:32:16 +0800343 return NO_ERROR;
344 } break;
Zhijun He2b59be82013-09-25 10:14:30 -0700345 case GET_CAMERA_CHARACTERISTICS: {
346 CHECK_INTERFACE(ICameraService, data, reply);
347 CameraMetadata info;
348 status_t result = getCameraCharacteristics(data.readInt32(), &info);
349 reply->writeNoException();
350 reply->writeInt32(result);
351
352 // out-variables are after exception and return value
353 reply->writeInt32(1); // means the parcelable is included
354 info.writeToParcel(reply);
355 return NO_ERROR;
356 } break;
Ruben Brunkd1176ef2014-02-21 10:51:38 -0800357 case GET_CAMERA_VENDOR_TAG_DESCRIPTOR: {
358 CHECK_INTERFACE(ICameraService, data, reply);
359 sp<VendorTagDescriptor> d;
360 status_t result = getCameraVendorTagDescriptor(d);
361 reply->writeNoException();
362 reply->writeInt32(result);
363
364 // out-variables are after exception and return value
Ruben Brunkd1176ef2014-02-21 10:51:38 -0800365 if (d == NULL) {
366 reply->writeInt32(0);
367 } else {
Igor Murashkine1445da2014-03-17 14:00:29 -0700368 reply->writeInt32(1); // means the parcelable is included
Ruben Brunkd1176ef2014-02-21 10:51:38 -0800369 d->writeToParcel(reply);
370 }
371 return NO_ERROR;
372 } break;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800373 case CONNECT: {
374 CHECK_INTERFACE(ICameraService, data, reply);
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800375 sp<ICameraClient> cameraClient =
376 interface_cast<ICameraClient>(data.readStrongBinder());
377 int32_t cameraId = data.readInt32();
378 const String16 clientName = data.readString16();
379 int32_t clientUid = data.readInt32();
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700380 sp<ICamera> camera;
381 status_t status = connect(cameraClient, cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -0700382 clientName, clientUid, /*out*/camera);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700383 reply->writeNoException();
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700384 reply->writeInt32(status);
385 if (camera != NULL) {
386 reply->writeInt32(1);
Marco Nelissen06b46062014-11-14 07:58:25 -0800387 reply->writeStrongBinder(IInterface::asBinder(camera));
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700388 } else {
389 reply->writeInt32(0);
390 }
Mathias Agopian3cf61352010-02-09 17:46:37 -0800391 return NO_ERROR;
392 } break;
Igor Murashkin634a5152013-02-20 17:15:11 -0800393 case CONNECT_PRO: {
394 CHECK_INTERFACE(ICameraService, data, reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700395 sp<IProCameraCallbacks> cameraClient =
396 interface_cast<IProCameraCallbacks>(data.readStrongBinder());
Igor Murashkinc073ba52013-02-26 14:32:34 -0800397 int32_t cameraId = data.readInt32();
398 const String16 clientName = data.readString16();
399 int32_t clientUid = data.readInt32();
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700400 sp<IProCameraUser> camera;
401 status_t status = connectPro(cameraClient, cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -0700402 clientName, clientUid, /*out*/camera);
Igor Murashkinbef3f232013-05-30 17:47:38 -0700403 reply->writeNoException();
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700404 reply->writeInt32(status);
405 if (camera != NULL) {
406 reply->writeInt32(1);
Marco Nelissen06b46062014-11-14 07:58:25 -0800407 reply->writeStrongBinder(IInterface::asBinder(camera));
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700408 } else {
409 reply->writeInt32(0);
410 }
Igor Murashkin634a5152013-02-20 17:15:11 -0800411 return NO_ERROR;
412 } break;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700413 case CONNECT_DEVICE: {
414 CHECK_INTERFACE(ICameraService, data, reply);
415 sp<ICameraDeviceCallbacks> cameraClient =
416 interface_cast<ICameraDeviceCallbacks>(data.readStrongBinder());
417 int32_t cameraId = data.readInt32();
418 const String16 clientName = data.readString16();
419 int32_t clientUid = data.readInt32();
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700420 sp<ICameraDeviceUser> camera;
421 status_t status = connectDevice(cameraClient, cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -0700422 clientName, clientUid, /*out*/camera);
Igor Murashkine7ee7632013-06-11 18:10:18 -0700423 reply->writeNoException();
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700424 reply->writeInt32(status);
425 if (camera != NULL) {
426 reply->writeInt32(1);
Marco Nelissen06b46062014-11-14 07:58:25 -0800427 reply->writeStrongBinder(IInterface::asBinder(camera));
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700428 } else {
429 reply->writeInt32(0);
430 }
Igor Murashkine7ee7632013-06-11 18:10:18 -0700431 return NO_ERROR;
432 } break;
Igor Murashkinbfc99152013-02-27 12:55:20 -0800433 case ADD_LISTENER: {
434 CHECK_INTERFACE(ICameraService, data, reply);
435 sp<ICameraServiceListener> listener =
436 interface_cast<ICameraServiceListener>(data.readStrongBinder());
Igor Murashkinbef3f232013-05-30 17:47:38 -0700437 reply->writeNoException();
Igor Murashkinbfc99152013-02-27 12:55:20 -0800438 reply->writeInt32(addListener(listener));
439 return NO_ERROR;
440 } break;
441 case REMOVE_LISTENER: {
442 CHECK_INTERFACE(ICameraService, data, reply);
443 sp<ICameraServiceListener> listener =
444 interface_cast<ICameraServiceListener>(data.readStrongBinder());
Igor Murashkinbef3f232013-05-30 17:47:38 -0700445 reply->writeNoException();
Igor Murashkinbfc99152013-02-27 12:55:20 -0800446 reply->writeInt32(removeListener(listener));
447 return NO_ERROR;
448 } break;
Igor Murashkin65d14b92014-06-17 12:03:20 -0700449 case GET_LEGACY_PARAMETERS: {
450 CHECK_INTERFACE(ICameraService, data, reply);
451 int cameraId = data.readInt32();
452 String16 parameters;
453
454 reply->writeNoException();
455 // return value
456 reply->writeInt32(getLegacyParameters(cameraId, &parameters));
457 // out parameters
458 reply->writeInt32(1); // parameters is always available
459 reply->writeString16(parameters);
460 return NO_ERROR;
461 } break;
462 case SUPPORTS_CAMERA_API: {
463 CHECK_INTERFACE(ICameraService, data, reply);
464 int cameraId = data.readInt32();
465 int apiVersion = data.readInt32();
466
467 reply->writeNoException();
468 // return value
469 reply->writeInt32(supportsCameraApi(cameraId, apiVersion));
470 return NO_ERROR;
471 } break;
Zhijun Heb10cdad2014-06-16 16:38:35 -0700472 case CONNECT_LEGACY: {
473 CHECK_INTERFACE(ICameraService, data, reply);
474 sp<ICameraClient> cameraClient =
475 interface_cast<ICameraClient>(data.readStrongBinder());
476 int32_t cameraId = data.readInt32();
477 int32_t halVersion = data.readInt32();
478 const String16 clientName = data.readString16();
479 int32_t clientUid = data.readInt32();
480 sp<ICamera> camera;
481 status_t status = connectLegacy(cameraClient, cameraId, halVersion,
482 clientName, clientUid, /*out*/camera);
483 reply->writeNoException();
484 reply->writeInt32(status);
485 if (camera != NULL) {
486 reply->writeInt32(1);
Marco Nelissen06b46062014-11-14 07:58:25 -0800487 reply->writeStrongBinder(IInterface::asBinder(camera));
Zhijun Heb10cdad2014-06-16 16:38:35 -0700488 } else {
489 reply->writeInt32(0);
490 }
491 return NO_ERROR;
492 } break;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800493 default:
494 return BBinder::onTransact(code, data, reply, flags);
495 }
496}
497
498// ----------------------------------------------------------------------------
499
500}; // namespace android