O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Embedded Android N Programming

Book Description

Create the perfectly customized system by unleashing the power of Android OS on your embedded device

About This Book

  • Understand the system architecture and how the source code is organized
  • Explore the power of Android and customize the build system
  • Build a fully customized Android version as per your requirements

Who This Book Is For

If you are a Java programmer who wants to customize, build, and deploy your own Android version using embedded programming, then this book is for you.

What You Will Learn

  • Master Android architecture and system design
  • Obtain source code and understand the modular organization
  • Customize and build your first system image for the Android emulator
  • Level up and build your own Android system for a real-world device
  • Use Android as a home automation and entertainment system
  • Tailor your system with optimizations and add-ons
  • Reach for the stars: look at the Internet of Things, entertainment, and domotics

In Detail

Take a deep dive into the Android build system and its customization with Learning Embedded Android Programming, written to help you master the steep learning curve of working with embedded Android. Start by exploring the basics of Android OS, discover Google’s “repo” system, and discover how to retrieve AOSP source code. You'll then find out to set up the build environment and the first AOSP system. Next, learn how to customize the boot sequence with a new animation, and use an Android “kitchen” to “cook” your custom ROM. By the end of the book, you'll be able to build customized Android open source projects by developing your own set of features.

Style and approach

This step-by-step guide is packed with various real-world examples to help you create a fully customized Android system with the most useful features available.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Learning Embedded Android N Programming
    1. Table of Contents
    2. Learning Embedded Android N Programming
    3. Credits
    4. About the Authors
    5. About the Reviewer
    6. www.PacktPub.com
      1. eBooks, discount offers, and more
        1. Why subscribe?
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Understanding the Architecture
      1. An overview of the Android system
        1. Linux kernel
        2. Hardware abstraction layer – HAL
        3. Libraries and the application framework
          1. Libraries
        4. The application framework
        5. Binder IPC
        6. The application layer
      2. Android compatibility
        1. The Android Compatibility Definition Document
          1. Device types
          2. Software compatibility
      3. Beyond Java
        1. Native API
        2. Maintaining 32-bit support
      4. From Dalvik to ART runtime
        1. The Android runtime
          1. A new old approach – AOT compilation
          2. Garbage collection and other improvements
          3. Waiting for Android Nougat
      5. Meeting the Compatibility Test Suite
        1. CTS setup
        2. Device setup
        3. Media files setup
        4. Run!
        5. Analyzing the test results
      6. Diving deeper with CTS Verifier
        1. Setup
        2. Manual testing
        3. Retrieving the results
      7. Summary
    9. 2. Obtaining the Source Code – Structure and Philosophy
      1. The Android philosophy
        1. The license
        2. Open source, closed doors
        3. The Android development model
        4. Source code tags and builds
        5. Nexus
          1. Phones
          2. Tablets
          3. Digital media players
        6. Source code tools
          1. Git
          2. Repo
        7. Gerrit
      2. Setting up the environment
        1. Free space
      3. Installing the required tools
      4. Getting ready
        1. Downloading the code
        2. Hands on the code
      5. A look inside AOSP
        1. The ART directory
        2. The bionic directory
        3. The build directory
        4. The external directory
        5. The device directory
        6. The frameworks directory
        7. The out directory
        8. The packages directory
        9. The system directory
        10. The rest of the directory structure
      6. Summary
    10. 3. Set up and Build – the Emulator Way
      1. Preparing the host system
        1. Hardware requirements
        2. Software requirements
          1. Installing Java JDK
          2. Installing system dependencies
        3. Setting up a Mac OS X environment
          1. Creating a case-sensitive disk image
          2. Installing the required software
      2. The Android build system
        1. An overview
        2. Bootstrap
        3. Setup
          1. The TARGET_PRODUCT variable
          2. The TARGET_BUILD_VARIANT variable
          3. The TARGET_BUILD_TYPE variable
          4. The TARGET_TOOLS_PREFIX variable
          5. The OUT_DIR variable
          6. The TARGET_PREBUILT_KERNEL variable
          7. The buildspec.mk file
          8. The lunch command
        4. Building the system
          1. More about make
            1. Building a module
            2. Cleaning a module
            3. Cleaning everything
            4. Listing modules
            5. Recreating an image
            6. Building tools
          2. Beyond the system image
            1. Android SDK
            2. Android NDK
            3. Android CTS
        5. Inside an AOSP module
          1. Diving into Android.mk
          2. Android.mk variables ecosystem
            1. The LOCAL_ variables
            2. The BUILD_ variables
          3. Module template examples
            1. The native executable template
            2. The shared library template
            3. The application template
      3. Creating a custom device
        1. Diving into device configuration
      4. From zero to the screenlock
        1. Setup
        2. Build
        3. Run
      5. Summary
    11. 4. Moving to Real-World Hardware
      1. Debugging tools
        1. Introducing ADB
          1. Pushing files to devices
          2. Pulling files from devices
          3. Installing Android APK files
          4. Logcat
        2. Fastboot
      2. Choosing our hardware
        1. Hardware architectures
          1. Minimum requirements
          2. System on Chip – SoC
          3. The baseband processor
        2. Our hardware choice
          1. Motorola Nexus 6
          2. UDOO Quad
      3. Compiling Android for a real-world device
        1. Nexus 6
        2. UDOO Quad
          1. Setup
          2. Bootloader
          3. System
          4. Kernel
      4. Bootloader mode
        1. Nexus devices
        2. UDOO family boards
      5. Flashing Android images
        1. Nexus 6
        2. UDOO
      6. Summary
    12. 5. Customizing Kernel and Boot Sequence
      1. An overview of the Linux kernel
        1. Obtaining the kernel
          1. Retrieving the kernel's binary version
          2. Obtaining the kernel source code
      2. Setting up the toolchain
        1. Getting the toolchain
      3. Preparing the host system
      4. Configuring the kernel
      5. Compiling the kernel
      6. Working with non-Google devices
      7. Driver management
      8. Altering the CPU frequency
        1. An overview of the governors
      9. Customizing the boot image
        1. Creating the boot image
        2. Upgrading the new boot image
      10. Android boot sequence
        1. Internal ROM – bios
        2. An overview of bootloader
        3. The kernel
        4. The Init process
        5. The Android init language
          1. Actions
          2. Services
          3. Options
          4. Triggers
          5. Commands
          6. Imports
      11. Summary
    13. 6. "Cooking" Your First ROM
      1. History of custom ROMs
        1. Cyanogenmod
          1. Building Cyanogenmod
          2. Installing a pre-build version
        2. The Android Open Kang Project
          1. Installing AOKP
        3. Minor ROMs
        4. Overview of OEM customizations
          1. Samsung – TouchWiz
          2. Huawei EMUI
          3. HTC Sense
          4. LG Optimus UI
          5. Xiaomi MIUI
      2. An overview of Android recovery
        1. Diving into Android recovery
        2. Installing an alternative recovery
          1. Clockworkmod
          2. TWRP – Team Win Recovery Project
          3. Connecting to the recovery shell using ADB
      3. Device permissions
        1. Root access
          1. SuperSu
          2. Obtaining root access
      4. Chef toolkit
        1. Preparing the environment
        2. Android kitchen
        3. Other developers' tools
          1. Manipulating DEX files with APKTool
      5. Cooking our first ROM
        1. Gathering the ingredients
          1. Dumping system partitions
        2. Modifying an Android system binary image
        3. Modifying an Android binary boot image
      6. Flashing our custom ROM
      7. Summary
    14. 7. Tailoring Your Personal Android System
      1. Receiving over the air updates – OTA
        1. Updating the whole system
        2. Updating the system incrementally
        3. Applying a single component update
      2. Creating over the air updates
        1. OTA internals
          1. Edify syntax
        2. OTA for custom ROM
      3. Advanced ROM customization
        1. ROM customization from binary
        2. Customizing ROM from source
        3. Adding new packages to Android's build system
          1. Adding a package by binary
          2. Adding packages by source code
      4. Hacking the Android framework
        1. Customizing the boot sequence UI
        2. Customizing the Android Settings menu
      5. Enhancing the system performance
        1. Customizing the system property file
        2. Adding a custom init sequence
      6. Advanced Linux kernel modding
        1. Diving into CPU frequency management
        2. Adding a custom CPU frequency governor
        3. Exploring I/O schedulers
      7. Looking forward
      8. Summary
    15. 8. Beyond the Smartphone
      1. Meeting Arduino
        1. Android ADK
        2. Using UDOO as an all-in-one ADK device
          1. Getting ready
          2. Flashing the Arduino board
          3. Creating the Android app
      2. Exploring the possibilities of the Internet of Things
        1. Android Auto
        2. Android Wear
      3. Domotics
      4. Can a green droid entertain you?
        1. Multimedia
        2. Toys
      5. Summary
    16. Index