Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [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 | #define LOG_TAG "CameraDeviceClient" |
| 18 | #define ATRACE_TAG ATRACE_TAG_CAMERA |
| 19 | // #define LOG_NDEBUG 0 |
| 20 | |
| 21 | #include <utils/Log.h> |
| 22 | #include <utils/Trace.h> |
| 23 | |
| 24 | #include <cutils/properties.h> |
| 25 | #include <gui/Surface.h> |
| 26 | #include "camera2/Parameters.h" |
| 27 | #include "CameraDeviceClient.h" |
| 28 | #include "camera2/ProFrameProcessor.h" |
| 29 | #include "CameraDeviceBase.h" |
| 30 | #include <camera/photography/CaptureRequest.h> |
| 31 | |
| 32 | namespace android { |
| 33 | using namespace camera2; |
| 34 | |
| 35 | CameraDeviceClientBase::CameraDeviceClientBase( |
| 36 | const sp<CameraService>& cameraService, |
| 37 | const sp<ICameraDeviceCallbacks>& remoteCallback, |
| 38 | const String16& clientPackageName, |
| 39 | int cameraId, |
| 40 | int cameraFacing, |
| 41 | int clientPid, |
| 42 | uid_t clientUid, |
| 43 | int servicePid) : |
| 44 | BasicClient(cameraService, remoteCallback->asBinder(), clientPackageName, |
| 45 | cameraId, cameraFacing, clientPid, clientUid, servicePid), |
| 46 | mRemoteCallback(remoteCallback) { |
| 47 | } |
| 48 | void CameraDeviceClientBase::notifyError() { |
| 49 | // Thread safe. Don't bother locking. |
| 50 | sp<ICameraDeviceCallbacks> remoteCb = mRemoteCallback; |
| 51 | |
| 52 | if (remoteCb != 0) { |
| 53 | remoteCb->notifyCallback(CAMERA_MSG_ERROR, CAMERA_ERROR_RELEASED, 0); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // Interface used by CameraService |
| 58 | |
| 59 | CameraDeviceClient::CameraDeviceClient(const sp<CameraService>& cameraService, |
| 60 | const sp<ICameraDeviceCallbacks>& remoteCallback, |
| 61 | const String16& clientPackageName, |
| 62 | int cameraId, |
| 63 | int cameraFacing, |
| 64 | int clientPid, |
| 65 | uid_t clientUid, |
| 66 | int servicePid) : |
| 67 | Camera2ClientBase(cameraService, remoteCallback, clientPackageName, |
| 68 | cameraId, cameraFacing, clientPid, clientUid, servicePid), |
| 69 | mRequestIdCounter(0) { |
| 70 | |
| 71 | ATRACE_CALL(); |
| 72 | ALOGI("CameraDeviceClient %d: Opened", cameraId); |
| 73 | } |
| 74 | |
| 75 | status_t CameraDeviceClient::initialize(camera_module_t *module) |
| 76 | { |
| 77 | ATRACE_CALL(); |
| 78 | status_t res; |
| 79 | |
| 80 | res = Camera2ClientBase::initialize(module); |
| 81 | if (res != OK) { |
| 82 | return res; |
| 83 | } |
| 84 | |
| 85 | String8 threadName; |
| 86 | mFrameProcessor = new ProFrameProcessor(mDevice); |
| 87 | threadName = String8::format("CDU-%d-FrameProc", mCameraId); |
| 88 | mFrameProcessor->run(threadName.string()); |
| 89 | |
| 90 | mFrameProcessor->registerListener(FRAME_PROCESSOR_LISTENER_MIN_ID, |
| 91 | FRAME_PROCESSOR_LISTENER_MAX_ID, |
| 92 | /*listener*/this); |
| 93 | |
| 94 | return OK; |
| 95 | } |
| 96 | |
| 97 | CameraDeviceClient::~CameraDeviceClient() { |
| 98 | } |
| 99 | |
| 100 | status_t CameraDeviceClient::submitRequest(sp<CaptureRequest> request, |
| 101 | bool streaming) { |
| 102 | ATRACE_CALL(); |
| 103 | ALOGV("%s", __FUNCTION__); |
| 104 | |
| 105 | status_t res; |
| 106 | |
| 107 | if ( (res = checkPid(__FUNCTION__) ) != OK) return res; |
| 108 | |
| 109 | Mutex::Autolock icl(mBinderSerializationLock); |
| 110 | |
| 111 | if (!mDevice.get()) return DEAD_OBJECT; |
| 112 | |
| 113 | if (request == 0) { |
| 114 | ALOGE("%s: Camera %d: Sent null request. Rejecting request.", |
| 115 | __FUNCTION__, mCameraId); |
| 116 | return BAD_VALUE; |
| 117 | } |
| 118 | |
| 119 | CameraMetadata metadata(request->mMetadata); |
| 120 | |
| 121 | if (metadata.isEmpty()) { |
| 122 | ALOGE("%s: Camera %d: Sent empty metadata packet. Rejecting request.", |
| 123 | __FUNCTION__, mCameraId); |
| 124 | return BAD_VALUE; |
| 125 | } else if (request->mSurfaceList.size() == 0) { |
| 126 | ALOGE("%s: Camera %d: Requests must have at least one surface target. " |
| 127 | "Rejecting request.", __FUNCTION__, mCameraId); |
| 128 | return BAD_VALUE; |
| 129 | } |
| 130 | |
| 131 | if (!enforceRequestPermissions(metadata)) { |
| 132 | // Callee logs |
| 133 | return PERMISSION_DENIED; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Write in the output stream IDs which we calculate from |
| 138 | * the capture request's list of surface targets |
| 139 | */ |
| 140 | Vector<uint8_t> outputStreamIds; |
| 141 | outputStreamIds.setCapacity(request->mSurfaceList.size()); |
| 142 | for (size_t i = 0; i < request->mSurfaceList.size(); ++i) { |
| 143 | sp<Surface> surface = request->mSurfaceList[i]; |
| 144 | |
| 145 | if (surface == 0) continue; |
| 146 | |
| 147 | sp<IGraphicBufferProducer> gbp = surface->getIGraphicBufferProducer(); |
| 148 | int idx = mStreamMap.indexOfKey(gbp->asBinder()); |
| 149 | |
| 150 | // Trying to submit request with surface that wasn't created |
| 151 | if (idx == NAME_NOT_FOUND) { |
| 152 | ALOGE("%s: Camera %d: Tried to submit a request with a surface that" |
| 153 | " we have not called createStream on", |
| 154 | __FUNCTION__, mCameraId); |
| 155 | return BAD_VALUE; |
| 156 | } |
| 157 | |
| 158 | int streamId = mStreamMap.valueAt(idx); |
| 159 | outputStreamIds.push_back(streamId); |
| 160 | ALOGV("%s: Camera %d: Appending output stream %d to request", |
| 161 | __FUNCTION__, mCameraId, streamId); |
| 162 | } |
| 163 | |
| 164 | metadata.update(ANDROID_REQUEST_OUTPUT_STREAMS, &outputStreamIds[0], |
| 165 | outputStreamIds.size()); |
| 166 | |
| 167 | // TODO: @hide ANDROID_REQUEST_ID, or use another request token |
| 168 | int32_t requestId = mRequestIdCounter++; |
| 169 | metadata.update(ANDROID_REQUEST_ID, &requestId, /*size*/1); |
| 170 | ALOGV("%s: Camera %d: Submitting request with ID %d", |
| 171 | __FUNCTION__, mCameraId, requestId); |
| 172 | |
| 173 | if (streaming) { |
| 174 | res = mDevice->setStreamingRequest(metadata); |
| 175 | if (res != OK) { |
| 176 | ALOGE("%s: Camera %d: Got error %d after trying to set streaming " |
| 177 | "request", __FUNCTION__, mCameraId, res); |
| 178 | } else { |
| 179 | mStreamingRequestList.push_back(mRequestIdCounter); |
| 180 | } |
| 181 | } else { |
| 182 | res = mDevice->capture(metadata); |
| 183 | if (res != OK) { |
| 184 | ALOGE("%s: Camera %d: Got error %d after trying to set capture", |
| 185 | __FUNCTION__, mCameraId, res); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | ALOGV("%s: Camera %d: End of function", __FUNCTION__, mCameraId); |
| 190 | if (res == OK) { |
| 191 | return requestId; |
| 192 | } |
| 193 | |
| 194 | return res; |
| 195 | } |
| 196 | |
| 197 | status_t CameraDeviceClient::cancelRequest(int requestId) { |
| 198 | ATRACE_CALL(); |
| 199 | ALOGV("%s, requestId = %d", __FUNCTION__, requestId); |
| 200 | |
| 201 | status_t res; |
| 202 | |
| 203 | if ( (res = checkPid(__FUNCTION__) ) != OK) return res; |
| 204 | |
| 205 | Mutex::Autolock icl(mBinderSerializationLock); |
| 206 | |
| 207 | if (!mDevice.get()) return DEAD_OBJECT; |
| 208 | |
| 209 | Vector<int>::iterator it, end; |
| 210 | for (it = mStreamingRequestList.begin(), end = mStreamingRequestList.end(); |
| 211 | it != end; ++it) { |
| 212 | if (*it == requestId) { |
| 213 | break; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | if (it == end) { |
| 218 | ALOGE("%s: Camera%d: Did not find request id %d in list of streaming " |
| 219 | "requests", __FUNCTION__, mCameraId, requestId); |
| 220 | return BAD_VALUE; |
| 221 | } |
| 222 | |
| 223 | res = mDevice->clearStreamingRequest(); |
| 224 | |
| 225 | if (res == OK) { |
| 226 | ALOGV("%s: Camera %d: Successfully cleared streaming request", |
| 227 | __FUNCTION__, mCameraId); |
| 228 | mStreamingRequestList.erase(it); |
| 229 | } |
| 230 | |
| 231 | return res; |
| 232 | } |
| 233 | |
| 234 | status_t CameraDeviceClient::deleteStream(int streamId) { |
| 235 | ATRACE_CALL(); |
| 236 | ALOGV("%s (streamId = 0x%x)", __FUNCTION__, streamId); |
| 237 | |
| 238 | status_t res; |
| 239 | if ( (res = checkPid(__FUNCTION__) ) != OK) return res; |
| 240 | |
| 241 | Mutex::Autolock icl(mBinderSerializationLock); |
| 242 | |
| 243 | if (!mDevice.get()) return DEAD_OBJECT; |
| 244 | |
| 245 | // Guard against trying to delete non-created streams |
| 246 | ssize_t index = NAME_NOT_FOUND; |
| 247 | for (size_t i = 0; i < mStreamMap.size(); ++i) { |
| 248 | if (streamId == mStreamMap.valueAt(i)) { |
| 249 | index = i; |
| 250 | break; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | if (index == NAME_NOT_FOUND) { |
| 255 | ALOGW("%s: Camera %d: Invalid stream ID (%d) specified, no stream " |
| 256 | "created yet", __FUNCTION__, mCameraId, streamId); |
| 257 | return BAD_VALUE; |
| 258 | } |
| 259 | |
| 260 | // Also returns BAD_VALUE if stream ID was not valid |
| 261 | res = mDevice->deleteStream(streamId); |
| 262 | |
| 263 | if (res == BAD_VALUE) { |
| 264 | ALOGE("%s: Camera %d: Unexpected BAD_VALUE when deleting stream, but we" |
| 265 | " already checked and the stream ID (%d) should be valid.", |
| 266 | __FUNCTION__, mCameraId, streamId); |
| 267 | } else if (res == OK) { |
| 268 | mStreamMap.removeItemsAt(index); |
| 269 | |
| 270 | ALOGV("%s: Camera %d: Successfully deleted stream ID (%d)", |
| 271 | __FUNCTION__, mCameraId, streamId); |
| 272 | } |
| 273 | |
| 274 | return res; |
| 275 | } |
| 276 | |
| 277 | status_t CameraDeviceClient::createStream(int width, int height, int format, |
| 278 | const sp<IGraphicBufferProducer>& bufferProducer) |
| 279 | { |
| 280 | ATRACE_CALL(); |
| 281 | ALOGV("%s (w = %d, h = %d, f = 0x%x)", __FUNCTION__, width, height, format); |
| 282 | |
| 283 | status_t res; |
| 284 | if ( (res = checkPid(__FUNCTION__) ) != OK) return res; |
| 285 | |
| 286 | Mutex::Autolock icl(mBinderSerializationLock); |
| 287 | |
| 288 | if (!mDevice.get()) return DEAD_OBJECT; |
| 289 | |
| 290 | // Don't create multiple streams for the same target surface |
| 291 | { |
| 292 | ssize_t index = mStreamMap.indexOfKey(bufferProducer->asBinder()); |
| 293 | if (index != NAME_NOT_FOUND) { |
| 294 | ALOGW("%s: Camera %d: Buffer producer already has a stream for it " |
| 295 | "(ID %d)", |
| 296 | __FUNCTION__, mCameraId, index); |
| 297 | return ALREADY_EXISTS; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | sp<IBinder> binder; |
| 302 | sp<ANativeWindow> anw; |
| 303 | if (bufferProducer != 0) { |
| 304 | binder = bufferProducer->asBinder(); |
| 305 | anw = new Surface(bufferProducer); |
| 306 | } |
| 307 | |
| 308 | // TODO: remove w,h,f since we are ignoring them |
| 309 | |
| 310 | if ((res = anw->query(anw.get(), NATIVE_WINDOW_WIDTH, &width)) != OK) { |
| 311 | ALOGE("%s: Camera %d: Failed to query Surface width", __FUNCTION__, |
| 312 | mCameraId); |
| 313 | return res; |
| 314 | } |
| 315 | if ((res = anw->query(anw.get(), NATIVE_WINDOW_HEIGHT, &height)) != OK) { |
| 316 | ALOGE("%s: Camera %d: Failed to query Surface height", __FUNCTION__, |
| 317 | mCameraId); |
| 318 | return res; |
| 319 | } |
| 320 | if ((res = anw->query(anw.get(), NATIVE_WINDOW_FORMAT, &format)) != OK) { |
| 321 | ALOGE("%s: Camera %d: Failed to query Surface format", __FUNCTION__, |
| 322 | mCameraId); |
| 323 | return res; |
| 324 | } |
| 325 | |
| 326 | // FIXME: remove this override since the default format should be |
| 327 | // IMPLEMENTATION_DEFINED. b/9487482 |
| 328 | if (format != HAL_PIXEL_FORMAT_BLOB && |
| 329 | format != HAL_PIXEL_FORMAT_YCbCr_420_888) { |
| 330 | ALOGW("%s: Camera %d: Overriding format 0x%x to IMPLEMENTATION_DEFINED", |
| 331 | __FUNCTION__, mCameraId, format); |
| 332 | format = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED; |
| 333 | } |
| 334 | |
| 335 | // TODO: add startConfigure/stopConfigure call to CameraDeviceBase |
| 336 | // this will make it so Camera3Device doesn't call configure_streams |
| 337 | // after each call, but only once we are done with all. |
| 338 | |
| 339 | int streamId = -1; |
Eino-Ville Talvala | c7ba4a5 | 2013-07-01 09:23:55 -0700 | [diff] [blame] | 340 | if (format == HAL_PIXEL_FORMAT_BLOB) { |
| 341 | // JPEG buffers need to be sized for maximum possible compressed size |
| 342 | CameraMetadata staticInfo = mDevice->info(); |
| 343 | camera_metadata_entry_t entry = staticInfo.find(ANDROID_JPEG_MAX_SIZE); |
| 344 | if (entry.count == 0) { |
| 345 | ALOGE("%s: Camera %d: Can't find maximum JPEG size in " |
| 346 | "static metadata!", __FUNCTION__, mCameraId); |
| 347 | return INVALID_OPERATION; |
| 348 | } |
| 349 | int32_t maxJpegSize = entry.data.i32[0]; |
| 350 | res = mDevice->createStream(anw, width, height, format, maxJpegSize, |
| 351 | &streamId); |
| 352 | } else { |
| 353 | // All other streams are a known size |
| 354 | res = mDevice->createStream(anw, width, height, format, /*size*/0, |
| 355 | &streamId); |
| 356 | } |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 357 | |
| 358 | if (res == OK) { |
| 359 | mStreamMap.add(bufferProducer->asBinder(), streamId); |
| 360 | |
| 361 | ALOGV("%s: Camera %d: Successfully created a new stream ID %d", |
| 362 | __FUNCTION__, mCameraId, streamId); |
| 363 | return streamId; |
| 364 | } |
| 365 | |
| 366 | return res; |
| 367 | } |
| 368 | |
| 369 | // Create a request object from a template. |
| 370 | status_t CameraDeviceClient::createDefaultRequest(int templateId, |
| 371 | /*out*/ |
| 372 | CameraMetadata* request) |
| 373 | { |
| 374 | ATRACE_CALL(); |
| 375 | ALOGV("%s (templateId = 0x%x)", __FUNCTION__, templateId); |
| 376 | |
| 377 | status_t res; |
| 378 | if ( (res = checkPid(__FUNCTION__) ) != OK) return res; |
| 379 | |
| 380 | Mutex::Autolock icl(mBinderSerializationLock); |
| 381 | |
| 382 | if (!mDevice.get()) return DEAD_OBJECT; |
| 383 | |
| 384 | CameraMetadata metadata; |
| 385 | if ( (res = mDevice->createDefaultRequest(templateId, &metadata) ) == OK && |
| 386 | request != NULL) { |
| 387 | |
| 388 | request->swap(metadata); |
| 389 | } |
| 390 | |
| 391 | return res; |
| 392 | } |
| 393 | |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame^] | 394 | status_t CameraDeviceClient::getCameraInfo(/*out*/CameraMetadata* info) |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 395 | { |
| 396 | ATRACE_CALL(); |
| 397 | ALOGV("%s", __FUNCTION__); |
| 398 | |
| 399 | status_t res = OK; |
| 400 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 401 | if ( (res = checkPid(__FUNCTION__) ) != OK) return res; |
| 402 | |
| 403 | Mutex::Autolock icl(mBinderSerializationLock); |
| 404 | |
| 405 | if (!mDevice.get()) return DEAD_OBJECT; |
| 406 | |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame^] | 407 | if (info != NULL) { |
| 408 | *info = mDevice->info(); // static camera metadata |
| 409 | // TODO: merge with device-specific camera metadata |
| 410 | } |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 411 | |
| 412 | return res; |
| 413 | } |
| 414 | |
| 415 | status_t CameraDeviceClient::dump(int fd, const Vector<String16>& args) { |
| 416 | String8 result; |
| 417 | result.appendFormat("CameraDeviceClient[%d] (%p) PID: %d, dump:\n", |
| 418 | mCameraId, |
| 419 | getRemoteCallback()->asBinder().get(), |
| 420 | mClientPid); |
| 421 | result.append(" State: "); |
| 422 | |
| 423 | // TODO: print dynamic/request section from most recent requests |
| 424 | mFrameProcessor->dump(fd, args); |
| 425 | |
| 426 | return dumpDevice(fd, args); |
| 427 | } |
| 428 | |
| 429 | // TODO: refactor the code below this with IProCameraUser. |
| 430 | // it's 100% copy-pasted, so lets not change it right now to make it easier. |
| 431 | |
| 432 | void CameraDeviceClient::detachDevice() { |
| 433 | if (mDevice == 0) return; |
| 434 | |
| 435 | ALOGV("Camera %d: Stopping processors", mCameraId); |
| 436 | |
| 437 | mFrameProcessor->removeListener(FRAME_PROCESSOR_LISTENER_MIN_ID, |
| 438 | FRAME_PROCESSOR_LISTENER_MAX_ID, |
| 439 | /*listener*/this); |
| 440 | mFrameProcessor->requestExit(); |
| 441 | ALOGV("Camera %d: Waiting for threads", mCameraId); |
| 442 | mFrameProcessor->join(); |
| 443 | ALOGV("Camera %d: Disconnecting device", mCameraId); |
| 444 | |
| 445 | // WORKAROUND: HAL refuses to disconnect while there's streams in flight |
| 446 | { |
| 447 | mDevice->clearStreamingRequest(); |
| 448 | |
| 449 | status_t code; |
| 450 | if ((code = mDevice->waitUntilDrained()) != OK) { |
| 451 | ALOGE("%s: waitUntilDrained failed with code 0x%x", __FUNCTION__, |
| 452 | code); |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | Camera2ClientBase::detachDevice(); |
| 457 | } |
| 458 | |
| 459 | /** Device-related methods */ |
| 460 | void CameraDeviceClient::onFrameAvailable(int32_t frameId, |
| 461 | const CameraMetadata& frame) { |
| 462 | ATRACE_CALL(); |
| 463 | ALOGV("%s", __FUNCTION__); |
| 464 | |
| 465 | Mutex::Autolock icl(mBinderSerializationLock); |
| 466 | SharedCameraCallbacks::Lock l(mSharedCameraCallbacks); |
| 467 | |
| 468 | if (mRemoteCallback != NULL) { |
| 469 | ALOGV("%s: frame = %p ", __FUNCTION__, &frame); |
| 470 | mRemoteCallback->onResultReceived(frameId, frame); |
| 471 | } |
| 472 | |
| 473 | } |
| 474 | |
| 475 | // TODO: move to Camera2ClientBase |
| 476 | bool CameraDeviceClient::enforceRequestPermissions(CameraMetadata& metadata) { |
| 477 | |
| 478 | const int pid = IPCThreadState::self()->getCallingPid(); |
| 479 | const int selfPid = getpid(); |
| 480 | camera_metadata_entry_t entry; |
| 481 | |
| 482 | /** |
| 483 | * Mixin default important security values |
| 484 | * - android.led.transmit = defaulted ON |
| 485 | */ |
| 486 | CameraMetadata staticInfo = mDevice->info(); |
| 487 | entry = staticInfo.find(ANDROID_LED_AVAILABLE_LEDS); |
| 488 | for(size_t i = 0; i < entry.count; ++i) { |
| 489 | uint8_t led = entry.data.u8[i]; |
| 490 | |
| 491 | switch(led) { |
| 492 | case ANDROID_LED_AVAILABLE_LEDS_TRANSMIT: { |
| 493 | uint8_t transmitDefault = ANDROID_LED_TRANSMIT_ON; |
| 494 | if (!metadata.exists(ANDROID_LED_TRANSMIT)) { |
| 495 | metadata.update(ANDROID_LED_TRANSMIT, |
| 496 | &transmitDefault, 1); |
| 497 | } |
| 498 | break; |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | // We can do anything! |
| 504 | if (pid == selfPid) { |
| 505 | return true; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * Permission check special fields in the request |
| 510 | * - android.led.transmit = android.permission.CAMERA_DISABLE_TRANSMIT |
| 511 | */ |
| 512 | entry = metadata.find(ANDROID_LED_TRANSMIT); |
| 513 | if (entry.count > 0 && entry.data.u8[0] != ANDROID_LED_TRANSMIT_ON) { |
| 514 | String16 permissionString = |
| 515 | String16("android.permission.CAMERA_DISABLE_TRANSMIT_LED"); |
| 516 | if (!checkCallingPermission(permissionString)) { |
| 517 | const int uid = IPCThreadState::self()->getCallingUid(); |
| 518 | ALOGE("Permission Denial: " |
| 519 | "can't disable transmit LED pid=%d, uid=%d", pid, uid); |
| 520 | return false; |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | return true; |
| 525 | } |
| 526 | |
| 527 | } // namespace android |