Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Roger Ye

Rating No ratings yet

Build, customize, and debug your own Android system Key Features Master Android system-level programming by integrating, customizing, and extending popular open source projects Use Android emulators to explore the true potential of your hardware Master key debugging techniques to create a hassle-free development environment Book Description Android system programming involves both hardware and software knowledge to work on system level programming. The developers need to use various techniques to debug the different components in the target devices. With all the challenges, you usually have a deep learning curve to master relevant knowledge in this area. This book will not only give you the key knowledge you need to understand Android system programming, but will also prepare you as you get hands-on with projects and gain debugging skills that you can use in your future projects. You will start by exploring the basic setup of AOSP, and building and testing an emulator image. In the first project, you will learn how to customize and extend the Android emulator. Then you'll move on to the real challenge―building your own Android system on VirtualBox. You'll see how to debug the init process, resolve the bootloader issue, and enable various hardware interfaces. When you have a complete system, you will learn how to patch and upgrade it through recovery. Throughout the book, you will get to know useful tips on how to integrate and reuse existing open source projects such as LineageOS (CyanogenMod), Android-x86, Xposed, and GApps in your own system. What you will learn Set up the Android development environment and organize source code repositories Get acquainted with the Android system architecture Build the Android emulator from the AOSP source tree Find out how to enable WiFi in the Android emulator Debug the boot up process using a customized Ramdisk Port your Android system to a new platform using VirtualBox Find out what recovery is and see how to enable it in t

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on, project-driven guide for engineers who want to move beyond Android app development and learn to build, customize, port, and debug the Android system itself—ideal for embedded developers, device integrators, and anyone curious about AOSP internals. 【Book Arc】 - **Opening (~0%–9%)**: Introduces the scope of Android system programming, contrasting it with app development, and maps the layered Android architecture—from the Linux kernel and HAL up through Binder IPC and the application framework. This stage sets the vocabulary and mental model for everything that follows. - **Early (~9%–25%)**: Walks through setting up a full AOSP build environment, including installing the correct JDK versions for Android 6 and 7, and managing source repositories with `repo` and manifests. It also explains how to create a local mirror of AOSP and Android-x86 to insulate your work from remote server outages. - **Early (~25%–34%)**: Dives into the kernel, HAL, and virtual hardware, dissecting the AOSP source tree layout and examining the goldfish emulator's virtual devices—audio, lights, and more—at the register level. This is where you learn how the emulator's hardware is simulated and how HALs connect to it. - **Middle (~34%–44%)**: Focuses on customizing the Android emulator by creating a new device definition (x86emu), comparing 32-bit and 64-bit product Makefiles, and understanding the build system's product configuration files. You'll learn how to add your own device to the `lunch` menu and build it. - **Middle (~44%–47%)**: Explores the Native Bridge mechanism and the Houdini ARM translator, showing how the emulator can run ARM binaries on x86 hosts. This section explains the callback interfaces between ART and the native bridge library, and how to integrate Houdini into your custom device. - **Late (~47%–end)**: The excerpts taper off here, but the book's stated trajectory continues into porting Android to VirtualBox, debugging the init process, resolving bootloader issues, enabling hardware interfaces, and using recovery to patch and upgrade the system. It also covers integrating open source projects like LineageOS, Android-x86, Xposed, and GApps. 【Key Takeaways】 - **System programming is hardware-bound** (Early): Unlike app development, Android system work is tied to specific hardware and OS versions, making it harder to teach and repeat. The book's strategy is to use virtual platforms (emulator, VirtualBox) to create reproducible environments. - **Binder IPC is the backbone of Android's architecture** (Early): Applications cannot access hardware or system resources directly; they must go through system services via Binder IPC. Understanding this proxy mechanism is essential for grasping how the framework and services interact across process boundaries. - **A local mirror is a practical necessity** (Early): Relying on remote repositories is fragile; the author demonstrates creating a mixed local mirror of AOSP, Android-x86, and GitHub using `repo` and manifests. This is a real-world tip that saves you from downtime and version drift. - **The emulator's HAL is inspectable and instructive** (Early): By examining `$OUT/system/lib/hw`, you can see exactly which HAL modules the emulator ships. The goldfish virtual devices (audio, lights) are documented at the register level, giving you a concrete model for how HALs interface with hardware. - **Product Makefiles define your device** (Middle): Creating a new emulator device means writing product definition files like `x86emu_x86.mk`, inheriting from generic AOSP products, and setting architecture, kernel config, and branding. The 32-bit vs 64-bit comparison shows how small changes cascade through the build. - **Native Bridge enables ARM-on-x86 translation** (Middle): The Houdini library implements callback structures (`NativeBridgeCallbacks` and `NativeBridgeRuntimeCallbacks`) that let ART call ARM native methods on x86 hosts. This is the key to running ARM apps on your custom emulator. - **Debugging is a core skill, not an afterthought** (Late): The book's later chapters are dedicated to debugging the boot process with a customized ramdisk and resolving bootloader issues on VirtualBox—skills that are directly transferable to real hardware porting. 【Reading Tips】 - **Skim the architecture overview** (Opening): If you already know Android's layers, move quickly through Chapter 1. The Binder IPC explanation is worth a careful read, but the rest is context-setting. - **Deep-read the build setup and mirror creation** (Early): This is where most readers get stuck. Follow the JDK installation and `repo` mirror steps exactly; they are prerequisites for every later project. - **Study the product Makefile comparison** (Middle): The side-by-side 32-bit/64-bit table is a goldmine. Understand what each inherited file does before you start customizing your own device. - **Expect code-level detail in the Native Bridge chapter** (Middle): The callback structures and JNI interfaces are dense. If you're not planning to integrate Houdini, skim this section and focus on the conceptual flow rather than the implementation. - **Use the book as a project manual, not a reference** (Overall): The value is in doing the projects sequentially. Set up the emulator first, then customize it, then attempt the VirtualBox port. Skipping ahead will likely lead to confusion. 【Coverage Limits】 The excerpts cover roughly the first half of the book (setup, emulator customization, HAL internals, and Native Bridge). The later chapters on VirtualBox porting, init debugging, and recovery are described in the book's introduction but not detailed in the provided material.
Excerpt 1
ulator Debug the boot up process using a customized Ramdisk Port your Android system to a new platform using VirtualBox Find out what recovery is and see how...
View in text
Excerpt 2
b packages for 64-bit architecture from archive.ubuntu.com: openjdk-8-jre-headless_8u45-b14-1_amd64.deb with SHA256 0f5aba8db39088283b51e00054813063173a4d880...
View in text
Excerpt 3
sters: Offset Name Abstract 0x00 INT_STATUS 0x04 INT_ENABLE 0x08 SET_WRITE_BUFFER_1 W: Set address of first kernel output buffer. 0x0c SET_WRITE_BUFFER_2 W:...
View in text
Excerpt 4
ue; } char cpuinfo_path[1024]; #if defined(__ANDROID__) snprintf(cpuinfo_path, sizeof(cpuinfo_path), "/system/lib" #ifdef __LP64__ "64" #endif // __LP64__ "/...
View in text
Excerpt 5
ot} /android /init # avoid kernel panic while :; do echo echo ' Android-x86 console shell. Use only in emergencies.' echo debug_shell fatal-err done No matte...
View in text
Excerpt 6
evice initialization is also split into two stages. [ 220 ] Creating Your Own Device on VirtualBox The Android init process will perform the hardware initial...
View in text
Excerpt 7
of this book is on how we can port Android systems to a new hardware platform. To focus on this goal, we will address the graphics HAL in this chapter instea...
View in text
Excerpt 8
return error if connection with host can not be established HostConnection *hostCon = HostConnection::get(); if (!hostCon) { ALOGE("gralloc: failed to get ho...
View in text
Tags
AI categories
Cloud NativeOSProgramming
ISBN: 178712536X
Publisher: Packt Publishing
Publish Year: 2017
Language: English
Pages: 470
File Format: PDF
File Size: 8.2 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…