docs: private void openCamera(int desiredWidth, int desiredHeight, int requestedCameraType) {
          // There's a confusing conflation of Camera index in Camera.open(i)
          // with Camera.getCameraInfo().facing values. However the API specifies that Camera.open(0)
          // will always be a rear-facing camera, and CAMERA_FACING_BACK = 0.
          if (mCamera != null) {
              throw new RuntimeException("camera already initialized");
          }
  
          Camera.CameraInfo info = new Camera.CameraInfo();
  
          // Try to find a front-facing camera (e.g. for videoconferencing).
          int numCameras = Camera.getNumberOfCameras();
          int targetCameraType = requestedCameraType;
          boolean triedAllCameras = false;
          cameraLoop:
          while (!triedAllCameras) {
              for (int i = 0; i < numCameras; i++) {
                  Camera.getCameraInfo(i, info);
                  if (info.facing == targetCameraType) {
                      mCamera = Camera.open(i);
                      mCurrentCamera = targetCameraType;
                      break cameraLoop;
                  }
              }
              if (mCamera == null) {
                  if (targetCameraType == requestedCameraType)
                      targetCameraType = (requestedCameraType == Camera.CameraInfo.CAMERA_FACING_BACK ? Camera.CameraInfo.CAMERA_FACING_FRONT : Camera.CameraInfo.CAMERA_FACING_BACK);
                  else
                      triedAllCameras = true;
              }
  
          }
  
          if (mCamera == null) {
              mCurrentCamera = -1;
              throw new RuntimeException("Unable to open camera");
          }
  
          Camera.Parameters parms = mCamera.getParameters();
  
          postCameraOpenedEvent(parms);
  
          List<String> focusModes = parms.getSupportedFocusModes();
          if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
              parms.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
          } else if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
              parms.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
          } else {
              if (VERBOSE) Log.i(TAG, "Camera does not support autofocus");
          }
  
          List<String> flashModes = parms.getSupportedFlashModes();
          String flashMode = (mDesiredFlash != null) ? mDesiredFlash : mCurrentFlash;
          if (isValidFlashMode(flashModes, flashMode)) {
              parms.setFlashMode(flashMode);
          }
  
          parms.setRecordingHint(true);
  
          List<int[]> fpsRanges = parms.getSupportedPreviewFpsRange();
          int[] maxFpsRange = null;
          // Get the maximum supported fps not to exceed 30
          for (int x = fpsRanges.size() - 1; x >= 0; x--) {
              maxFpsRange = fpsRanges.get(x);
              if (maxFpsRange[1] / 1000.0 <= 30) break;
          }
          if (maxFpsRange != null) {
              parms.setPreviewFpsRange(maxFpsRange[0], maxFpsRange[1]);
          }
  
          choosePreviewSize(parms, desiredWidth, desiredHeight);
          // leave the frame rate set to default
          mCamera.setParameters(parms);
  
          int[] fpsRange = new int[2];
          Camera.Size mCameraPreviewSize = parms.getPreviewSize();
          parms.getPreviewFpsRange(fpsRange);
          String previewFacts = mCameraPreviewSize.width + "x" + mCameraPreviewSize.height;
          if (fpsRange[0] == fpsRange[1]) {
              previewFacts += " @" + (fpsRange[0] / 1000.0) + "fps";
          } else {
              previewFacts += " @" + (fpsRange[0] / 1000.0) + " - " + (fpsRange[1] / 1000.0) + "fps";
          }
          if (VERBOSE) Log.i(TAG, "Camera preview set: " + previewFacts);
      }