title: Android Camera2: Auto Focus and Exposure
body: <p>In my Android camera application I'm using the Camera2 API. The application doesn't show the preview of the Camera, and I've implemented it in a way, when a button on the UI is pressed, it takes an image. But the problem is with auto focus and auto exposure. Simply, I need to camera always focused on the middle of its view. So when building the request, I added following properties:</p>
  
  <pre><code>captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO);
  captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
  captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
  captureBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START);
  captureBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CameraMetadata.CONTROL_AE_PRECAPTURE_TRIGGER_START);  
  </code></pre>
  
  <p>But the problem is still the images are not focused. </p>
  
  <p>I have couple of questions:</p>
  
  <p>Do I need to implement some checking in a method inside <code>CameraCaptureSession.CaptureCallback</code>?</p>
  
  <p>I also noticed that by the time <code>onImageAvailable</code> is called in <code>ImageReader.OnImageAvailableListener</code>, the <code>onCaptureProgressed</code> method of <code>CameraCaptureSession.CaptureCallback</code> is not triggered.</p>
  
  <p>What are the points I'm missing here? Do I need to implement a thread to wait until the camera is focused, which will start by when pressing the take picture button.</p>
  
  <p>Please note that there's no camera preview for this application. </p>