From f90319b0d26d9dd1a6e0cf5a6e801adc300eb645 Mon Sep 17 00:00:00 2001 From: mingwax Date: Thu, 13 Jul 2017 15:22:44 +0800 Subject: SnapdragonCamera: Fix FC when mediarecorder start occur error MediaRecorder.start method should be before the hideUIwhileRecording. Adjust the logic for starting video. CRs-Fixed: 2072609 Change-Id: Ie48f8ebc4bfe3385604d4095d8ff02029c26968b --- src/com/android/camera/CaptureModule.java | 35 +++++++++++-------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'src/com/android/camera/CaptureModule.java') diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index d61163919..6b9c6869e 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -3116,7 +3116,6 @@ public class CaptureModule implements CameraModule, PhotoController, mStartRecPending = true; mIsRecordingVideo = true; mMediaRecorderPausing = false; - mUI.hideUIwhileRecording(); mActivity.updateStorageSpaceAndHint(); if (mActivity.getStorageSpaceBytes() <= Storage.LOW_STORAGE_THRESHOLD_BYTES) { @@ -3128,6 +3127,17 @@ public class CaptureModule implements CameraModule, PhotoController, try { setUpMediaRecorder(cameraId); + try { + mMediaRecorder.start(); // Recording is now started + } catch (RuntimeException e) { + Toast.makeText(mActivity,"Could not start media recorder.\n " + + "Can't start video recording.", Toast.LENGTH_LONG).show(); + releaseMediaRecorder(); + releaseAudioFocus(); + mStartRecPending = false; + mIsRecordingVideo = false; + return false; + } if (mUnsupportedResolution == true ) { Log.v(TAG, "Unsupported Resolution according to target"); mStartRecPending = false; @@ -3143,6 +3153,7 @@ public class CaptureModule implements CameraModule, PhotoController, requestAudioFocus(); mUI.clearFocus(); + mUI.hideUIwhileRecording(); mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[cameraId]); mState[cameraId] = STATE_PREVIEW; mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE; @@ -3210,17 +3221,6 @@ public class CaptureModule implements CameraModule, PhotoController, + e.getMessage()); e.printStackTrace(); } - try { - mMediaRecorder.start(); // Recording is now started - } catch (RuntimeException e) { - Toast.makeText(mActivity,"Could not start media recorder.\n " + - "Can't start video recording.", Toast.LENGTH_LONG).show(); - releaseMediaRecorder(); - releaseAudioFocus(); - mStartRecPending = false; - mIsRecordingVideo = false; - return; - } mUI.clearFocus(); mUI.resetPauseButton(); mRecordingTotalTime = 0L; @@ -3255,17 +3255,6 @@ public class CaptureModule implements CameraModule, PhotoController, } catch (IllegalStateException e) { e.printStackTrace(); } - try { - mMediaRecorder.start(); // Recording is now started - } catch (RuntimeException e) { - Toast.makeText(mActivity,"Could not start media recorder.\n " + - "Can't start video recording.", Toast.LENGTH_LONG).show(); - releaseMediaRecorder(); - releaseAudioFocus(); - mStartRecPending = false; - mIsRecordingVideo = false; - return; - } mUI.clearFocus(); mUI.resetPauseButton(); mRecordingTotalTime = 0L; -- cgit v1.2.3