Android internals
     Egor Elizarov
     SPbSU 2012
Legal info
   Android internals by Egor Elizarov is licensed under a
    Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License

   You are free to
      – copy, distribute, display, and perform the work
      – make derivative works
   Under the following conditions
       – Attribution. You must give the original author credit
       – Share Alike. If you alter, transform, or build upon this work, you may
         distribute the resulting work only under a license identical to this one
   All pictures and trademarks are the property of their respective owners. Use of
    these trademarks and pictures is subject to owners permissions.
   Corrections, suggestions, contributions and translations are welcome!



                                          2                                 Egor Elizarov SPbSU 2012
Lecture 6



                                Android IPC
                          Typical Android subsystem


                                                      yegor.yelizarov(at)gmail.com
Rev: 1.1
Last update: 06/01/2012                           http://vk.com/android_internals


                                      3                             Egor Elizarov SPbSU 2012
Previous time

    VM types

    Virtualization approaches

    Dalvik VM features

    Interpreter core types

    JIT algorithm

    Android application start up process

                             4             Egor Elizarov SPbSU 2012
IPC Approaches


    Classic
    – System V IPC
    – Posix IPC


    Modern
    – Binder
    – Cross Memory Attach (CMA)
    – KNEM
    – Kdbus

                         5        Egor Elizarov SPbSU 2012
Linux IPC


    Pipe

    Socket

    Signal

    Semaphore

    Message queue

    Shared memory
                    6       Egor Elizarov SPbSU 2012
Binder


    Lightweight IPC/RPC

    Customized re-implementation of Open Binder

    BeOS -> ACCESS/PalmOS -> Open Binder

    Per process thread pool for processing requests

    Synchronous calls between processes

    Zero copy message transmission
                           7                    Egor Elizarov SPbSU 2012
Socket vs Binder


                                         Binder
          Socket
                               
                                   Associated with PID

    Associated with FD
                               
                                   Local only

    Network transparency
                               
                                   Communication via

    Stream IO read/write
                                   IOCTL


                           8                      Egor Elizarov SPbSU 2012
Binder facilities




        9           Egor Elizarov SPbSU 2012
Parcels and marshalling


    Parcel is a message to be send through Binder

    Different types of data can be marshalled
    (packed) in parcels

    To make remote procedure call binder
    marshalles function arguments and meta data,
    sends it to remote process and unpacks the
    results

                          10                    Egor Elizarov SPbSU 2012
RPC main idea




      11        Egor Elizarov SPbSU 2012
OOP patterns used in Binder


    Bridge



    Mediator



    Proxy



                 12          Egor Elizarov SPbSU 2012
Application layer




        13          Egor Elizarov SPbSU 2012
Application layer transaction




              14          Egor Elizarov SPbSU 2012
Android Interface Definition Language




                  15            Egor Elizarov SPbSU 2012
AIDL example




     16        Egor Elizarov SPbSU 2012
Application layer internals




             17           Egor Elizarov SPbSU 2012
Service Manager

    Special Binder node with known address

    Provide information about existing services

    All services should be registered in Service
    Manager (name & binder token)

    Command line tool: adb service

    sp<IBinder> binder = defaultServiceManager()
    ->getService(String16("media.player"));
                           18                      Egor Elizarov SPbSU 2012
Service Manager workflow




           19         Egor Elizarov SPbSU 2012
Middleware layer



    Provide binder facilities to java framework

    Marshalling/unmarshalling Parcels

    Interaction with kernel

    Managing threads



                              20                  Egor Elizarov SPbSU 2012
Middleware layer internals




            21           Egor Elizarov SPbSU 2012
Kernel layer




     22        Egor Elizarov SPbSU 2012
Binder in action




       23          Egor Elizarov SPbSU 2012
Typical subsytem


    Main logic is implemented in frameworks

    C++ layer contains some servers (Ex:
    mediaserver) connected to java framework via
    Binder

    Use standard external libraries (Ex: libBluez)

    HAL as interface for HW vendors

                           24                   Egor Elizarov SPbSU 2012
Typical subsystem scheme




           25          Egor Elizarov SPbSU 2012
Next Time




    Graphic subsystem

    HW acceleration




                        26   Egor Elizarov SPbSU 2012
Useful links


    http://vk.com/android_internals


    http://0xlab.org/~jserv/android-binder-ipc.pdf


    http://cs736-android.pbworks.com/w/page/5834468/IPC
    %20Binder


    http://www.angryredplanet.com/~hackbod/openbinder/docs/
    html/BinderIPCMechanism.html


    http://mylifewithandroid.blogspot.com/2008/01/about-
    binders.html

                                27                         Egor Elizarov SPbSU 2012
Useful links (2)

    http://free-electrons.com/doc/posix-api.pdf

    http://lwn.net/Articles/466304/

    http://www.slideshare.net/opersys/android-
    internals

    https://github.com/keesj/gomo/wiki/AndroidNati
    veBinder

    http://lwn.net/Articles/472984/
                           28                     Egor Elizarov SPbSU 2012
Thanks to


    Sergey Matyukevich for review and advices
    (www.linkedin.com/pub/sergey-matyukevich/31/889/769)


    Nikolay F. Fominykh for review and advices


    Nikita Shulga for advices and notes
    (http://www.linkedin.com/pub/nikita-shulga/8/582/287)


    Grigory Tolstolytkin for advices and notes
    (http://www.linkedin.com/pub/grigory-
    tolstolytkin/2a/b41/74)


                                29                      Egor Elizarov SPbSU 2012

More Related Content

PDF
Android internals 05 - Dalvik VM (rev_1.1)
PDF
Android internals 01 - Basic concepts of mobile platforms (rev_1.1)
PDF
Android internals 08 - System start up, Media subsystem (rev_1.1)
PDF
Android internals 04 - “Androdized” kernel, Bionic, Logging subsystem (rev_1.1)
PDF
Android internals 09 - Sensors, Power Management, Input subsystem, Data stora...
PDF
Android internals 03 - Build system, emulator (rev_1.1)
PDF
Android internals 00 - Introduction (rev_1.1)
PDF
Android internals 02 - High-level architecture, version control system (rev_1.1)
Android internals 05 - Dalvik VM (rev_1.1)
Android internals 01 - Basic concepts of mobile platforms (rev_1.1)
Android internals 08 - System start up, Media subsystem (rev_1.1)
Android internals 04 - “Androdized” kernel, Bionic, Logging subsystem (rev_1.1)
Android internals 09 - Sensors, Power Management, Input subsystem, Data stora...
Android internals 03 - Build system, emulator (rev_1.1)
Android internals 00 - Introduction (rev_1.1)
Android internals 02 - High-level architecture, version control system (rev_1.1)

Viewers also liked (19)

PDF
Android internals 07 - Android graphics (rev_1.1)
PDF
Android internals 10 - Debugging/Profiling, Bluetooth/WiFI/RIL (rev_1.1)
PDF
Making Linux do Hard Real-time
PPTX
Game controlling via android
PDF
Smart Phone CPU
PPTX
Samsung processors: Exynos family
PDF
Android Sensors
PDF
Review Multicore processing based on ARM architecture
PDF
Introduction to Android Window System
PDF
Performance Comparison Between x86 and ARM Assembly
PDF
Motion recognition with Android devices
PDF
Improve Android System Component Performance
PPTX
Android location and sensors API
PPTX
Arm corrected ppt
PPTX
CPU Architectures for Mobile Phone Devices
PPT
Risc and cisc eugene clewlow
PPTX
Intel & ARM: Strategic Comparison
PPT
Risc processors
PDF
Explore Android Internals
Android internals 07 - Android graphics (rev_1.1)
Android internals 10 - Debugging/Profiling, Bluetooth/WiFI/RIL (rev_1.1)
Making Linux do Hard Real-time
Game controlling via android
Smart Phone CPU
Samsung processors: Exynos family
Android Sensors
Review Multicore processing based on ARM architecture
Introduction to Android Window System
Performance Comparison Between x86 and ARM Assembly
Motion recognition with Android devices
Improve Android System Component Performance
Android location and sensors API
Arm corrected ppt
CPU Architectures for Mobile Phone Devices
Risc and cisc eugene clewlow
Intel & ARM: Strategic Comparison
Risc processors
Explore Android Internals
Ad

Similar to Android internals 06 - Binder, Typical subsystem (rev_1.1) (20)

PDF
Effortless network response logging on Android
ODP
Introduction to Spring Framework and Spring IoC
PDF
Readactor-Practical Code Randomization Resilient to Memory Disclosure
PDF
Designing An Android Sensor Subsystem and Solving Common Sensor Problems
PDF
MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...
PDF
An introduction to the Spring Framework
PDF
Android Native Development Kit
DOCX
Spring notes
PDF
Setting up a vscode development environment for mbed 5 application using the ...
PDF
ELB를 활용한 Socket.IO 멀티노드 구축사례
PDF
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
PDF
Cross Platform Mobile Apps with the Ionic Framework
PDF
FEL 12 Release Notes
PPTX
Spring Architecture | Advanced Java
PPTX
COBOL deployment to .Net or JVM - Developer Day
PPSX
TheSpringFramework
PDF
Kandroid for nhn_deview_20131013_v5_final
ODP
Os Grossupdated
PDF
[JavaOne] Demystifying WebSockets - Build a Cool, Real-time Multi-player Game...
PDF
Molome infrastructure
Effortless network response logging on Android
Introduction to Spring Framework and Spring IoC
Readactor-Practical Code Randomization Resilient to Memory Disclosure
Designing An Android Sensor Subsystem and Solving Common Sensor Problems
MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...
An introduction to the Spring Framework
Android Native Development Kit
Spring notes
Setting up a vscode development environment for mbed 5 application using the ...
ELB를 활용한 Socket.IO 멀티노드 구축사례
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Cross Platform Mobile Apps with the Ionic Framework
FEL 12 Release Notes
Spring Architecture | Advanced Java
COBOL deployment to .Net or JVM - Developer Day
TheSpringFramework
Kandroid for nhn_deview_20131013_v5_final
Os Grossupdated
[JavaOne] Demystifying WebSockets - Build a Cool, Real-time Multi-player Game...
Molome infrastructure
Ad

Recently uploaded (20)

PDF
Physical pharmaceutics two in b pharmacy
PDF
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
PPTX
MMW-CHAPTER-1-final.pptx major Elementary Education
PDF
FYJC - Chemistry textbook - standard 11.
PDF
faiz-khans about Radiotherapy Physics-02.pdf
PDF
GIÁO ÁN TIẾNG ANH 7 GLOBAL SUCCESS (CẢ NĂM) THEO CÔNG VĂN 5512 (2 CỘT) NĂM HỌ...
PDF
GSA-Past-Papers-2010-2024-2.pdf CSS examination
DOCX
THEORY AND PRACTICE ASSIGNMENT SEMESTER MAY 2025.docx
PPTX
Diploma pharmaceutics notes..helps diploma students
PDF
Review of Related Literature & Studies.pdf
PDF
Diabetes Mellitus , types , clinical picture, investigation and managment
PPTX
principlesofmanagementsem1slides-131211060335-phpapp01 (1).ppt
PDF
LATAM’s Top EdTech Innovators Transforming Learning in 2025.pdf
PPT
hsl powerpoint resource goyloveh feb 07.ppt
PDF
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
PDF
Chevening Scholarship Application and Interview Preparation Guide
PPSX
namma_kalvi_12th_botany_chapter_9_ppt.ppsx
PPTX
IT infrastructure and emerging technologies
PPTX
Copy of ARAL Program Primer_071725(1).pptx
PPTX
ACFE CERTIFICATION TRAINING ON LAW.pptx
Physical pharmaceutics two in b pharmacy
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
MMW-CHAPTER-1-final.pptx major Elementary Education
FYJC - Chemistry textbook - standard 11.
faiz-khans about Radiotherapy Physics-02.pdf
GIÁO ÁN TIẾNG ANH 7 GLOBAL SUCCESS (CẢ NĂM) THEO CÔNG VĂN 5512 (2 CỘT) NĂM HỌ...
GSA-Past-Papers-2010-2024-2.pdf CSS examination
THEORY AND PRACTICE ASSIGNMENT SEMESTER MAY 2025.docx
Diploma pharmaceutics notes..helps diploma students
Review of Related Literature & Studies.pdf
Diabetes Mellitus , types , clinical picture, investigation and managment
principlesofmanagementsem1slides-131211060335-phpapp01 (1).ppt
LATAM’s Top EdTech Innovators Transforming Learning in 2025.pdf
hsl powerpoint resource goyloveh feb 07.ppt
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
Chevening Scholarship Application and Interview Preparation Guide
namma_kalvi_12th_botany_chapter_9_ppt.ppsx
IT infrastructure and emerging technologies
Copy of ARAL Program Primer_071725(1).pptx
ACFE CERTIFICATION TRAINING ON LAW.pptx

Android internals 06 - Binder, Typical subsystem (rev_1.1)

  • 1. Android internals Egor Elizarov SPbSU 2012
  • 2. Legal info  Android internals by Egor Elizarov is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License  You are free to – copy, distribute, display, and perform the work – make derivative works  Under the following conditions – Attribution. You must give the original author credit – Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one  All pictures and trademarks are the property of their respective owners. Use of these trademarks and pictures is subject to owners permissions.  Corrections, suggestions, contributions and translations are welcome! 2 Egor Elizarov SPbSU 2012
  • 3. Lecture 6 Android IPC Typical Android subsystem yegor.yelizarov(at)gmail.com Rev: 1.1 Last update: 06/01/2012 http://vk.com/android_internals 3 Egor Elizarov SPbSU 2012
  • 4. Previous time  VM types  Virtualization approaches  Dalvik VM features  Interpreter core types  JIT algorithm  Android application start up process 4 Egor Elizarov SPbSU 2012
  • 5. IPC Approaches  Classic – System V IPC – Posix IPC  Modern – Binder – Cross Memory Attach (CMA) – KNEM – Kdbus 5 Egor Elizarov SPbSU 2012
  • 6. Linux IPC  Pipe  Socket  Signal  Semaphore  Message queue  Shared memory 6 Egor Elizarov SPbSU 2012
  • 7. Binder  Lightweight IPC/RPC  Customized re-implementation of Open Binder  BeOS -> ACCESS/PalmOS -> Open Binder  Per process thread pool for processing requests  Synchronous calls between processes  Zero copy message transmission 7 Egor Elizarov SPbSU 2012
  • 8. Socket vs Binder Binder Socket  Associated with PID  Associated with FD  Local only  Network transparency  Communication via  Stream IO read/write IOCTL 8 Egor Elizarov SPbSU 2012
  • 9. Binder facilities 9 Egor Elizarov SPbSU 2012
  • 10. Parcels and marshalling  Parcel is a message to be send through Binder  Different types of data can be marshalled (packed) in parcels  To make remote procedure call binder marshalles function arguments and meta data, sends it to remote process and unpacks the results 10 Egor Elizarov SPbSU 2012
  • 11. RPC main idea 11 Egor Elizarov SPbSU 2012
  • 12. OOP patterns used in Binder  Bridge  Mediator  Proxy 12 Egor Elizarov SPbSU 2012
  • 13. Application layer 13 Egor Elizarov SPbSU 2012
  • 14. Application layer transaction 14 Egor Elizarov SPbSU 2012
  • 15. Android Interface Definition Language 15 Egor Elizarov SPbSU 2012
  • 16. AIDL example 16 Egor Elizarov SPbSU 2012
  • 17. Application layer internals 17 Egor Elizarov SPbSU 2012
  • 18. Service Manager  Special Binder node with known address  Provide information about existing services  All services should be registered in Service Manager (name & binder token)  Command line tool: adb service  sp<IBinder> binder = defaultServiceManager() ->getService(String16("media.player")); 18 Egor Elizarov SPbSU 2012
  • 19. Service Manager workflow 19 Egor Elizarov SPbSU 2012
  • 20. Middleware layer  Provide binder facilities to java framework  Marshalling/unmarshalling Parcels  Interaction with kernel  Managing threads 20 Egor Elizarov SPbSU 2012
  • 21. Middleware layer internals 21 Egor Elizarov SPbSU 2012
  • 22. Kernel layer 22 Egor Elizarov SPbSU 2012
  • 23. Binder in action 23 Egor Elizarov SPbSU 2012
  • 24. Typical subsytem  Main logic is implemented in frameworks  C++ layer contains some servers (Ex: mediaserver) connected to java framework via Binder  Use standard external libraries (Ex: libBluez)  HAL as interface for HW vendors 24 Egor Elizarov SPbSU 2012
  • 25. Typical subsystem scheme 25 Egor Elizarov SPbSU 2012
  • 26. Next Time  Graphic subsystem  HW acceleration 26 Egor Elizarov SPbSU 2012
  • 27. Useful links  http://vk.com/android_internals  http://0xlab.org/~jserv/android-binder-ipc.pdf  http://cs736-android.pbworks.com/w/page/5834468/IPC %20Binder  http://www.angryredplanet.com/~hackbod/openbinder/docs/ html/BinderIPCMechanism.html  http://mylifewithandroid.blogspot.com/2008/01/about- binders.html 27 Egor Elizarov SPbSU 2012
  • 28. Useful links (2)  http://free-electrons.com/doc/posix-api.pdf  http://lwn.net/Articles/466304/  http://www.slideshare.net/opersys/android- internals  https://github.com/keesj/gomo/wiki/AndroidNati veBinder  http://lwn.net/Articles/472984/ 28 Egor Elizarov SPbSU 2012
  • 29. Thanks to  Sergey Matyukevich for review and advices (www.linkedin.com/pub/sergey-matyukevich/31/889/769)  Nikolay F. Fominykh for review and advices  Nikita Shulga for advices and notes (http://www.linkedin.com/pub/nikita-shulga/8/582/287)  Grigory Tolstolytkin for advices and notes (http://www.linkedin.com/pub/grigory- tolstolytkin/2a/b41/74) 29 Egor Elizarov SPbSU 2012