From 8a4a0ac6545f53a9ec4af6074caf0e935b08ffbe Mon Sep 17 00:00:00 2001 From: Oleksiy Avramchenko Date: Mon, 14 Sep 2015 11:00:33 +0200 Subject: DO NOT MERGE: Fix setTorchMode support for the old HAL version CameraHardwareInterfaceFlashControl class calls disconnectCameraDevice when torch is disabled. This closes connection to the camera module, but mDevice instance is kept and variable is non-NULL which will prevent connection next time torch is going to be enabled. Bug: 24909924 Change-Id: Icb1ffb07f05256afd92821f0f4908cda5332c05b --- services/camera/libcameraservice/CameraFlashlight.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'services/camera') diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp index 280bb9d..e42c596 100644 --- a/services/camera/libcameraservice/CameraFlashlight.cpp +++ b/services/camera/libcameraservice/CameraFlashlight.cpp @@ -878,6 +878,7 @@ status_t CameraHardwareInterfaceFlashControl::disconnectCameraDevice() { } mDevice->setPreviewWindow(NULL); mDevice->release(); + mDevice = NULL; return OK; } -- cgit v1.1 From d4a653a15767d4de37dbfdee22c2170951c93299 Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Wed, 14 Oct 2015 11:05:44 -0700 Subject: Camera: setup vendor tags before get_camera_info So HAL can use vendor tags on first get_camera_info call. Bug: 24913201 Change-Id: I73f17de87e3712a27f9cee366995df27a740f5cb --- services/camera/libcameraservice/CameraService.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'services/camera') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 2aaefe9..fb43e8c 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -173,6 +173,13 @@ void CameraService::onFirstRef() mNumberOfCameras = mModule->getNumberOfCameras(); mNumberOfNormalCameras = mNumberOfCameras; + // Setup vendor tags before we call get_camera_info the first time + // because HAL might need to setup static vendor keys in get_camera_info + VendorTagDescriptor::clearGlobalVendorTagDescriptor(); + if (mModule->getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_2) { + setUpVendorTags(); + } + mFlashlight = new CameraFlashlight(*mModule, *this); status_t res = mFlashlight->findFlashUnits(); if (res) { @@ -239,12 +246,6 @@ void CameraService::onFirstRef() mModule->setCallbacks(this); } - VendorTagDescriptor::clearGlobalVendorTagDescriptor(); - - if (mModule->getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_2) { - setUpVendorTags(); - } - CameraDeviceFactory::registerService(this); CameraService::pingCameraServiceProxy(); -- cgit v1.1 From 82104ebbb2cc04277ab07b355f38f73045a11770 Mon Sep 17 00:00:00 2001 From: Chien-Yu Chen Date: Wed, 14 Oct 2015 11:29:31 -0700 Subject: Camera: Add video recording stop sound Add video recording stop sound to match MediaActionSound. Bug: 24745252 Change-Id: I84b69757c7e0a98abfaafcce5f41dd45fd41cf74 --- services/camera/libcameraservice/CameraService.cpp | 3 ++- services/camera/libcameraservice/CameraService.h | 3 ++- services/camera/libcameraservice/api1/Camera2Client.cpp | 6 +++--- services/camera/libcameraservice/api1/CameraClient.cpp | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'services/camera') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 2aaefe9..19f588a 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -1831,7 +1831,8 @@ void CameraService::loadSound() { if (mSoundRef++) return; mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg"); - mSoundPlayer[SOUND_RECORDING] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg"); + mSoundPlayer[SOUND_RECORDING_START] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg"); + mSoundPlayer[SOUND_RECORDING_STOP] = newMediaPlayer("/system/media/audio/ui/VideoStop.ogg"); } void CameraService::releaseSound() { diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index cd97b08..4b0eeb7 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -159,7 +159,8 @@ public: enum sound_kind { SOUND_SHUTTER = 0, - SOUND_RECORDING = 1, + SOUND_RECORDING_START = 1, + SOUND_RECORDING_STOP = 2, NUM_SOUNDS }; diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index 48b5a26..4338d64 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -1040,7 +1040,7 @@ status_t Camera2Client::startRecordingL(Parameters ¶ms, bool restart) { } if (!restart) { - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_START); mStreamingProcessor->updateRecordingRequest(params); if (res != OK) { ALOGE("%s: Camera %d: Unable to update recording request: %s (%d)", @@ -1212,7 +1212,7 @@ void Camera2Client::stopRecording() { return; }; - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_STOP); // Remove recording stream to prevent it from slowing down takePicture later if (!l.mParameters.recordingHint && l.mParameters.isJpegSizeOverridden()) { @@ -1638,7 +1638,7 @@ status_t Camera2Client::commandEnableShutterSoundL(bool enable) { } status_t Camera2Client::commandPlayRecordingSoundL() { - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_START); return OK; } diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index 38e35cd..30b462b 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -439,7 +439,7 @@ status_t CameraClient::startRecordingMode() { // start recording mode enableMsgType(CAMERA_MSG_VIDEO_FRAME); - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_START); result = mHardware->startRecording(); if (result != NO_ERROR) { ALOGE("mHardware->startRecording() failed with status %d", result); @@ -470,7 +470,7 @@ void CameraClient::stopRecording() { disableMsgType(CAMERA_MSG_VIDEO_FRAME); mHardware->stopRecording(); - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_STOP); mPreviewBuffer.clear(); } @@ -648,7 +648,7 @@ status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) { } return OK; } else if (cmd == CAMERA_CMD_PLAY_RECORDING_SOUND) { - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_START); } else if (cmd == CAMERA_CMD_SET_VIDEO_BUFFER_COUNT) { // Silently ignore this command return INVALID_OPERATION; -- cgit v1.1 From 3e600894685b994849d59307721c6862ae0c45b7 Mon Sep 17 00:00:00 2001 From: Ranjith Kagathi Ananda Date: Thu, 8 Oct 2015 16:00:33 -0700 Subject: Camera: frameworks: Add NULL check for callback --Added NULL check for mRemoteCallback Ack by: Susmitha Gummalla Bug: 25023187 Change-Id: Ib88a128a52e81b8ec1052e3222b6d8b9e494afcc --- services/camera/libcameraservice/CameraService.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'services/camera') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index f2d6ad6..2bb282f 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -2084,7 +2084,11 @@ sp CameraService::Client::getClientFromCookie(void* user) void CameraService::Client::notifyError(ICameraDeviceCallbacks::CameraErrorCode errorCode, const CaptureResultExtras& resultExtras) { - mRemoteCallback->notifyCallback(CAMERA_MSG_ERROR, CAMERA_ERROR_RELEASED, 0); + if (mRemoteCallback != NULL) { + mRemoteCallback->notifyCallback(CAMERA_MSG_ERROR, CAMERA_ERROR_RELEASED, 0); + } else { + ALOGE("mRemoteCallback is NULL!!"); + } } // NOTE: function is idempotent -- cgit v1.1 From 32ab9fdab562127ccd37a8cdb15421ebdf82a458 Mon Sep 17 00:00:00 2001 From: Ranjith Kagathi Ananda Date: Thu, 8 Oct 2015 16:41:09 -0700 Subject: libcameraservice: Fix ALOG prints in FlashLight. Add missing __FUNCTION__ arguments into log statements. Ack by: Dilip Gopalakrishna Bug: 25023187 Change-Id: I0256bad626d490fb9360a73c104afaad7a012a97 --- services/camera/libcameraservice/CameraFlashlight.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'services/camera') diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp index e42c596..406c1c4 100644 --- a/services/camera/libcameraservice/CameraFlashlight.cpp +++ b/services/camera/libcameraservice/CameraFlashlight.cpp @@ -99,7 +99,8 @@ status_t CameraFlashlight::createFlashlightControl(const String8& cameraId) { status_t CameraFlashlight::setTorchMode(const String8& cameraId, bool enabled) { if (!mFlashlightMapInitialized) { - ALOGE("%s: findFlashUnits() must be called before this method."); + ALOGE("%s: findFlashUnits() must be called before this method.", + __FUNCTION__); return NO_INIT; } @@ -200,7 +201,8 @@ bool CameraFlashlight::hasFlashUnit(const String8& cameraId) { bool CameraFlashlight::hasFlashUnitLocked(const String8& cameraId) { if (!mFlashlightMapInitialized) { - ALOGE("%s: findFlashUnits() must be called before this method."); + ALOGE("%s: findFlashUnits() must be called before this method.", + __FUNCTION__); return false; } @@ -219,7 +221,8 @@ status_t CameraFlashlight::prepareDeviceOpen(const String8& cameraId) { Mutex::Autolock l(mLock); if (!mFlashlightMapInitialized) { - ALOGE("%s: findFlashUnits() must be called before this method."); + ALOGE("%s: findFlashUnits() must be called before this method.", + __FUNCTION__); return NO_INIT; } @@ -256,7 +259,8 @@ status_t CameraFlashlight::deviceClosed(const String8& cameraId) { Mutex::Autolock l(mLock); if (!mFlashlightMapInitialized) { - ALOGE("%s: findFlashUnits() must be called before this method."); + ALOGE("%s: findFlashUnits() must be called before this method.", + __FUNCTION__); return NO_INIT; } -- cgit v1.1 From 5adc76c49a525993f3362cf648864fb21f4547f0 Mon Sep 17 00:00:00 2001 From: Tom Keel Date: Thu, 8 Oct 2015 16:42:56 +0200 Subject: DO NOT MERGE: libcameraservice: Fix nullptr crash when no client. This change prevents a crash in the camera service when the camera HAL notifies the service about the absence of a removable camera and there happens to be no client connected to the service. It checks that the pointer returned from clientToDisconnect.get() is non-null before trying to dereference it (as is done in existing code immediately below this change). Bug: 25165323 Change-Id: I8055654bac980542e63ea7f52bf897eaafbc09bc Signed-off-by: Tom Keel --- services/camera/libcameraservice/CameraService.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'services/camera') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 2bb282f..3deb396 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -315,8 +315,10 @@ void CameraService::onDeviceStatusChanged(camera_device_status_t cameraId, clientToDisconnect = removeClientLocked(id); // Notify the client of disconnection - clientToDisconnect->notifyError(ICameraDeviceCallbacks::ERROR_CAMERA_DISCONNECTED, - CaptureResultExtras{}); + if (clientToDisconnect != nullptr) { + clientToDisconnect->notifyError(ICameraDeviceCallbacks::ERROR_CAMERA_DISCONNECTED, + CaptureResultExtras{}); + } } ALOGI("%s: Client for camera ID %s evicted due to device status change from HAL", -- cgit v1.1