Program: 38117
Project: 38117
Buggy source:
private boolean startRecordingVideo(final int cameraId){
  if (null == mCameraDevice[cameraId]) {
    return false;
  }
  Log.d(TAG,"String_Node_Str" + cameraId);
  mStartRecPending=true;
  mIsRecordingVideo=true;
  mMediaRecorderPausing=false;
  mUI.hideUIwhileRecording();
  mActivity.updateStorageSpaceAndHint();
  if (mActivity.getStorageSpaceBytes() <= Storage.LOW_STORAGE_THRESHOLD_BYTES) {
    Log.w(TAG,"String_Node_Str");
    mStartRecPending=false;
    mIsRecordingVideo=false;
    return false;
  }
  try {
    setUpMediaRecorder(cameraId);
    if (mUnsupportedResolution == true) {
      Log.v(TAG,"String_Node_Str");
      mStartRecPending=false;
      mIsRecordingVideo=false;
      return false;
    }
    if (mMediaRecorder == null) {
      Log.e(TAG,"String_Node_Str");
      mStartRecPending=false;
      mIsRecordingVideo=false;
      return false;
    }
    requestAudioFocus();
    mUI.clearFocus();
    mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS,mCameraId[cameraId]);
    mState[cameraId]=STATE_PREVIEW;
    mControlAFMode=CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
    closePreviewSession();
    mFrameProcessor.onClose();
    Size preview=mVideoPreviewSize;
    if (mHighSpeedCapture) {
      preview=mVideoSize;
    }
    boolean changed=mUI.setPreviewSize(preview.getWidth(),preview.getHeight());
    if (changed) {
      mUI.hideSurfaceView();
      mUI.showSurfaceView();
    }
    mUI.resetTrackingFocus();
    createVideoSnapshotImageReader();
    mVideoRequestBuilder=mCameraDevice[cameraId].createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
    mVideoRequestBuilder.setTag(cameraId);
    mPreviewRequestBuilder[cameraId]=mVideoRequestBuilder;
    List<Surface> surfaces=new ArrayList<>();
    Surface surface=getPreviewSurfaceForSession(cameraId);
    mFrameProcessor.onOpen(getFrameProcFilterId(),mVideoSize);
    if (mFrameProcessor.isFrameFilterEnabled()) {
      mActivity.runOnUiThread(new Runnable(){
        public void run(){
          mUI.getSurfaceHolder().setFixedSize(mVideoSize.getHeight(),mVideoSize.getWidth());
        }
      }
);
    }
    mFrameProcessor.setOutputSurface(surface);
    mFrameProcessor.setVideoOutputSurface(mMediaRecorder.getSurface());
    addPreviewSurface(mVideoRequestBuilder,surfaces,cameraId);
    if (mHighSpeedCapture)     mVideoRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE,mHighSpeedFPSRange);
    if (mHighSpeedCapture && ((int)mHighSpeedFPSRange.getUpper() > NORMAL_SESSION_MAX_FPS)) {
      mCameraDevice[cameraId].createConstrainedHighSpeedCaptureSession(surfaces,new CameraConstrainedHighSpeedCaptureSession.StateCallback(){
        @Override public void onConfigured(        CameraCaptureSession cameraCaptureSession){
          mCurrentSession=cameraCaptureSession;
          mCaptureSession[cameraId]=cameraCaptureSession;
          CameraConstrainedHighSpeedCaptureSession session=(CameraConstrainedHighSpeedCaptureSession)mCurrentSession;
          try {
            List list=CameraUtil.createHighSpeedRequestList(mVideoRequestBuilder.build(),cameraId);
            session.setRepeatingBurst(list,mCaptureCallback,mCameraHandler);
          }
 catch (          CameraAccessException e) {
            Log.e(TAG,"String_Node_Str" + e.getMessage());
            e.printStackTrace();
          }
catch (          IllegalArgumentException e) {
            Log.e(TAG,"String_Node_Str" + e.getMessage());
            e.printStackTrace();
          }
catch (          IllegalStateException e) {
            Log.e(TAG,"String_Node_Str" + e.getMessage());
            e.printStackTrace();
          }
          try {
            mMediaRecorder.start();
          }
 catch (          RuntimeException e) {
            Toast.makeText(mActivity,"String_Node_Str" + "String_Node_Str",Toast.LENGTH_LONG).show();
            releaseMediaRecorder();
            releaseAudioFocus();
            mStartRecPending=false;
            mIsRecordingVideo=false;
            return;
          }
          mUI.clearFocus();
          mUI.resetPauseButton();
          mRecordingTotalTime=0L;
          mRecordingStartTime=SystemClock.uptimeMillis();
          mUI.enableShutter(false);
          mUI.showRecordingUI(true,true);
          updateRecordingTime();
          keepScreenOn();
        }
        @Override public void onConfigureFailed(        CameraCaptureSession cameraCaptureSession){
          Toast.makeText(mActivity,"String_Node_Str",Toast.LENGTH_SHORT).show();
        }
      }
,null);
    }
 else {
      surfaces.add(mVideoSnapshotImageReader.getSurface());
      mCameraDevice[cameraId].createCaptureSession(surfaces,new CameraCaptureSession.StateCallback(){
        @Override public void onConfigured(        CameraCaptureSession cameraCaptureSession){
          Log.d(TAG,"String_Node_Str");
          mCurrentSession=cameraCaptureSession;
          mCaptureSession[cameraId]=cameraCaptureSession;
          try {
            setUpVideoCaptureRequestBuilder(mVideoRequestBuilder,cameraId);
            mCurrentSession.setRepeatingRequest(mVideoRequestBuilder.build(),mCaptureCallback,mCameraHandler);
          }
 catch (          CameraAccessException e) {
            e.printStackTrace();
          }
catch (          IllegalStateException e) {
            e.printStackTrace();
          }
          try {
            mMediaRecorder.start();
          }
 catch (          RuntimeException e) {
            Toast.makeText(mActivity,"String_Node_Str" + "String_Node_Str",Toast.LENGTH_LONG).show();
            releaseMediaRecorder();
            releaseAudioFocus();
            mStartRecPending=false;
            mIsRecordingVideo=false;
            return;
          }
          mUI.clearFocus();
          mUI.resetPauseButton();
          mRecordingTotalTime=0L;
          mRecordingStartTime=SystemClock.uptimeMillis();
          mUI.showRecordingUI(true,false);
          updateRecordingTime();
          keepScreenOn();
        }
        @Override public void onConfigureFailed(        CameraCaptureSession cameraCaptureSession){
          Toast.makeText(mActivity,"String_Node_Str",Toast.LENGTH_SHORT).show();
        }
      }
,null);
    }
  }
 catch (  CameraAccessException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  mStartRecPending=false;
  return true;
}

Fixed version (ground truth):
private boolean startRecordingVideo(final int cameraId){
  if (null == mCameraDevice[cameraId]) {
    return false;
  }
  Log.d(TAG,"String_Node_Str" + cameraId);
  mStartRecPending=true;
  mIsRecordingVideo=true;
  mMediaRecorderPausing=false;
  mActivity.updateStorageSpaceAndHint();
  if (mActivity.getStorageSpaceBytes() <= Storage.LOW_STORAGE_THRESHOLD_BYTES) {
    Log.w(TAG,"String_Node_Str");
    mStartRecPending=false;
    mIsRecordingVideo=false;
    return false;
  }
  try {
    setUpMediaRecorder(cameraId);
    try {
      mMediaRecorder.start();
    }
 catch (    RuntimeException e) {
      Toast.makeText(mActivity,"String_Node_Str" + "String_Node_Str",Toast.LENGTH_LONG).show();
      releaseMediaRecorder();
      releaseAudioFocus();
      mStartRecPending=false;
      mIsRecordingVideo=false;
      return false;
    }
    if (mUnsupportedResolution == true) {
      Log.v(TAG,"String_Node_Str");
      mStartRecPending=false;
      mIsRecordingVideo=false;
      return false;
    }
    if (mMediaRecorder == null) {
      Log.e(TAG,"String_Node_Str");
      mStartRecPending=false;
      mIsRecordingVideo=false;
      return false;
    }
    requestAudioFocus();
    mUI.clearFocus();
    mUI.hideUIwhileRecording();
    mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS,mCameraId[cameraId]);
    mState[cameraId]=STATE_PREVIEW;
    mControlAFMode=CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
    closePreviewSession();
    mFrameProcessor.onClose();
    Size preview=mVideoPreviewSize;
    if (mHighSpeedCapture) {
      preview=mVideoSize;
    }
    boolean changed=mUI.setPreviewSize(preview.getWidth(),preview.getHeight());
    if (changed) {
      mUI.hideSurfaceView();
      mUI.showSurfaceView();
    }
    mUI.resetTrackingFocus();
    createVideoSnapshotImageReader();
    mVideoRequestBuilder=mCameraDevice[cameraId].createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
    mVideoRequestBuilder.setTag(cameraId);
    mPreviewRequestBuilder[cameraId]=mVideoRequestBuilder;
    List<Surface> surfaces=new ArrayList<>();
    Surface surface=getPreviewSurfaceForSession(cameraId);
    mFrameProcessor.onOpen(getFrameProcFilterId(),mVideoSize);
    if (mFrameProcessor.isFrameFilterEnabled()) {
      mActivity.runOnUiThread(new Runnable(){
        public void run(){
          mUI.getSurfaceHolder().setFixedSize(mVideoSize.getHeight(),mVideoSize.getWidth());
        }
      }
);
    }
    mFrameProcessor.setOutputSurface(surface);
    mFrameProcessor.setVideoOutputSurface(mMediaRecorder.getSurface());
    addPreviewSurface(mVideoRequestBuilder,surfaces,cameraId);
    if (mHighSpeedCapture)     mVideoRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE,mHighSpeedFPSRange);
    if (mHighSpeedCapture && ((int)mHighSpeedFPSRange.getUpper() > NORMAL_SESSION_MAX_FPS)) {
      mCameraDevice[cameraId].createConstrainedHighSpeedCaptureSession(surfaces,new CameraConstrainedHighSpeedCaptureSession.StateCallback(){
        @Override public void onConfigured(        CameraCaptureSession cameraCaptureSession){
          mCurrentSession=cameraCaptureSession;
          mCaptureSession[cameraId]=cameraCaptureSession;
          CameraConstrainedHighSpeedCaptureSession session=(CameraConstrainedHighSpeedCaptureSession)mCurrentSession;
          try {
            List list=CameraUtil.createHighSpeedRequestList(mVideoRequestBuilder.build(),cameraId);
            session.setRepeatingBurst(list,mCaptureCallback,mCameraHandler);
          }
 catch (          CameraAccessException e) {
            Log.e(TAG,"String_Node_Str" + e.getMessage());
            e.printStackTrace();
          }
catch (          IllegalArgumentException e) {
            Log.e(TAG,"String_Node_Str" + e.getMessage());
            e.printStackTrace();
          }
catch (          IllegalStateException e) {
            Log.e(TAG,"String_Node_Str" + e.getMessage());
            e.printStackTrace();
          }
          mUI.clearFocus();
          mUI.resetPauseButton();
          mRecordingTotalTime=0L;
          mRecordingStartTime=SystemClock.uptimeMillis();
          mUI.enableShutter(false);
          mUI.showRecordingUI(true,true);
          updateRecordingTime();
          keepScreenOn();
        }
        @Override public void onConfigureFailed(        CameraCaptureSession cameraCaptureSession){
          Toast.makeText(mActivity,"String_Node_Str",Toast.LENGTH_SHORT).show();
        }
      }
,null);
    }
 else {
      surfaces.add(mVideoSnapshotImageReader.getSurface());
      mCameraDevice[cameraId].createCaptureSession(surfaces,new CameraCaptureSession.StateCallback(){
        @Override public void onConfigured(        CameraCaptureSession cameraCaptureSession){
          Log.d(TAG,"String_Node_Str");
          mCurrentSession=cameraCaptureSession;
          mCaptureSession[cameraId]=cameraCaptureSession;
          try {
            setUpVideoCaptureRequestBuilder(mVideoRequestBuilder,cameraId);
            mCurrentSession.setRepeatingRequest(mVideoRequestBuilder.build(),mCaptureCallback,mCameraHandler);
          }
 catch (          CameraAccessException e) {
            e.printStackTrace();
          }
catch (          IllegalStateException e) {
            e.printStackTrace();
          }
          mUI.clearFocus();
          mUI.resetPauseButton();
          mRecordingTotalTime=0L;
          mRecordingStartTime=SystemClock.uptimeMillis();
          mUI.showRecordingUI(true,false);
          updateRecordingTime();
          keepScreenOn();
        }
        @Override public void onConfigureFailed(        CameraCaptureSession cameraCaptureSession){
          Toast.makeText(mActivity,"String_Node_Str",Toast.LENGTH_SHORT).show();
        }
      }
,null);
    }
  }
 catch (  CameraAccessException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  mStartRecPending=false;
  return true;
}