Program: 38216
Project: 38216
Buggy source:
/** 
 * This method does not deal with the API level check.  Everyone should check first for supported operations before sending message to this handler.
 */
@Override public void handleMessage(final Message msg){
  try {
switch (msg.what) {
case OPEN_CAMERA:
      try {
        Method openMethod=Class.forName("String_Node_Str").getMethod("String_Node_Str",int.class,int.class);
        mCamera=(android.hardware.Camera)openMethod.invoke(null,msg.arg1,CAMERA_HAL_API_VERSION_1_0);
      }
 catch (      Exception e) {
        Log.v(TAG,"String_Node_Str" + e.getMessage() + "String_Node_Str");
        mCamera=android.hardware.Camera.open(msg.arg1);
      }
    if (mCamera != null) {
      mParametersIsDirty=true;
      if (mParamsToSet == null) {
        mParamsToSet=mCamera.getParameters();
      }
    }
 else {
      if (msg.obj != null) {
        ((CameraOpenErrorCallback)msg.obj).onDeviceOpenFailure(msg.arg1);
      }
    }
  return;
case RELEASE:
if (mCamera == null) {
  return;
}
mCamera.release();
errorCbInstance=null;
mCamera=null;
return;
case RECONNECT:
mReconnectIOException=null;
try {
mCamera.reconnect();
}
 catch (IOException ex) {
mReconnectIOException=ex;
}
return;
case UNLOCK:
mCamera.unlock();
return;
case LOCK:
mCamera.lock();
return;
case SET_PREVIEW_TEXTURE_ASYNC:
setPreviewTexture(msg.obj);
return;
case SET_PREVIEW_DISPLAY_ASYNC:
try {
mCamera.setPreviewDisplay((SurfaceHolder)msg.obj);
}
 catch (IOException e) {
throw new RuntimeException(e);
}
return;
case START_PREVIEW_ASYNC:
try {
mCamera.startPreview();
}
 catch (Exception e) {
e.printStackTrace();
if (errorCbInstance != null) errorCbInstance.onStartPreviewFailure(msg.arg1);
}
return;
case STOP_PREVIEW:
mCamera.stopPreview();
return;
case SET_PREVIEW_CALLBACK_WITH_BUFFER:
mCamera.setPreviewCallbackWithBuffer((PreviewCallback)msg.obj);
return;
case ADD_CALLBACK_BUFFER:
mCamera.addCallbackBuffer((byte[])msg.obj);
return;
case AUTO_FOCUS:
mCamera.autoFocus((AutoFocusCallback)msg.obj);
return;
case CANCEL_AUTO_FOCUS:
mCamera.cancelAutoFocus();
return;
case SET_AUTO_FOCUS_MOVE_CALLBACK:
setAutoFocusMoveCallback(mCamera,msg.obj);
return;
case SET_DISPLAY_ORIENTATION:
mCamera.setDisplayOrientation(msg.arg1);
return;
case SET_ZOOM_CHANGE_LISTENER:
mCamera.setZoomChangeListener((OnZoomChangeListener)msg.obj);
return;
case SET_FACE_DETECTION_LISTENER:
setFaceDetectionListener((FaceDetectionListener)msg.obj);
return;
case START_FACE_DETECTION:
startFaceDetection();
return;
case STOP_FACE_DETECTION:
stopFaceDetection();
return;
case SET_ERROR_CALLBACK:
mCamera.setErrorCallback((ErrorCallback)msg.obj);
return;
case SET_PARAMETERS:
mParametersIsDirty=true;
mCamera.setParameters((Parameters)msg.obj);
mSig.open();
break;
case GET_PARAMETERS:
if (mParametersIsDirty) {
mParameters=mCamera.getParameters();
mParametersIsDirty=false;
}
return;
case SET_PREVIEW_CALLBACK:
mCamera.setPreviewCallback((PreviewCallback)msg.obj);
return;
case SET_ONESHOT_PREVIEW_CALLBACK:
mCamera.setOneShotPreviewCallback((PreviewCallback)msg.obj);
case ENABLE_SHUTTER_SOUND:
enableShutterSound((msg.arg1 == 1) ? true : false);
return;
case REFRESH_PARAMETERS:
mParametersIsDirty=true;
return;
case SET_HISTOGRAM_MODE:
mCamera.setHistogramMode((CameraDataCallback)msg.obj);
break;
case SEND_HISTOGRAM_DATA:
mCamera.sendHistogramData();
break;
case SET_LONGSHOT:
mCamera.setLongshot((Boolean)msg.obj);
break;
case SET_AUTO_HDR_MODE:
mCamera.setMetadataCb((CameraMetaDataCallback)msg.obj);
break;
default :
throw new RuntimeException("String_Node_Str" + msg.what);
}
}
 catch (RuntimeException e) {
if (msg.what != RELEASE && mCamera != null) {
try {
mCamera.release();
}
 catch (Exception ex) {
Log.e(TAG,"String_Node_Str");
}
mCamera=null;
}
 else if (mCamera == null) {
if (msg.what == OPEN_CAMERA) {
if (msg.obj != null) {
((CameraOpenErrorCallback)msg.obj).onDeviceOpenFailure(msg.arg1);
}
}
 else {
Log.w(TAG,"String_Node_Str");
}
return;
}
throw e;
}
}

Fixed version (ground truth):
/** 
 * This method does not deal with the API level check.  Everyone should check first for supported operations before sending message to this handler.
 */
@Override public void handleMessage(final Message msg){
  try {
switch (msg.what) {
case OPEN_CAMERA:
      try {
        Method openMethod=Class.forName("String_Node_Str").getMethod("String_Node_Str",int.class,int.class);
        mCamera=(android.hardware.Camera)openMethod.invoke(null,msg.arg1,CAMERA_HAL_API_VERSION_1_0);
      }
 catch (      Exception e) {
        Log.v(TAG,"String_Node_Str" + e.getMessage() + "String_Node_Str");
        mCamera=android.hardware.Camera.open(msg.arg1);
      }
    if (mCamera != null) {
      mParametersIsDirty=true;
      if (mParamsToSet == null) {
        mParamsToSet=mCamera.getParameters();
      }
    }
 else {
      if (msg.obj != null) {
        ((CameraOpenErrorCallback)msg.obj).onDeviceOpenFailure(msg.arg1);
      }
    }
  return;
case RELEASE:
if (mCamera == null) {
  return;
}
mCamera.release();
errorCbInstance=null;
mCamera=null;
return;
case RECONNECT:
mReconnectIOException=null;
try {
mCamera.reconnect();
}
 catch (IOException ex) {
mReconnectIOException=ex;
}
return;
case UNLOCK:
mCamera.unlock();
return;
case LOCK:
mCamera.lock();
return;
case SET_PREVIEW_TEXTURE_ASYNC:
setPreviewTexture(msg.obj);
return;
case SET_PREVIEW_DISPLAY_ASYNC:
try {
mCamera.setPreviewDisplay((SurfaceHolder)msg.obj);
}
 catch (IOException e) {
throw new RuntimeException(e);
}
return;
case START_PREVIEW_ASYNC:
try {
mCamera.startPreview();
}
 catch (Exception e) {
e.printStackTrace();
if (errorCbInstance != null) errorCbInstance.onStartPreviewFailure(msg.arg1);
}
return;
case STOP_PREVIEW:
mCamera.stopPreview();
return;
case SET_PREVIEW_CALLBACK_WITH_BUFFER:
mCamera.setPreviewCallbackWithBuffer((PreviewCallback)msg.obj);
return;
case ADD_CALLBACK_BUFFER:
mCamera.addCallbackBuffer((byte[])msg.obj);
return;
case AUTO_FOCUS:
mCamera.autoFocus((AutoFocusCallback)msg.obj);
return;
case CANCEL_AUTO_FOCUS:
mCamera.cancelAutoFocus();
return;
case SET_AUTO_FOCUS_MOVE_CALLBACK:
setAutoFocusMoveCallback(mCamera,msg.obj);
return;
case SET_DISPLAY_ORIENTATION:
mCamera.setDisplayOrientation(msg.arg1);
return;
case SET_ZOOM_CHANGE_LISTENER:
mCamera.setZoomChangeListener((OnZoomChangeListener)msg.obj);
return;
case SET_FACE_DETECTION_LISTENER:
setFaceDetectionListener((FaceDetectionListener)msg.obj);
return;
case START_FACE_DETECTION:
startFaceDetection();
return;
case STOP_FACE_DETECTION:
stopFaceDetection();
return;
case SET_ERROR_CALLBACK:
mCamera.setErrorCallback((ErrorCallback)msg.obj);
return;
case SET_PARAMETERS:
mParametersIsDirty=true;
mCamera.setParameters((Parameters)msg.obj);
mSig.open();
break;
case GET_PARAMETERS:
if (mParametersIsDirty) {
mParameters=mCamera.getParameters();
mParametersIsDirty=false;
}
return;
case SET_PREVIEW_CALLBACK:
mCamera.setPreviewCallback((PreviewCallback)msg.obj);
return;
case SET_ONESHOT_PREVIEW_CALLBACK:
mCamera.setOneShotPreviewCallback((PreviewCallback)msg.obj);
return;
case ENABLE_SHUTTER_SOUND:
enableShutterSound((msg.arg1 == 1) ? true : false);
return;
case REFRESH_PARAMETERS:
mParametersIsDirty=true;
return;
case SET_HISTOGRAM_MODE:
mCamera.setHistogramMode((CameraDataCallback)msg.obj);
break;
case SEND_HISTOGRAM_DATA:
mCamera.sendHistogramData();
break;
case SET_LONGSHOT:
mCamera.setLongshot((Boolean)msg.obj);
break;
case SET_AUTO_HDR_MODE:
mCamera.setMetadataCb((CameraMetaDataCallback)msg.obj);
break;
default :
throw new RuntimeException("String_Node_Str" + msg.what);
}
}
 catch (RuntimeException e) {
if (msg.what != RELEASE && mCamera != null) {
try {
mCamera.release();
}
 catch (Exception ex) {
Log.e(TAG,"String_Node_Str");
}
mCamera=null;
}
 else if (mCamera == null) {
if (msg.what == OPEN_CAMERA) {
if (msg.obj != null) {
((CameraOpenErrorCallback)msg.obj).onDeviceOpenFailure(msg.arg1);
}
}
 else {
Log.w(TAG,"String_Node_Str");
}
return;
}
throw e;
}
}