@Override public void run() throws InterruptedException, CameraAccessException, CameraCaptureSessionClosedException, ResourceAcquisitionFailedException {
  FrameServer.Session session=mFrameServer.tryCreateExclusiveSession();
  if (session == null) {
    return;
  }
  try {
    AFTriggerResult afScanResult=new AFTriggerResult();
    RequestBuilder idleBuilder=createAFIdleRequest(null);
    session.submitRequest(Arrays.asList(idleBuilder.build()),FrameServer.RequestType.REPEATING);
    RequestBuilder cancelBuilder=createAFCancelRequest(null);
    session.submitRequest(Arrays.asList(cancelBuilder.build()),FrameServer.RequestType.NON_REPEATING);
    idleBuilder=createAFIdleRequest(afScanResult);
    session.submitRequest(Arrays.asList(idleBuilder.build()),FrameServer.RequestType.REPEATING);
    RequestBuilder triggerBuilder=createAFTriggerRequest(afScanResult);
    session.submitRequest(Arrays.asList(triggerBuilder.build()),FrameServer.RequestType.NON_REPEATING);
    afScanResult.get();
  }
  finally {
    session.close();
  }
}

@ Override public void run ( ) throws InterruptedException , CameraAccessException , CameraCaptureSessionClosedException , ResourceAcquisitionFailedException { FrameServer . Session session = mFrameServer . tryCreateExclusiveSession ( ) ; if ( session == null ) { return ; } try { AFTriggerResult afScanResult = new AFTriggerResult ( ) ; RequestBuilder idleBuilder = createAFIdleRequest ( null ) ; session . submitRequest ( Arrays . asList ( idleBuilder . build ( ) ) , FrameServer . RequestType . REPEATING ) ; RequestBuilder cancelBuilder = createAFCancelRequest ( null ) ; session . submitRequest ( Arrays . asList ( cancelBuilder . build ( ) ) , FrameServer . RequestType . NON_REPEATING ) ; idleBuilder = createAFIdleRequest ( afScanResult ) ; session . submitRequest ( Arrays . asList ( idleBuilder . build ( ) ) , FrameServer . RequestType . REPEATING ) ; RequestBuilder triggerBuilder = createAFTriggerRequest ( afScanResult ) ; session . submitRequest ( Arrays . asList ( triggerBuilder . build ( ) ) , FrameServer . RequestType . NON_REPEATING ) ; afScanResult . get ( ) ; } finally { session . close ( ) ; } }
performs an auto - focus scan , blocking until the scan starts , runs , and completes .
