Program: 198731
Project: 198731
Buggy source:
/** 
 * Generate capture result metadata from the legacy camera request.
 * @param legacyRequest a non-{@code null} legacy request containing the latest parameters
 * @param timestamp the timestamp to use for this result in nanoseconds.
 * @return a {@link CameraMetadataNative} object containing result metadata.
 */
public static CameraMetadataNative convertResultMetadata(LegacyRequest legacyRequest,long timestamp){
  CameraCharacteristics characteristics=legacyRequest.characteristics;
  CaptureRequest request=legacyRequest.captureRequest;
  Size previewSize=legacyRequest.previewSize;
  Camera.Parameters params=legacyRequest.parameters;
  CameraMetadataNative result=new CameraMetadataNative();
  Rect activeArraySize=characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
  ZoomData zoomData=ParameterUtils.convertScalerCropRegion(activeArraySize,request.get(CaptureRequest.SCALER_CROP_REGION),previewSize,params);
  mapAe(result,characteristics,request,activeArraySize,zoomData,params);
  result.set(CaptureResult.CONTROL_AF_MODE,convertLegacyAfMode(params.getFocusMode()));
  result.set(CaptureResult.CONTROL_AWB_LOCK,params.getAutoWhiteBalanceLock());
  if (LegacyMetadataMapper.LIE_ABOUT_AWB_STATE) {
    result.set(CaptureResult.CONTROL_AWB_STATE,CameraMetadata.CONTROL_AWB_STATE_CONVERGED);
  }
  if (LegacyMetadataMapper.LIE_ABOUT_AWB) {
    result.set(CaptureResult.CONTROL_AWB_MODE,request.get(CaptureRequest.CONTROL_AWB_MODE));
  }
{
  }
{
    if (Parameters.FOCUS_MODE_INFINITY.equals(params.getFocusMode())) {
      result.set(CaptureResult.LENS_FOCUS_DISTANCE,0.0f);
    }
  }
  result.set(CaptureResult.LENS_FOCAL_LENGTH,params.getFocalLength());
  mapScaler(result,zoomData,params);
  result.set(CaptureResult.SENSOR_TIMESTAMP,timestamp);
  return result;
}

Fixed version (ground truth):
/** 
 * Generate capture result metadata from the legacy camera request.
 * @param legacyRequest a non-{@code null} legacy request containing the latest parameters
 * @param timestamp the timestamp to use for this result in nanoseconds.
 * @return a {@link CameraMetadataNative} object containing result metadata.
 */
private static CameraMetadataNative convertResultMetadata(LegacyRequest legacyRequest,long timestamp){
  CameraCharacteristics characteristics=legacyRequest.characteristics;
  CaptureRequest request=legacyRequest.captureRequest;
  Size previewSize=legacyRequest.previewSize;
  Camera.Parameters params=legacyRequest.parameters;
  CameraMetadataNative result=new CameraMetadataNative();
  Rect activeArraySize=characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
  ZoomData zoomData=ParameterUtils.convertScalerCropRegion(activeArraySize,request.get(CaptureRequest.SCALER_CROP_REGION),previewSize,params);
  mapAe(result,characteristics,request,activeArraySize,zoomData,params);
  result.set(CaptureResult.CONTROL_AF_MODE,convertLegacyAfMode(params.getFocusMode()));
  result.set(CaptureResult.CONTROL_AWB_LOCK,params.getAutoWhiteBalanceLock());
  if (LegacyMetadataMapper.LIE_ABOUT_AWB_STATE) {
    result.set(CaptureResult.CONTROL_AWB_STATE,CameraMetadata.CONTROL_AWB_STATE_CONVERGED);
  }
  if (LegacyMetadataMapper.LIE_ABOUT_AWB) {
    result.set(CaptureResult.CONTROL_AWB_MODE,request.get(CaptureRequest.CONTROL_AWB_MODE));
  }
{
  }
{
    if (Parameters.FOCUS_MODE_INFINITY.equals(params.getFocusMode())) {
      result.set(CaptureResult.LENS_FOCUS_DISTANCE,0.0f);
    }
  }
  result.set(CaptureResult.LENS_FOCAL_LENGTH,params.getFocalLength());
  result.set(REQUEST_PIPELINE_DEPTH,characteristics.get(CameraCharacteristics.REQUEST_PIPELINE_MAX_DEPTH));
  mapScaler(result,zoomData,params);
  return result;
}