Android 14 Adds Support for Using Smartphones as Webcams

Mishaal Rahman
|
Try Esper for Free
MDM Solutions for Android and iOS

Video conferencing platforms like Zoom and Google Meet exploded in popularity during the COVID era, but the webcam market struggled to keep up. The best webcams were hard to get or were too expensive, causing most people to turn to cheaper, more readily available webcams or their laptop’s integrated webcam. The camera in most smartphones offers significantly better image quality than the one found in the vast majority of webcams, though, so many people installed third-party software on their phones to turn them into webcams. Starting in Android 14, it may not be necessary to use a third-party app to turn your smartphone into a webcam for your PC, as that functionality is getting baked into the Android OS itself — though there’s a catch.

When you plug an Android phone into a PC, you have the option to change the USB mode between file transfer/Android Auto (MTP), USB tethering (NCM), MIDI, or PTP. In Android 14, however, a new option can appear in USB Preferences: USB webcam. Selecting this option switches the USB mode to UVC (USB Video Class), provided the device supports it, turning your Android device into a standard USB webcam that other devices will recognize, including Windows, macOS, and Linux PCs, and possibly even other Android devices.

Android USB Preferences screen

Webcam support in Android 14 is not enabled out of the box, however. In order to enable it, four things are required: a Linux kernel config needs to be enabled, the UVC device needs to be configured, the USB HAL needs to be updated, and a new system app needs to be preloaded. 

Kernel config

The Linux kernel config (CONFIG_USB_CONFIGFS_F_UVC) is necessary so that the Android device can be mounted as a UVC gadget. Fortunately, many devices upgrading to and nearly all devices launching with Android 14 will have a kernel with this config enabled. This is because it is enabled by default on Generic Kernel Image (GKI) versions starting from android12-5.10 and later, and devices launching with Android 12 or later on top of Linux kernel version 5.10 or higher are required to ship the GKI kernel.

Because major kernel version upgrades are rare in the Android space and since the Google Requirements Freeze (GRF) program allows for older vendor implementations to still be certifiable, some devices upgrading to Android 14 won’t have kernels that support the USB webcam function. It’s hard to put together a list of such devices, so the best way to tell if your device is capable is to check its kernel version and whether the config is enabled.

To check your device’s kernel version, run:

adb shell “cat /proc/version”

However, to actually verify that the kernel config is enabled, it’s necessary to run another command to see if “CONFIG_USB_CONFIGFS_F_UVC” appears in config.gz, a compressed copy of the configuration file used to build the kernel on the device.

adb shell "zcat /proc/config.gz | grep 'CONFIG_USB_CONFIGFS_F_UVC'"

For example, here is the output from a Galaxy Z Fold 5 running Android 13. Since it is using the android13-5.15 GKI and since “CONFIG_USB_CONFIGFS_F_UVC=y”, it should be capable of supporting the USB webcam feature once it’s upgraded to Android 14. That’s assuming, though, that the device meets the other prerequisites I mentioned before.

ADB code

Webcam Service app

Within the Android 14 QPR1 beta for select Pixel devices is a new system app called “Webcam Service” (com.android.deviceaswebcam). This app relies on a shared library named libjni_deviceAsWebcam.so. This app and library are set to be included as part of Android 14’s upcoming source code release.

The Webcam Service app implements the “DeviceAsWebcam” service that I previously reported would “[turn] an Android device into a webcam.” The service forwards camera frames to a /dev/video node that host devices can read from. SELinux policy dictates that only processes in the device_as_webcam domain, ie. only the Webcam Service system app, can access the /dev/video nodes. Thus, only the device maker and not any third-party can actually take advantage of Android 14’s native USB webcam support.

How does the Webcam Service app actually know when to start forwarding camera frames? When the new “USB webcam” option in “USB Preferences” is toggled, the system broadcasts the android.hardware.usb.action.USB_STATE intent with the “connected” and “uvc” intent extras. Webcam Service has a receiver for this intent, which starts the system service if the “uvc” intent extra is set to “true” and the framework method android.hardware.usb#isUvcSupportEnabled() returns true.

The method isUvcSupportEnabled() returns true when the system property “ro.usb.uvc.enabled” is set to true. This property must be set by the OEM at build time, and if it is not set, then “USB Preferences” won’t show the “USB webcam” option and Webcam Service won’t start. This property is only readable by system apps like Settings and the Webcam Service app.

When the Webcam Service starts, a new notification is posted that lets the user configure the webcam. Tapping the notification opens a camera preview where the user can zoom in or out or change lenses. Under the hood, the Webcam Service app starts a foreground service to ensure it is kept alive by the system. It uses the Camera2 API and supports streaming at either 720p (1280x720) or 1080p (1920x1080p) resolutions. The webcam device appears on the connected host as “Android Webcam”.

Android screens with notifications and camera

ConfigFS and USB HAL

The exact encoding method, video parameters, and name displayed to the host depends on how the device maker sets up the UVC gadget using configfs. For example, on the Tensor-powered Pixel devices, Google’s UVC gadget function configuration can be found in the init.gs[101|201].usb.rc file located in /vendor/etc/init/hw.

Config code

In addition, the device needs an updated USB HAL so that Android is able to switch USB modes to UVC when the option is selected in Settings. Due to the aforementioned GRF program, however, it’s likely that many devices upgrading to Android 14 won’t receive an updated USB HAL, meaning this feature won’t work.

Conclusion

It’s good to see Google implement native USB webcam functionality into Android. Assuming that the Webcam Service app will be available in AOSP as we expect, that means this feature can be picked up by any device maker that wishes to implement webcam functionality. Many will call this feature a clone of Apple’s “Continuity Camera”, but it’s worth noting that Android’s version works with multiple platforms. Any phone running Android 14 that meets the requirements mentioned in this article can be turned into a standard USB webcam that works with any PC, and that’s a big deal.

If you are looking for a tool to manage Android devices, give us at Esper a shout. To get an overview of mobile device management tools, check out our guide: 

Everything You Need to Know about MDM

FAQ

No items found.
No items found.
Mishaal Rahman
Mishaal Rahman

Mishaal Rahman is a Technical Editor at Esper. He has been an Android user for over a decade and has been at the forefront of Android news coverage for half a decade. His in-depth breakdowns of new Android versions have been referenced across the Internet.

Mishaal Rahman
Learn about Esper mobile device management software for Android and iOS
Featured resource
Read more
Featured resource
Considerations for Building Android Apps for Company-Owned Devices
Your app delivers your customer (or employee) experience, making it a crucial piece of your overall solution. Use this guide to understand the considerations of designing and building your perfect app for dedicated device use cases on Android hardware.
Download the Guide

Esper is Modern Device Management

For tablets, smartphones, kiosks, point of sale, IoT, and other Android and iOS edge devices.
MDM Solutions