Skip to main content

AOSP patches

Why Patch AOSP?

The Android SDK includes AOSP patches for a few reasons:

  • To enable the SDK to function (depending on AOSP version and the Android SDK version - see below).
  • To enable or enhance specific pieces of Android SDK functionality.

Do I have to patch AOSP to use the Android SDK?

On Android 8, an AOSP patch is always required. On Android 11+, an AOSP patch was required until SDK version 5.0. See below for details of those patches.

If patches are not required, then the remaining patches can be optionally applied (noting the functionality that will be lost if they are not applied). We will work in the future to reduce the number of patches, replacing the lost functionality by other means where possible.

This should enable e.g. using a Generic System Image (GSI) on recent Android versions, if desired.

Applying patches

See the Integration Guide.

Patch details

Required Patches

PatchAndroid VersionsRequiredNotes
build/core/tasksAndroid 8YesAllowlists Memfault components in the Android 8 build.
system/sepolicyAndroid 8YesApplies Memfault's sepolicy modifications on Android 8.
system/core/liblogAndroid 8-10Yes (if using Continuous Logging mode)Fixes a bug which causes Continuous Logging mode to fail on Android versions 8-10.
build/make/target/productAndroid 11-14Yes (When using Android SDK < 5.0)Required to allowlist the SDK in the /system partition on Android version 11 and above. Removed in 5.0, where the Android SDK is moved to /system-ext.

Optional Patches

PatchAndroid VersionsRequiredNotes
system/core/debuggerdAndroid 8-9NoAdds a timestamp to tombstones on Android 8-9. We recommend applying this patch on those versions, for more accurate timestamping of native crashes.
art/runtimeAndroid 10+NoAdds the GNU build ID to native stacktraces output by the OS (including tombstone, ANR DropBoxManager entries). We recommend applying this patch, to enable Memfault to symbolicate native stacktraces. We are investigating whether this patch can be removed in the future, while retaining the ability to symbolicate native stacktraces.
frameworks/base/coreAll VersionsNoConfigures batterystats to always collect data even when not discharging. Without this patch, devices with no battery, or with a battery but not in a discharging state, will not collect batterystats metrics (including e.g. GPS, Screen, Wifi, Phone, etc metrics). We recommend applying this patch to collect more comprehensive metrics.
frameworks/native/cmds/dumpstateAll VersionsNoAdds a "minimal mode" dumpstate (i.e. minimal bugreport) capability, which collects a small subset of data when the Android SDK collects a bugreport. This is not currently in-use by any user - we may remove it in a future SDK version.
build/make/target/productAndroid 9-13NoSets the vendor.memfault.bort.version.patch sysprop, to track whether the AOSP patches were applied on a build or not.