Android Internals
Android Builders Summit – April 13th 2011

            Karim Yaghmour
      karim.yaghmour@opersys.com
             @karimyaghmour
About ...
â—Ź   Author of:




â—Ź   Introduced Linux Trace Toolkit in 1999
â—Ź   Originated Adeos and relayfs (kernel/relay.c)
1. Android Concepts       9. System Server
2. Overall Architecture   10.Activity Manager
3. System startup         11.Binder
4. Linux Kernel           12.Stock AOSP Apps
5. Hardware Support       13.Hacking
6. Native User-Space
7. Dalvik
8. JNI
1. Android Concepts
â—Ź   Components
â—Ź   Intents
â—Ź   Component lifecycle
â—Ź   Manifest file
â—Ź   Processes and threads
â—Ź   Remote procedure calls
1.1. Components
â—Ź   1 App = N Components
â—Ź   Apps can use components of other applications
â—Ź   App processes are automagically started whenever any part
    is needed
â—Ź   Ergo: N entry points, !1, and !main()
â—Ź   Components:
    â—Ź   Activities
    â—Ź   Services
    â—Ź   Broadcast Receivers
    â—Ź   Content Providers
1.2. Intents
â—Ź   Intent = asynchronous message w/ or w/o
    designated target
â—Ź   Like a polymorphic Unix signal, but w/o
    required target
●   Intents “payload” held in Intent Object
â—Ź   Intent Filters specified in Manifest file
1.3. Component lifecycle
â—Ź   System automagically starts/stops/kills
    processes:
    â—Ź   Entire system behaviour predicated on low memory
â—Ź   System triggers Lifecycle callbacks when
    relevant
â—Ź   Ergo: Must manage Component Lifecycle
â—Ź   Some Components are more complex to
    manage than others
1.4. Manifest file
●   Informs system about app’s components
â—Ź   XML format
â—Ź   Always called AndroidManifest.xml
â—Ź   Activity = <activity> ... static
â—Ź   Service = <service> ... static
â—Ź   Broadcast Receiver:
    â—Ź   Static = <receiver>
    â—Ź   Dynamic = Context.registerReceiver()
â—Ź   Content Provider = <provider> ... static
1.5. Processes and threads
â—Ź   Processes
    â—Ź   Default: all callbacks to any app Component are issued to the main process thread
    ●   <activity>—<service>—<recipient>—<provider> have process attribute to override
        default
    â—Ź   Do NOT perform blocking/long operations in main process thread:
        –   Spawn threads instead
    ●   Process termination/restart is at system’s discretion
    â—Ź   Therefore:
        –   Must manage Component Lifecycle
â—Ź   Threads:
    â—Ź   Create using the regular Java Thread Object
    â—Ź   Android API provides thread helper classes:
        –   Looper: for running a message loop with a thread
        –   Handler: for processing messages
        –   HandlerThread: for setting up a thread with a message loop
1.6. Remote procedure calls
â—Ź   Apparently System V IPC is evil ...
â—Ź   Android RPCs = Binder mechanism
â—Ź   Binder is a low-level functionality, not used as-is
â—Ź   Instead: must define interface using Interface
    Definition Language (IDL)
â—Ź   IDL fed to aidl Tool to generate Java interface
    definitions
1.7. Development tools
â—Ź   SDK:
    ●   android – manage AVDs and SDK components
    ●   apkbuilder – creating .apk packages
    ●   dx – converting .jar to .dex
    ●   adb – debug bridge
    ●   emulator – QEMU-based ARM emulator
    â—Ź   ...
â—Ź   Eclipse w/ ADT plugin
â—Ź   NDK: GNU toolchain for native binaries
2.1. Overall Architecture - EL
2.2. Overall Architecture - Android
3. System Startup
â—Ź   Bootloader
â—Ź   Kernel
â—Ź   Init
â—Ź   Zygote
â—Ź   System Server
â—Ź   Activity Manager
â—Ź   Launcher (Home)
3.1. Bootloader
â—Ź   aosp/bootable/bootloader
    â—Ź   Custom bootloader for Android
    â—Ź   USB-based
    ●   Implements the “fastboot” protocol
    ●   Controlled via “fastboot” cli tool on host
â—Ź   aosp/bootable/recovery
    â—Ź   UI-based recovery boot program
    â—Ź   Accessed through magic key sequence at boot
    â—Ź   Usually manufacturer specific variant
â—Ź   Flash layout:

          0x000003860000­0x000003900000 : "misc"
          0x000003900000­0x000003e00000 : "recovery"
          0x000003e00000­0x000004300000 : "boot"        Kernel
          0x000004300000­0x00000c300000 : "system"      /system
          0x00000c300000­0x0000183c0000 : "userdata"    /data
          0x0000183c0000­0x00001dd20000 : "cache"       /cache
          0x00001dd20000­0x00001df20000 : "kpanic"
          0x00001df20000­0x00001df60000 : "dinfo"
          0x00001df60000­0x00001dfc0000 : "setupdata"
          0x00001dfc0000­0x00001e040000 : "splash1"
          0x000000300000­0x000001680000 : "modem"
                         From Acer Liquid-E
3.2. Kernel
â—Ź   Early startup code is very hardware dependent
â—Ź   Initializes environment for the running of C code
â—Ź   Jumps to the architecture-independent
    start_kernel() function.
â—Ź   Initializes high-level kernel subsystems
â—Ź   Mounts root filesystem
â—Ź   Starts the init process
3.3. Android Init
â—Ź   Open, parses, and runs /init.rc:
    â—Ź   Create mountpoints and mount filesystems
    â—Ź   Set up filesystem permissions
    â—Ź   Set OOM adjustments properties
    â—Ź   Start daemons:
        –   adbd
        –   servicemanager (binder context manager)
        –   vold
        –   netd
        –   rild
        –   app_process -Xzygote (Zygote)
        –   mediaserver
        –   ...
3.4. Zygote, etc.
â—Ź   Init:
    â—Ź   app_process -Xzygote (Zygote)
â—Ź   frameworks/base/cmds/app_process/app_main.cpp:
    ●   runtime.start(“com.android.internal.os.Zygote”, ...
â—Ź   frameworks/base/core/jni/AndroidRuntime.cpp:
    â—Ź   startVM()
    â—Ź   Call Zygote's main()
â—Ź   frameworks/base/core/java/com/android/internal/os/Zy
    goteInit.java:
    â—Ź   ...
â—Ź   preloadClasses()
    â—Ź   startSystemServer()
    â—Ź   ... magic ...
    â—Ź   Call SystemServer's run()
â—Ź   frameworks/base/services/java/com/android/server
    /SystemServer.java:
    â—Ź   Start all system services/managers
    â—Ź   Start ActivityManager:
         –   Send Intent.CATEGORY_HOME
         –   Launcher2 kicks in
4. Linux Kernel
4.1. Androidisms
â—Ź   Wakelocks
â—Ź   lowmem handler
â—Ź   Binder
●   ashmem – Anonymous Shared Memory
â—Ź   RAM console
â—Ź   Logger
â—Ź   ...
5. Hardware support
Bluetooth               BlueZ through D-BUS IPC (to avoid GPL contamination it seems)
GPS                     Manufacturer-provided libgps.so
Wifi                    wpa_supplicant
Display                 Std framebuffer driver (/dev/fb0)
Keymaps and Keyboards   Std input event (/dev/event0)
Lights                  Manufacturer-provided liblights.so
     Backlight
     Keyboard
     Buttons
     Battery
     Notifications
     Attention
Audio                   Manufacturer-provided libaudio.so (could use ALSA underneath ... at least as illustrated in their porting guide)
Camera                  Manufacturer-provided libcamera.so (could use V4L2 kernel driver underneath ... as illustrated in porting guide)
Power Management        “Wakelocks” kernel patch
Sensors                 Manufacturer-provided libsensors.so
     Accelerometer
     Magnetic Field
     Orientation
     Gyroscope
     Light
     Pressure
     Temperature
     Proximity
Radio Layer Interface   Manufacturer-provided libril-<companyname>-<RIL version>.so
6. Native User-Space
â—Ź   Mainly
    â—Ź   /data    => User data
    â—Ź   /system => System components
â—Ź   Also found:
    â—Ź   /cache
    â—Ź   /mnt
    â—Ź   /sbin
    â—Ź   Etc.
â—Ź   Libs:
     Bionic, SQLite, SSL, OpenGL|ES,
     Non-Posix: limited Pthreads support, no SysV IPC
â—Ź   Toolbox
â—Ź   Daemons:
     servicemanager, vold, rild, netd, adbd, ...
7. Dalvik
â—Ź   Sun-Java =
        Java language + JVM + JDK libs
â—Ź   Android Java =
        Java language + Dalvik + Apache Harmony
â—Ź   Target:
    â—Ź   Slow CPU
    â—Ź   Relatively low RAM
    â—Ź   OS without swap space
    â—Ź   Battery powered
â—Ź   Now has JIT
7.1. Dalvik's .dex files
●   JVM munches on “.class” files
●   Dalvik munches on “.dex” files
●   .dex file = .class files post-processed by “dx”
    utility
â—Ź   Uncompressed .dex = 0.5 * Uncompressed .jar
8. JNI – Java Native Interface
â—Ź   Call gate for other languages, such as C, C++
â—Ź   Equivalent to .NET's pinvoke
â—Ź   Usage: include and call native code from App
â—Ź   Tools = NDK ... samples included
●   Check out “JNI Programmer's Guide and
    Specification” - freely available PDF
9. System Server
Entropy Service            Device Policy               Audio Service
Power Manager              Status Bar                  Headset Observer
Activity Manager           Clipboard Service           Dock Observer
Telephone Registry         Input Method Service        UI Mode Manager Service
Package Manager            NetStat Service             Backup Service
Account Manager            NetworkManagement Service   AppWidget Service
Content Manager            Connectivity Service        Recognition Service
System Content Providers   Throttle Service            Status Bar Icons
Battery Service            Accessibility Manager       DiskStats Service
Lights Service             Mount Service               ADB Settings Observer
Vibrator Service           Notification Manager
Alarm Manager              Device Storage Monitor
Init Watchdog              Location Manager
Sensor Service             Search Service
Window Manager             DropBox Service
Bluetooth Service          Wallpaper Service
9.1. Some stats
â—Ź   frameworks/base/services/java/com/android/ser
    ver:
    â—Ź   3.5 M
    â—Ź   ~100 files
    â—Ź   85 kloc
â—Ź   Activity manager:
    â—Ź   920K
    â—Ź   30+ files
    â—Ź   20 kloc
9.2. Observing with “logcat”
 â—Ź   Find the System Server's PID
          $ adb shell ps | grep system_server
          system 63 32 120160 35408 ffffffff afd0c738 S system_server
 â—Ź   Look for its output:
          $ adb logcat | grep “63)”
...
D/PowerManagerService( 63): bootCompleted
I/TelephonyRegistry( 63): notifyServiceState: 0 home Android Android 310260 UMTS CSS not supp...
I/TelephonyRegistry( 63): notifyDataConnection: state=0 isDataConnectivityPossible=false reason=null interfaceName=null
networkType=3
I/SearchManagerService( 63): Building list of searchable activities
I/WifiService( 63): WifiService trying to setNumAllowed to 11 with persist set to true
I/ActivityManager( 63): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 ...
I/TelephonyRegistry( 63): notifyMessageWaitingChanged: false
I/TelephonyRegistry( 63): notifyCallForwardingChanged: false
I/TelephonyRegistry( 63): notifyDataConnection: state=1 isDataConnectivityPossible=true reason=simL...
I/TelephonyRegistry( 63): notifyDataConnection: state=2 isDataConnectivityPossible=true reason=simL...
D/Tethering( 63): MasterInitialState.processMessage what=3
I/ActivityManager( 63): Start proc android.process.media for broadcast com.android.providers.downloads/.DownloadReceiver:
pid=223 uid=10002 gids={1015, 2001, 3003}
I/RecoverySystem( 63): No recovery log file
W/WindowManager( 63): App freeze timeout expired.
...
9.3. Snapshot with “dumpsys”
Currently running services:
  SurfaceFlinger
  accessibility
  account
  activity
  alarm
  appwidget
  audio
  backup
...
  wifi
  window
-------------------------------------------------------------------------------
DUMP OF SERVICE SurfaceFlinger:
+ Layer 0x396b90
     z= 21000, pos=( 0, 0), size=( 480, 800), needsBlending=1, needsDithering=1, invalidat ...
0]
     name=com.android.launcher/com.android.launcher2.Launcher
     client=0x391e48, identity=6
     [ head= 1, available= 2, queued= 0 ] reallocMask=00000000, inUse=-1, identity=6, status=0
     format= 1, [480x800:480] [480x800:480], freezeLock=0x0, dq-q-time=53756 us
...
10. ActivityManager
â—Ź   Start new Activities, Services
â—Ź   Fetch Content Providers
â—Ź   Intent broadcasting
â—Ź   OOM adj. maintenance
â—Ź   Application Not Responding
â—Ź   Permissions
â—Ź   Task management
â—Ź   Lifecycle management
â—Ź   Ex. starting new app from Launcher:
      â—Ź   onClick(Launcher)
      â—Ź   startActivity(Activity.java)
      â—Ź   <Binder>
      â—Ź   ActivityManagerService
      â—Ź   startViaZygote(Process.java)
      â—Ź   <Socket>
      â—Ź   Zygote
11. Binder
â—Ź   CORBA/COM-like IPC
●   Data sent through “parcels” in “transactions”
â—Ź   Kernel-supported mechanism
â—Ź   /dev/binder
â—Ź   Check /proc/binder/*
â—Ź   android.* API connected to System Server
    through binder.
12. Stock AOSP Apps

/packages/apps                            /packages/providers      /packages/inputmethods

AccountsAndSettings    Launcher2          ApplicationProvider      LatinIME
AlarmClock             Mms                CalendarProvider         OpenWnn
Bluetooth              Music              ContactsProvider         PinyinIME
Browser                PackageInstaller   DownloadProvider
Calculator             Protips            DrmProvider
Calendar               Provision          GoogleContactsProvider
Camera                 QuickSearchBox     MediaProvider
CertInstaller          Settings           TelephonyProvider
Contacts               SoundRecorder      UserDictionaryProvider
DeskClock              SpeechRecorder
Email                  Stk
Gallery                VoiceDialer
HTMLViewer
13. Hacking
â—Ź   Source:
    ●   AOSP – source.android.com / android.git.kernel.org
    ●   Cyanogenmod – www.cyanogenmod.com
    ●   xdadevelopers – www.xda-developers.com
â—Ź   Tools:
    â—Ź   repo / git
    â—Ź   fastboot
    â—Ź   recovery
    ●   Kernel privilege escalation exploits -- “one-click root”
    â—Ź   ...
Thank you ...


karim.yaghmour@opersys.com

Android Internals

  • 1.
    Android Internals Android BuildersSummit – April 13th 2011 Karim Yaghmour karim.yaghmour@opersys.com @karimyaghmour
  • 2.
    About ... â—Ź Author of: â—Ź Introduced Linux Trace Toolkit in 1999 â—Ź Originated Adeos and relayfs (kernel/relay.c)
  • 3.
    1. Android Concepts 9. System Server 2. Overall Architecture 10.Activity Manager 3. System startup 11.Binder 4. Linux Kernel 12.Stock AOSP Apps 5. Hardware Support 13.Hacking 6. Native User-Space 7. Dalvik 8. JNI
  • 4.
    1. Android Concepts â—Ź Components â—Ź Intents â—Ź Component lifecycle â—Ź Manifest file â—Ź Processes and threads â—Ź Remote procedure calls
  • 5.
    1.1. Components â—Ź 1 App = N Components â—Ź Apps can use components of other applications â—Ź App processes are automagically started whenever any part is needed â—Ź Ergo: N entry points, !1, and !main() â—Ź Components: â—Ź Activities â—Ź Services â—Ź Broadcast Receivers â—Ź Content Providers
  • 6.
    1.2. Intents ● Intent = asynchronous message w/ or w/o designated target ● Like a polymorphic Unix signal, but w/o required target ● Intents “payload” held in Intent Object ● Intent Filters specified in Manifest file
  • 7.
    1.3. Component lifecycle â—Ź System automagically starts/stops/kills processes: â—Ź Entire system behaviour predicated on low memory â—Ź System triggers Lifecycle callbacks when relevant â—Ź Ergo: Must manage Component Lifecycle â—Ź Some Components are more complex to manage than others
  • 8.
    1.4. Manifest file ● Informs system about app’s components ● XML format ● Always called AndroidManifest.xml ● Activity = <activity> ... static ● Service = <service> ... static ● Broadcast Receiver: ● Static = <receiver> ● Dynamic = Context.registerReceiver() ● Content Provider = <provider> ... static
  • 9.
    1.5. Processes andthreads ● Processes ● Default: all callbacks to any app Component are issued to the main process thread ● <activity>—<service>—<recipient>—<provider> have process attribute to override default ● Do NOT perform blocking/long operations in main process thread: – Spawn threads instead ● Process termination/restart is at system’s discretion ● Therefore: – Must manage Component Lifecycle ● Threads: ● Create using the regular Java Thread Object ● Android API provides thread helper classes: – Looper: for running a message loop with a thread – Handler: for processing messages – HandlerThread: for setting up a thread with a message loop
  • 10.
    1.6. Remote procedurecalls â—Ź Apparently System V IPC is evil ... â—Ź Android RPCs = Binder mechanism â—Ź Binder is a low-level functionality, not used as-is â—Ź Instead: must define interface using Interface Definition Language (IDL) â—Ź IDL fed to aidl Tool to generate Java interface definitions
  • 11.
    1.7. Development tools ● SDK: ● android – manage AVDs and SDK components ● apkbuilder – creating .apk packages ● dx – converting .jar to .dex ● adb – debug bridge ● emulator – QEMU-based ARM emulator ● ... ● Eclipse w/ ADT plugin ● NDK: GNU toolchain for native binaries
  • 12.
  • 13.
  • 14.
    3. System Startup â—Ź Bootloader â—Ź Kernel â—Ź Init â—Ź Zygote â—Ź System Server â—Ź Activity Manager â—Ź Launcher (Home)
  • 15.
    3.1. Bootloader ● aosp/bootable/bootloader ● Custom bootloader for Android ● USB-based ● Implements the “fastboot” protocol ● Controlled via “fastboot” cli tool on host ● aosp/bootable/recovery ● UI-based recovery boot program ● Accessed through magic key sequence at boot ● Usually manufacturer specific variant
  • 16.
    ● Flash layout: 0x000003860000­0x000003900000 : "misc" 0x000003900000­0x000003e00000 : "recovery" 0x000003e00000­0x000004300000 : "boot" Kernel 0x000004300000­0x00000c300000 : "system" /system 0x00000c300000­0x0000183c0000 : "userdata" /data 0x0000183c0000­0x00001dd20000 : "cache" /cache 0x00001dd20000­0x00001df20000 : "kpanic" 0x00001df20000­0x00001df60000 : "dinfo" 0x00001df60000­0x00001dfc0000 : "setupdata" 0x00001dfc0000­0x00001e040000 : "splash1" 0x000000300000­0x000001680000 : "modem" From Acer Liquid-E
  • 17.
    3.2. Kernel â—Ź Early startup code is very hardware dependent â—Ź Initializes environment for the running of C code â—Ź Jumps to the architecture-independent start_kernel() function. â—Ź Initializes high-level kernel subsystems â—Ź Mounts root filesystem â—Ź Starts the init process
  • 18.
    3.3. Android Init ● Open, parses, and runs /init.rc: ● Create mountpoints and mount filesystems ● Set up filesystem permissions ● Set OOM adjustments properties ● Start daemons: – adbd – servicemanager (binder context manager) – vold – netd – rild – app_process -Xzygote (Zygote) – mediaserver – ...
  • 19.
    3.4. Zygote, etc. ● Init: ● app_process -Xzygote (Zygote) ● frameworks/base/cmds/app_process/app_main.cpp: ● runtime.start(“com.android.internal.os.Zygote”, ... ● frameworks/base/core/jni/AndroidRuntime.cpp: ● startVM() ● Call Zygote's main() ● frameworks/base/core/java/com/android/internal/os/Zy goteInit.java: ● ...
  • 20.
    ● preloadClasses() ● startSystemServer() ● ... magic ... ● Call SystemServer's run() ● frameworks/base/services/java/com/android/server /SystemServer.java: ● Start all system services/managers ● Start ActivityManager: – Send Intent.CATEGORY_HOME – Launcher2 kicks in
  • 21.
  • 22.
    4.1. Androidisms ● Wakelocks ● lowmem handler ● Binder ● ashmem – Anonymous Shared Memory ● RAM console ● Logger ● ...
  • 23.
    5. Hardware support Bluetooth BlueZ through D-BUS IPC (to avoid GPL contamination it seems) GPS Manufacturer-provided libgps.so Wifi wpa_supplicant Display Std framebuffer driver (/dev/fb0) Keymaps and Keyboards Std input event (/dev/event0) Lights Manufacturer-provided liblights.so Backlight Keyboard Buttons Battery Notifications Attention Audio Manufacturer-provided libaudio.so (could use ALSA underneath ... at least as illustrated in their porting guide) Camera Manufacturer-provided libcamera.so (could use V4L2 kernel driver underneath ... as illustrated in porting guide) Power Management “Wakelocks” kernel patch Sensors Manufacturer-provided libsensors.so Accelerometer Magnetic Field Orientation Gyroscope Light Pressure Temperature Proximity Radio Layer Interface Manufacturer-provided libril-<companyname>-<RIL version>.so
  • 24.
    6. Native User-Space â—Ź Mainly â—Ź /data => User data â—Ź /system => System components â—Ź Also found: â—Ź /cache â—Ź /mnt â—Ź /sbin â—Ź Etc.
  • 25.
    â—Ź Libs: Bionic, SQLite, SSL, OpenGL|ES, Non-Posix: limited Pthreads support, no SysV IPC â—Ź Toolbox â—Ź Daemons: servicemanager, vold, rild, netd, adbd, ...
  • 26.
    7. Dalvik â—Ź Sun-Java = Java language + JVM + JDK libs â—Ź Android Java = Java language + Dalvik + Apache Harmony â—Ź Target: â—Ź Slow CPU â—Ź Relatively low RAM â—Ź OS without swap space â—Ź Battery powered â—Ź Now has JIT
  • 27.
    7.1. Dalvik's .dexfiles ● JVM munches on “.class” files ● Dalvik munches on “.dex” files ● .dex file = .class files post-processed by “dx” utility ● Uncompressed .dex = 0.5 * Uncompressed .jar
  • 28.
    8. JNI –Java Native Interface ● Call gate for other languages, such as C, C++ ● Equivalent to .NET's pinvoke ● Usage: include and call native code from App ● Tools = NDK ... samples included ● Check out “JNI Programmer's Guide and Specification” - freely available PDF
  • 29.
    9. System Server EntropyService Device Policy Audio Service Power Manager Status Bar Headset Observer Activity Manager Clipboard Service Dock Observer Telephone Registry Input Method Service UI Mode Manager Service Package Manager NetStat Service Backup Service Account Manager NetworkManagement Service AppWidget Service Content Manager Connectivity Service Recognition Service System Content Providers Throttle Service Status Bar Icons Battery Service Accessibility Manager DiskStats Service Lights Service Mount Service ADB Settings Observer Vibrator Service Notification Manager Alarm Manager Device Storage Monitor Init Watchdog Location Manager Sensor Service Search Service Window Manager DropBox Service Bluetooth Service Wallpaper Service
  • 30.
    9.1. Some stats â—Ź frameworks/base/services/java/com/android/ser ver: â—Ź 3.5 M â—Ź ~100 files â—Ź 85 kloc â—Ź Activity manager: â—Ź 920K â—Ź 30+ files â—Ź 20 kloc
  • 31.
    9.2. Observing with“logcat” ● Find the System Server's PID $ adb shell ps | grep system_server system 63 32 120160 35408 ffffffff afd0c738 S system_server ● Look for its output: $ adb logcat | grep “63)” ... D/PowerManagerService( 63): bootCompleted I/TelephonyRegistry( 63): notifyServiceState: 0 home Android Android 310260 UMTS CSS not supp... I/TelephonyRegistry( 63): notifyDataConnection: state=0 isDataConnectivityPossible=false reason=null interfaceName=null networkType=3 I/SearchManagerService( 63): Building list of searchable activities I/WifiService( 63): WifiService trying to setNumAllowed to 11 with persist set to true I/ActivityManager( 63): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 ... I/TelephonyRegistry( 63): notifyMessageWaitingChanged: false I/TelephonyRegistry( 63): notifyCallForwardingChanged: false I/TelephonyRegistry( 63): notifyDataConnection: state=1 isDataConnectivityPossible=true reason=simL... I/TelephonyRegistry( 63): notifyDataConnection: state=2 isDataConnectivityPossible=true reason=simL... D/Tethering( 63): MasterInitialState.processMessage what=3 I/ActivityManager( 63): Start proc android.process.media for broadcast com.android.providers.downloads/.DownloadReceiver: pid=223 uid=10002 gids={1015, 2001, 3003} I/RecoverySystem( 63): No recovery log file W/WindowManager( 63): App freeze timeout expired. ...
  • 32.
    9.3. Snapshot with“dumpsys” Currently running services: SurfaceFlinger accessibility account activity alarm appwidget audio backup ... wifi window ------------------------------------------------------------------------------- DUMP OF SERVICE SurfaceFlinger: + Layer 0x396b90 z= 21000, pos=( 0, 0), size=( 480, 800), needsBlending=1, needsDithering=1, invalidat ... 0] name=com.android.launcher/com.android.launcher2.Launcher client=0x391e48, identity=6 [ head= 1, available= 2, queued= 0 ] reallocMask=00000000, inUse=-1, identity=6, status=0 format= 1, [480x800:480] [480x800:480], freezeLock=0x0, dq-q-time=53756 us ...
  • 33.
    10. ActivityManager â—Ź Start new Activities, Services â—Ź Fetch Content Providers â—Ź Intent broadcasting â—Ź OOM adj. maintenance â—Ź Application Not Responding â—Ź Permissions â—Ź Task management â—Ź Lifecycle management
  • 34.
    â—Ź Ex. starting new app from Launcher: â—Ź onClick(Launcher) â—Ź startActivity(Activity.java) â—Ź <Binder> â—Ź ActivityManagerService â—Ź startViaZygote(Process.java) â—Ź <Socket> â—Ź Zygote
  • 35.
    11. Binder ● CORBA/COM-like IPC ● Data sent through “parcels” in “transactions” ● Kernel-supported mechanism ● /dev/binder ● Check /proc/binder/* ● android.* API connected to System Server through binder.
  • 37.
    12. Stock AOSPApps /packages/apps /packages/providers /packages/inputmethods AccountsAndSettings Launcher2 ApplicationProvider LatinIME AlarmClock Mms CalendarProvider OpenWnn Bluetooth Music ContactsProvider PinyinIME Browser PackageInstaller DownloadProvider Calculator Protips DrmProvider Calendar Provision GoogleContactsProvider Camera QuickSearchBox MediaProvider CertInstaller Settings TelephonyProvider Contacts SoundRecorder UserDictionaryProvider DeskClock SpeechRecorder Email Stk Gallery VoiceDialer HTMLViewer
  • 38.
    13. Hacking ● Source: ● AOSP – source.android.com / android.git.kernel.org ● Cyanogenmod – www.cyanogenmod.com ● xdadevelopers – www.xda-developers.com ● Tools: ● repo / git ● fastboot ● recovery ● Kernel privilege escalation exploits -- “one-click root” ● ...
  • 39.