Android 10 or higher includes several updatable media components that enable updating framework components through Google Play Store infrastructure or through a partner-provided over-the-air (OTA) mechanism. Media components are packaged together in modules that allows providing security updates and feature updates without requiring a full system image update.
Updatable media components exist in the following modules.
Media. This module includes media extractors,
Media Codecs. This module includes updatable software Codec2 components.
MediaProvider. This module optimizes indexed metadata (audio, video, and images from SD cards and USB devices) and makes that data available to apps through the MediaStore public APIs.
For details on adding custom extractors and decoders, see Customizing Media Components.
In Android 9 and lower, extracters are compiled into a single
libstagefright.so file. In Android 10 or higher,
media extractors are separate components. Each extractor has its own
with an entry point that provides a sniffer function to determine whether the
extractor can handle the given media file, and a factory function that creates
an instance of the extractor for the given media file. Each extractor is named
(to help in debugging) and versioned to indicate which extractor is the newest.
The media framework automatically loads all available extractor
.so files, so
you can create your own extractors by adding a new
.so file without needing to
libstagefright or other media framework libraries. You can also ensure
that a custom extractor is preferred over the Google-provided extractor.
The MediaSession2 API allows media apps to expose their transport controls and playback information to other processes such as the Android framework and other apps. This component can't be customized.
The MediaParser API allows ExoPlayer to make efficient use of framework media container parsers to extract media samples from media containers. MediaParser includes the following changes to source code boundaries:
frameworks/base/apex/media/framework/java/android/media/MediaParser.java. API and thin layer implementation.
external/exoplayer/. Exoplayer verbatim sources on which MediaParser is built.
The MediaParser API can’t be customized. To test MediaParser, use the tests in
The Media Codecs module includes updatable software Codec2 components. Support for customization differs between releases:
In Android 11 or higher (specifically Google Play System Update v292100200), you can customize the parameters for ION memory allocation (see below for details).
In Android 9 or lower, the OMX codec API isn't updatable, but you can still use it in the vendor partition.
ION memory allocation
In Android 11 or higher and Google Play System Update v292100200 or higher, you can customize the following parameters for ION memory allocation.
||All heap types allowed.|
||No flags set.|
To override the parameters:
Register a default
android.hardware.media.c2service and provide custom ION usage parameters.
To create a new service, copy the frameworks/av/media/codec2/hidl/services/vendor.cpp file to your repository then modify
To reuse the (OMX)
media.codecprocess, copy and register the
StoreImplclass from frameworks/av/media/codec2/hidl/services/vendor.cpp to the existing
Add the following code to the device
<hal format="hidl"> <name>android.hardware.media.c2</name> <transport>hwbinder</transport> <version>1.0</version> <interface> <name>IComponentStore</name> <instance>default</instance> </interface> </hal>
Format and dependences
The Media module (
com.android.media) and Media Codec module
com.android.media.swcodec) are in APEX
format. Included media components rely only on NDK APIs.
During an update, the framework components on the device load an APEX package that contains Java and native code.
Figure 1. The media component update flow
After the framework installs the APEX package, the device reboots and mounts the
disk image and media system processes (
the updated modules from the mount point.