Wednesday, May 26, 2021

How to check if Camera2 API is enabled on your Android device

A smartphone’s hardware is often capable of more than just what the software allows by default. This is the exact reason why Google Camera ports have become very popular on our forums, as many see them as an easy way to dramatically improve picture quality on a wide range of devices. With the ported Google Camera app, you can use Google’s superior HDR+ optimization as well as their Portrait Mode on your non-Google device. However, you must have come across a particular term – “Camera2 API” – while reading about these ports. In this tutorial, you’ll learn what the term actually means and how you can check the status of Camera2 API support on your Android phones.

Table of Contents:


What is Camera2 API?

The physical camera module on your phone is an incredibly complex piece of hardware, but Android doesn’t need to know all the low-level parameters to interact with it, thanks to the camera Hardware Abstraction Layer (HAL) implemented by SoC vendors. The camera-specific Application Programming Interface (API) resides on top of the HAL and acts as an app-level public framework. In a nutshell, the Camera API allows apps to probe the camera features on a device in a streamlined manner, without bothering about the nitty-gritty of the camera sensor.

Google introduced the Camera2 API in Android 5.0 Lollipop as a successor to the original Camera API in order to better define how apps can interact with the individual cameras connected to your smartphone. It exposes a number of granular camera controls to the apps, including efficient zero-copy burst/streaming flows and per-frame controls of exposure, gain, white balance gains, color conversion, denoising, sharpening, and more.

There are four different support levels for the Camera2 API:

  • Legacy: Legacy devices that don’t support Camera API2 features such as per-frame controls. These devices expose capabilities to apps through the Camera API2 interfaces that are approximately the same capabilities as those exposed to apps through the Camera API1 interfaces.
  • Limited: These devices support only a subset of all Camera API2 capabilities.
  • Full: These devices support all of the major capabilities of Camera API2 and must use Camera HAL 3.2 or higher and Android 5.0 or higher.
  • Level_3: These devices support YUV reprocessing and RAW image capture, along with additional output stream configurations on top of full Camera2 API support.

As for most users, the reason you all should care about Camera2 API support is that it’s necessary for Google Camera ports to work on your smartphone.


How to check if Camera2 API is enabled

The webpage for the Image Test Suite part of Compatibility Test Suite (CTS) states that Camera HAL3 support with the Camera2 API is strongly recommended for certified devices running Android 9 or higher. With that being said, many devices in the past have lacked Camera2 API support out-of-the-box. To enable the API, some of them require either root to modify their build.prop, or just an unlocked bootloader to run vendor-specific Fastboot commands. More recently though, things have begun to change.

To know the status of the Camera2 API support on your device, choose one of the following methods.

Method 1: Using ADB

Before getting started with this method, make sure that you have access to a PC/Mac with ADB and Fastboot installed.

  1. On your phone, turn on USB debugging from Developer options.
  2. Connect your device to the PC/Mac.
  3. Open up a Command Prompt or PowerShell (Windows) or a terminal window (macOS or Linux).
    • In case the location of the ADB binary isn’t defined in the global PATH settings, you have to change the working directory of the shell to the location where the ADB binary is placed.
  4. Enter the following command:
    adb shell "getprop | grep HAL3"
  5. If the result is one of the following:
    [persist.camera.HAL3.enabled]: [1]
    [persist.vendor.camera.HAL3.enabled]: [1]

    , then your device has Camera HAL3 with full Camera2 API support.

ADB getprop HAL3 query using PowerShell under Windows


Method 2: Using a terminal emulator

If you don’t want to use a PC/Mac, then you can use any terminal emulator app to check the status of the Camera2 API directly from your phone.

  1. Download a terminal emulator app of your choice. We have listed a few popular ones below.
  2. Open the app and enter the following command:
    getprop | grep HAL3
  3. If the result is one of the following:
    [persist.camera.HAL3.enabled]: [1]
    [persist.vendor.camera.HAL3.enabled]: [1]

    , then your device has Camera HAL3 with full Camera2 API support.

getprop HAL3 using a Terminal Emulator

Terminal Emulator for Android (Free, Google Play) →

Termux (Free, F-Droid) →

Keep in mind that having HAL3 support doesn’t mean that all of Camera2 API features are available, as a company could still modify functionality such as RAW capture support, ISO levels, exposure times and more. This is why we recommend to opt for the third method, as it offers more granular information.


Method 3: Using a dedicated third-party app

Don’t want to fiddle with the command line interface? Then just download the Camera2 API Probe app on the target Android device from the Google Play Store.

Camera2 API Probe (Free, Google Play) →

Once installed, the app will show two or more sections depending on the number of camera lenses your device has (e.g. “Camera ID: 0” represents the rear camera module). Under each Camera ID, you can find a sub-category of various features and their support details. We are particularly interested in the category named “Hardware Support Level” which shows the Camera2 API support level on the device.

Camera2 Probe

As you can see, the app not only finds out the exact Camera2 API level for your device, it also lists down several other features that are supported by the camera module. The information may come in handy at the time of installing third-party camera apps like a specific Google Camera port that can utilize these features.


We hope you can now quickly spot whether Camera2 API is enabled or not on your device using this guide. Do let us know your preferred method in the comments!

The post How to check if Camera2 API is enabled on your Android device appeared first on xda-developers.



from xda-developers https://ift.tt/3fpnlJv
via IFTTT

No comments:

Post a Comment