Internals-II:Framework Internals
Duration: 3 days

Back to course list Home
Synopsis Understand the inner workings of the Android core frameworks, and how they interact with overhead Dalvik and underlying kernel. Versions Froyo (2.2) through Lollipop (5.0.2) are discussed in detail. Emphasis on Android's media architecture and frameworks. This course is meant as a followup to "Android Internals" (or "Linux to Android")
Target Audience Android implementors and hackers, who want to gain a better understanding of Android's core frameworks, and their implementation in Java, and C/C++.
This course is NOT intended for user mode developers who wish to develop GUI applications or use the Android Java SDKs - it is a followup to Internals-I: Linux To Android
  • Describe the architecture of the Android core frameworks
  • Explain the multimedia architecture of Android - AudioFlinger and Surface/PixelFlinger
  • Build and replace Android system components
  • Identify, modify and extend Java Native Interfaces
Exercises This course allocates plenty of time for hands-on practice.
The hands-on exercises include:
  • Calling Dalvik/Java code from native code, and vice versa
  • Creating HAL modules
  • Tracing activity IPC
1. The Android Architecture
2 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).
Note: This module may be skipped for people with solid knowledge of Android Internals, who have participated in "Linux to Android"

  • Android features
    • Android vs. Linux vs. Embedded Linux
      • Filesystem layout and directories
        • The Runtime Environment
          • The Frameworks
            • Dalvik (Java) and ART
              • Version differences - from Gingerbread to KitKat
                • Security Architecture recap
                  • User-Mode and Kernel-Mode Architecture
                    2. Building Android
                    1 hours
                    Obtaining, navigating and compiling portions or the complete Android source
                    • Getting the source - repo, git, etc
                      • Setting up a build environment on a dedicated VM
                        • Considerations with cross compilation
                          • Getting to know up close and personal
                            • Compiling and tweaking for x86, x64, or ARM
                              • Compiling specific Android components

                                Exercises include:
                                • Setting up an Android build environment
                                • Obtaining the source code of the latest Android system, compiling and building it
                                3. Android System Services
                                1 day
                                Get to know mediaserver and friends - their many threads, services and interprocess communication
                                • Android servers
                                  • Debugging servers
                                    • system_server and its multitude of threads (AudioFlinger, SurfaceFlinger, sensors..)
                                      • servicemanager
                                        • mediaserver
                                          • rild
                                            • Zygote
                                              4. Androidisms
                                              1 hours
                                              Detailed discussion of Android kernel changes, including:
                                              • Ashmem
                                                • Low memory killer
                                                  • RAM console
                                                    • Binder (as introduction - covered more in IPC
                                                      • Logging
                                                        • Power Management and wakelocks
                                                          5a. Dalvik
                                                          4 hours
                                                          Detailed examination the Dalvik virtual machine and its possible successor, ART, including:
                                                          • Dalvik vs. Java: Same, but different
                                                            • Architecture of Dalvik
                                                              • Memory optimizations in Dalvik
                                                                • DEX file format
                                                                  • DEX bytecode format
                                                                    • ART - The new runtime in KitKat
                                                                      5b. JNI
                                                                      2 hours
                                                                      Detailed examination JNI mechanisms in Dalvik, including:
                                                                      • Using JNI: From the Java and Native perspectives
                                                                        • Dalvik dynamic loading of native code
                                                                          • Native components in Android system services

                                                                            Exercises include:
                                                                            • Writing and debugging a JNI service
                                                                            • Tracing server execution from Java to native code
                                                                            6. The Android HAL
                                                                            1 hours
                                                                            Explaining the Android Hardware Abstraction Layer (HAL) - libhardware - as it relates to cameras, sensors, gps, and other hardware

                                                                            Exercises include:
                                                                            • Implementing a dummy HAL module
                                                                            7. Binder
                                                                            2 hours
                                                                            The heart of Android (and amongst its darkest corners) is the Binder (ported from BeOS). In this module, we elucidate its mechanisms, from it Java bindings through native code down to the underlying kernel support, including:
                                                                            • libBinder
                                                                              • Java's IBinder and Parcels
                                                                                • The /dev/binder implementation
                                                                                  • Debugging Binder
                                                                                    • service, am, and other debugging tools

                                                                                      Exercises include:
                                                                                      • Directly starting activities and applications from native code and CLI
                                                                                      • Debugging Binder
                                                                                      8. The Android Multimedia Architecture
                                                                                      4 hours
                                                                                      Understand the inner workings of SurfaceFlinger, responsible for all graphics (combining views and framebuffers) in Android, AudioFlinger (sound) and Android L's InputFlinger.
                                                                                      • Surface/PixelFlinger
                                                                                        • OpenGL graphics
                                                                                          • Combining views
                                                                                            • Diagnosing the flinger
                                                                                              • Hardware accelearation
                                                                                                • AudioFlinger
                                                                                                  • L: InputFlinger
                                                                                                    9. Android USB
                                                                                                    2 hours
                                                                                                    Understand Android's Behavior as a USB target and as a USB host
                                                                                                    • Android's USB Stack
                                                                                                      • Android as a target
                                                                                                        • The Gadget Driver
                                                                                                          • Mass Storage
                                                                                                            • PTP/MTP
                                                                                                              • ADB
                                                                                                                • RNDIS (Tethering)
                                                                                                                • Android as a host and Accessory Mode
                                                                                                                  10. Android Connectivity
                                                                                                                  4 hours
                                                                                                                  Understand Android's various interfaces:
                                                                                                                  • Telephony (RILD)
                                                                                                                    • Wi-Fi
                                                                                                                      • Wi-Fi with wpa_supplicant
                                                                                                                        • Wi-Fi Direct with p2p_supplicant
                                                                                                                        • VPNs
                                                                                                                          • Tethering