/**
   * **************************************************
   * SurfaceHolder.Callback,Camera.PreviewCallback
   * **************************************************
   */
  @Override
  public void surfaceCreated(SurfaceHolder holder) {
    try {
      // Indicate camera, our View dimensions
      mCameraManager.openDriver(holder, this.getWidth(), this.getHeight());
    } catch (IOException e) {
      Log.w(TAG, "Can not openDriver: " + e.getMessage());
      mCameraManager.closeDriver();
    }

    try {
      mQRCodeReader = new QRCodeReader();
      mCameraManager.startPreview();
    } catch (Exception e) {
      Log.e(TAG, "Exception: " + e.getMessage());
      mCameraManager.closeDriver();
    }
  }
  @Override
  public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    Log.d(TAG, "surfaceChanged");

    if (mHolder.getSurface() == null) {
      Log.e(TAG, "Error: preview surface does not exist");
      return;
    }

    // preview_width = width;
    // preview_height = height;

    mPreviewWidth = mCameraManager.getPreviewSize().x;
    mPreviewHeight = mCameraManager.getPreviewSize().y;

    mCameraManager.stopPreview();
    mCameraManager.getCamera().setPreviewCallback(this);
    mCameraManager.getCamera().setDisplayOrientation(90); // Portrait mode

    mCameraManager.startPreview();
  }