Internals-I:Linux To Android
Duration: 3-4 days

Back to course list Home
Synopsis For experienced Linux kernel developers, this course is a great introduction to the Android systems. We examine the features of the Android Operating System, and highlight exactly what it inherits from its Linux core, as well as how it diverges with its idiosyncrasies and "Android-isms". We talk about the modifications to the Linux kernel, that help Android optimize for embedded and tightly constrained hardware. Additional modules discuss specific Androidisms, such as the Hardware Abstraction Layer (HAL), the Media Framework and Android Power Management.
Target Audience Experienced Linux System and Kernel programmers who want to move to the Android Platform.
This course is NOT intended for user mode developers who wish to develop GUI applications or use the Android Java SDKs - but can be a great recommended followup for those who already do
Prerequisites
Objectives
  • Describe the architecture of the Android operating system
  • Describe the similarities between Linux and Android
  • Describe the differences between Linux and Android
  • Understand core architectural differences from Froyo (2.2) to KitKat (4.4)
  • Describe the functions and architecture of the Android Kernel
Exercises This course allocates plenty of time for hands-on practice.
The hands-on exercises include:
  • Creating a full fledged Android native application
  • Manipulating Kernel structures like process control blocks, events and others
Modules
Day 1
1. Introduction - The Android Architecture
2-4 hours
Introduction to the Android architecture. We discuss the design and implementation of the various subsystems, at a modular "black box" level, without going into the source code level (yet).
  • Android features
    • Android vs. Linux vs. Embedded Linux
      • Filesystem layout and directories
        • The Runtime Environment
          • The Frameworks
            • Dalvik (Java)
              • Components
                • Activities
                  • Services
                    • Broadcast Receivers
                      • Content Providers
                      • Version differences - 1.5 through 4.4.4 and L
                        • User-Mode and Kernel-Mode Architecture
                          • Android Kernel modifications
                            2. Inside an Android
                            2 hours
                            Exploring the Android shell environment, using ADB and the various commands. We show both simulator and real devices, and examine, in depth, the various commands availble for viewing system information and debugging.
                            • ADB and the Android Shell
                              • Commands in /system/bin
                                • Android Filesystem layout
                                  • Android process memory
                                    • Commands in /system/xbin
                                      • Debugging techniques


                                        Exercises include:
                                        • Dynamic tracing of Android system calls
                                        Day 2
                                        3. Booting
                                        2 hours
                                        System startup and initialization - Walk through the various stages, from boot loader through kernel startup to basic setup of user mode processes. Optionally, we also describe the modification of the boot loaders.
                                        • x86 vs. ARM
                                          • The Boot loader, and FastBoot
                                            • Kernel Startup
                                              • User mode init - /init and /init.rc
                                                • Services and Daemons


                                                  Exercises include:
                                                  • Creating a simple service and integrating it with the device boot sequence
                                                  4. Crash course in application development
                                                  2 hours
                                                  We walk through a simple Android application - working through the Android SDK, the Dalvik Java environment, and the basic frameworks. This module is optional, in case the target audience are new to Android, and is not meant to be comprehensive - only to cover the key concepts, and map them to the underlying native APIs that implement them. Otherwise, it can be skipped. Topics include:
                                                  • Basic application structure - Packages and Manifests
                                                    • Text Views
                                                      • Buttons
                                                        • Basic Layouts
                                                          • Menus
                                                            • Dialogs
                                                              • Events and Notifications


                                                                Exercises include:
                                                                • Compiling and building a sample Android "Hello World" application
                                                                5. The NDK
                                                                2 hours
                                                                For developers who need to escape the Virtual Machine, Android offers the Native SDK - or the NDK. For performance critical regions, going into native mode is a necessity, not a luxury. We explain the basic ideas of the NDK, its bridging from Java, and sample from its APIs.
                                                                • Why go Native? Introduction to NDK
                                                                  • Bionic - Android's LibC
                                                                    • Accessing Native Calls - JNI
                                                                      • Building an Android native binary (exectuable)
                                                                        • Building an Android native shared library
                                                                          • NDK Samples


                                                                            Exercises include:
                                                                            • Compiling and building a sample NDK application
                                                                            Day 3
                                                                            6. Android Security
                                                                            2 hours
                                                                            The Android security infrastructure and model.
                                                                            • Security Policies
                                                                              • Private and Public
                                                                                • Permissions
                                                                                  • Service Hooks
                                                                                    • Protected APIs
                                                                                      • Kernel mode security
                                                                                        • The Linux Capabilities model
                                                                                          • Linux Security Modules (LSM) and SELinux
                                                                                            • Kernel buffer overflow protection - ExecShield and randomization
                                                                                            7. Android-isms
                                                                                            4 hours
                                                                                            Android is, at the kernel level, almost identical to the common Linux kernel. There are, however, idiosyncrasies and modifications, which optimize the kernel to the mobile environments - low memory conditions, power management considerations, and more. In this chapter, we dig deep into these modifications, by examining each in detail, at the source code level. Specifically, we discuss:
                                                                                            • ASHmem - Android's Anonymous Shared Memory mechanism
                                                                                              • PMem - Physical contiguous memory for non scatter/gather capable hardware
                                                                                                • Low memory killer - Allowing customized Linux OOM behavior from user space
                                                                                                  • Wakelocks - and the enhancements to Power Management
                                                                                                    • Android Logging - /dev/log/* and the magic behind the logcat command
                                                                                                      • The RAM Console - Used in Android to save Panic data across reboot
                                                                                                        • /dev/binder - the implementation of OpenBinder and the underlying mechanism supporting AIDL
                                                                                                          • Timed GPIO/Output
                                                                                                            Day optional
                                                                                                            *. Android Media
                                                                                                            4-6 hours
                                                                                                            Detailed discussion of the Android Media Framework - SurfaceFlinger, AudioFliger and StageFright, and ways to interface with them. Topics Include:
                                                                                                            • MediaFlinger and the View subsystem
                                                                                                              • AudioFlinger
                                                                                                                • The Frame Buffer - Playback and Capture
                                                                                                                  • The DRM framework
                                                                                                                    *. Android's Hardware Abstraction Layer
                                                                                                                    2-3 hours
                                                                                                                    The Android Hardware Abstraction Layer is a key component in Android. It enables the operating system to be adapted to different devices. The basic devices of a phone or tablet - the leds, power, vibrator and others - are abstracted by libhardware into virtual hardware devices, and we discuss them here.
                                                                                                                    • The need for a hardware abstraction layer
                                                                                                                      • The basic devices
                                                                                                                        • Camera
                                                                                                                          • Flashlight
                                                                                                                            • GPS
                                                                                                                              • Leds
                                                                                                                                • Sensors
                                                                                                                                  • Vibrator
                                                                                                                                  • The User Event Daemon
                                                                                                                                    • HAL stubs
                                                                                                                                      • The last stretch - from HAL to the driver