private void process()

in packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/CameraCaptureCallback.java [71:145]


  private void process(CaptureResult result) {
    Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
    Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);

    // Update capture properties
    if (result instanceof TotalCaptureResult) {
      Float lensAperture = result.get(CaptureResult.LENS_APERTURE);
      Long sensorExposureTime = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
      Integer sensorSensitivity = result.get(CaptureResult.SENSOR_SENSITIVITY);
      this.captureProps.setLastLensAperture(lensAperture);
      this.captureProps.setLastSensorExposureTime(sensorExposureTime);
      this.captureProps.setLastSensorSensitivity(sensorSensitivity);
    }

    if (cameraState != CameraState.STATE_PREVIEW) {
      Log.d(
          TAG,
          "CameraCaptureCallback | state: "
              + cameraState
              + " | afState: "
              + afState
              + " | aeState: "
              + aeState);
    }

    switch (cameraState) {
      case STATE_PREVIEW:
        {
          // We have nothing to do when the camera preview is working normally.
          break;
        }
      case STATE_WAITING_FOCUS:
        {
          if (afState == null) {
            return;
          } else if (afState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED
              || afState == CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) {
            handleWaitingFocusState(aeState);
          } else if (captureTimeouts.getPreCaptureFocusing().getIsExpired()) {
            Log.w(TAG, "Focus timeout, moving on with capture");
            handleWaitingFocusState(aeState);
          }

          break;
        }
      case STATE_WAITING_PRECAPTURE_START:
        {
          // CONTROL_AE_STATE can be null on some devices
          if (aeState == null
              || aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED
              || aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE
              || aeState == CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED) {
            setCameraState(CameraState.STATE_WAITING_PRECAPTURE_DONE);
          } else if (captureTimeouts.getPreCaptureMetering().getIsExpired()) {
            Log.w(TAG, "Metering timeout waiting for pre-capture to start, moving on with capture");

            setCameraState(CameraState.STATE_WAITING_PRECAPTURE_DONE);
          }
          break;
        }
      case STATE_WAITING_PRECAPTURE_DONE:
        {
          // CONTROL_AE_STATE can be null on some devices
          if (aeState == null || aeState != CaptureResult.CONTROL_AE_STATE_PRECAPTURE) {
            cameraStateListener.onConverged();
          } else if (captureTimeouts.getPreCaptureMetering().getIsExpired()) {
            Log.w(
                TAG, "Metering timeout waiting for pre-capture to finish, moving on with capture");
            cameraStateListener.onConverged();
          }

          break;
        }
    }
  }