@Override
  public void onStart() {
    mState = STATE_IDLE;
    updateFocusUI();

    CameraController.setFocusState(CameraController.FOCUS_STATE_IDLE);
  }
  private void cancelAutoFocus() {
    Log.e(TAG, "cancelAutofocus");
    // Note: CameraController.getFocusMode(); will return
    // 'FOCUS_MODE_AUTO' if actual
    // mode is in fact FOCUS_MODE_CONTINUOUS_PICTURE or
    // FOCUS_MODE_CONTINUOUS_VIDEO
    int fm = CameraController.getFocusMode();
    if (fm != CameraParameters.AF_MODE_UNSUPPORTED) {
      if (fm != preferenceFocusMode && preferenceFocusMode != CameraParameters.MF_MODE) {
        CameraController.cancelAutoFocus();
        CameraController.setCameraFocusMode(preferenceFocusMode);
      }
    }

    // Reset the tap area before calling mListener.cancelAutofocus.
    // Otherwise, focus mode stays at auto and the tap area passed to the
    // driver is not reset.
    CameraController.setCameraFocusAreas(null);
    ApplicationScreen.instance.setCameraMeteringMode(ApplicationScreen.getMeteringMode());
    resetTouchFocus();

    mState = STATE_IDLE;
    CameraController.setFocusState(CameraController.FOCUS_STATE_IDLE);

    updateFocusUI();
    mHandler.removeMessages(RESET_TOUCH_FOCUS);
  }
  public void onPreviewStopped() {
    mState = STATE_IDLE;
    resetTouchFocus();
    // If auto focus was in progress, it would have been canceled.
    updateFocusUI();

    CameraController.setFocusState(CameraController.FOCUS_STATE_IDLE);
  }
  @Override
  public void onStop() {
    // cancelAutoFocus();
    mState = STATE_INACTIVE;
    updateFocusUI();

    CameraController.setFocusState(CameraController.FOCUS_STATE_IDLE);

    ApplicationScreen.getGUIManager().removeViews(focusLayout, R.id.specialPluginsLayout);
  }
 public void onPreviewStarted() {
   mState = STATE_IDLE;
   CameraController.setFocusState(CameraController.FOCUS_STATE_IDLE);
 }