I’m building an Android Camera2 app and I absolutely need the Camera to run at 60 FPS.

Many Samsung phones advertise that their Cameras to support 60 FPS through the Camera Devices API:

fun getMaxFps(cameraId): Int {
  val characteristics = cameraManager.getCameraCharacteristics(cameraId)
  val config = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)!!
  val frameDuration = config.getOutputMinFrameDuration(format, size)
  val maxFps = (1.0 / (frameDuration.toDouble() / 1_000_000_000)).toInt()
  //  ^ 60 FPS on most phones
  return maxFps

Unfortunately, Samsung has vendor-locked 60 FPS for third party apps so when you try to create a Camera Session that streams at the advertised 60 FPS it just shows a black-screen:

val captureRequest = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW)
captureRequest.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, Range(60, 60))

The insane thing about this is that this doesn’t even throw an error, it just silently fails and shows a blackscreen. Quite a fun surprise in production.

Since I absolutely need 60 FPS, I was wondering if there was any way around that vendor lock without requiring a rooted phone.

I’m happy to use the C++/NDK Camera2 API or even Samsung specific APIs if required.