KernelSU Integration into AOSP common-android13-5.10 x86_64 Emulator

KernelSU is a powerful kernel-based security module that allows for advanced features like rootless privileged access. Integrating KernelSU into an Android emulator, specifically targeting the x86_64 architecture, presents unique challenges. This document outlines the process of integrating KernelSU into the AOSP common-android13-5.10 build using Kleaf/Bazel and addresses common issues encountered during the integration.

Understanding the Environment

Before diving into the integration process, it's crucial to understand the environment setup:

  • Host System: Windows (PowerShell) with WSL2 (Ubuntu) for cross-platform compatibility.
  • CPU: 12th Gen Intel® Core™ i7-12700, providing robust processing power.
  • Android Emulator: Version 36.2.12.0 with build_id 14214601.
  • AVD Configuration: Z1 device with Android 33, using the google_apis system image for x86_64 architecture.
  • Toolchain: Utilizing repo, tools/bazel, and AOSP kernel manifests for building the kernel.
  • Kernel Manifest: Focused on the common-android13-5.10 branch from the Android kernel manifest repository.

Challenges in Integration

Kconfig Include Failures

When attempting to integrate KernelSU, one of the primary issues faced is the failure of Kconfig includes. For instance, when placing KernelSU sources under a directory like drivers/kernelsu/ and attempting to include it in drivers/Kconfig with `source