SlideShare a Scribd company logo
Inter-process method invocation
           in Android

               2011.4.9


         Tetsuyuki Kobayashi

                                  1
Who am I?

   20+ years involved in embedded systems
       10 years in real time OS, such as iTRON
       10 years in embedded Java Virtual Machine
       Now GCC, Linux, QEMU, Android, …
   Blogs
       http://d.hatena.ne.jp/embedded/ (Personal)
       http://blog.kmckk.com/ (Corporate)
   Twitter
       @tetsu_koba
                                                     2
Today's topic

   inter process communications in
    Android
   Inter process method invocation
    using Binder
   AIDL
   Example of inter process
    method invocation
                                      3
Inter Process Communication



                 Activity
      Activity              Window     Alarm
      Manager               Manager   Manager




 Kernel




                                                4
Abstraction of Inter Process
      Communication
                            More abstract
          Intent


              AIDL


                   Binder




   No need to use Binder directly.
   AIDL requires multi-thread programming
                                                      5
   In most case Intent is easy and powerful enough.
Invoking method via interface


             caller




             callee


       In the same process


                                6
Inter-process invocation

                     caller
                                interface



caller

         interface
                         How?
callee

                                interface


                     callee
                                            7
Inter-process invocation

                        caller
                                         interface


                        Proxy
caller

         interface    Binder in kernel


                     Binder Thread
callee
                          Stub
                                         interface


                        callee
                                                     8
android.os.Parcel


            Delivering arguments of method




”flatten”                                    ”unflatten”


                      transmit
                                                      9
Describing in UML ...


           <<interface>>




   Proxy                   Stub




                                  10
Describing in UML ...
                                    caller



           <<interface>>              calls


                      implements


   Proxy                   Stub

                                  extends

                           callee

                                              11
AIDL
Auto generated from .aidl file                      caller



                           <<interface>>




                   Proxy                   Stub



                                           callee

                                                             12
Use case: Who calls ”onPause”
          in Activity?
                    2:Send message     Activity
                       by Handler
                                                  3:”onPause”
                                                    is called
                  queue                Looper        in main
                                                     thread
   Activity
   Manager                               Main
                                          Main
                   Binder               Thread
                                         Thread
                    Binder
                  Thread #1
                   Thread #1




 Kernel
              1:Call ”schedulePauseActivity”
                      across process

                                                                13
Binder

   /etc/binder
   Not for general purpose. Tuned for specific
    transaction.
   Multi-thread aware
       Have internal data per thead
       (CF. Socket have internal data per fd.)
   Not use ”write” and ”read”. Write and read at
    once by ”ioctl”.

                                                    14
Transaction of Binder
                          Process A and B have different memory space.
                          They can not see each other.
Kernel                         Process B
                            Process A
         Binder



                  Copy memory by copy_from _user
                  Then, wake up process B

Kernel
                                Process B
         Binder



                            Process A
                  Copy memory by copy_to_user
                                                                         15
See also
        rd

    3 session of Yokohama Android Platform club
        http://www.yokohama.android-pf.org/study/dai-san-kai-benkyou-kai

    1st session of Android SDK work group
        http://www.android-group.jp/index.php?%CA%D9%B6%AF%B2%F1%2FAndr
   KMC blog
        http://blog.kmckk.com/archives/3611344.html
        http://blog.kmckk.com/archives/3613707.html
        http://blog.kmckk.com/archives/3627888.html
        http://blog.kmckk.com/archives/3645070.html
        http://blog.kmckk.com/archives/3647635.html
        http://blog.kmckk.com/archives/3617229.html
                                                                            16
Q&A




Thank you for listening!
Any comments to blogs are welcome.

                                     17

More Related Content

PDF
Android IPC Mechanism
PDF
Explore Android Internals
PDF
Low Level View of Android System Architecture
PDF
Understanding the Android System Server
PDF
Embedded Android Workshop with Pie
PDF
Embedded Android : System Development - Part II (HAL)
PDF
Android Things : Building Embedded Devices
ODP
Q4.11: Porting Android to new Platforms
Android IPC Mechanism
Explore Android Internals
Low Level View of Android System Architecture
Understanding the Android System Server
Embedded Android Workshop with Pie
Embedded Android : System Development - Part II (HAL)
Android Things : Building Embedded Devices
Q4.11: Porting Android to new Platforms

What's hot (20)

PDF
Android Boot Time Optimization
PDF
Android's HIDL: Treble in the HAL
PPTX
Android Binder: Deep Dive
PDF
Embedded Android : System Development - Part II (Linux device drivers)
PDF
Android device driver structure introduction
PPT
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
PPTX
Binder: Android IPC
PDF
Android Binder IPC for Linux
PPTX
Overview of Android binder IPC implementation
PDF
Kernel Module Programming
PDF
Design and Concepts of Android Graphics
PDF
Embedded Android : System Development - Part IV (Android System Services)
PDF
Embedded Android : System Development - Part I
PDF
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
ODP
Embedded Android : System Development - Part III
PDF
Embedded Android Workshop
PPTX
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
PDF
Android Internals
PDF
Understanding binder in android
PPT
Android booting sequece and setup and debugging
Android Boot Time Optimization
Android's HIDL: Treble in the HAL
Android Binder: Deep Dive
Embedded Android : System Development - Part II (Linux device drivers)
Android device driver structure introduction
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Binder: Android IPC
Android Binder IPC for Linux
Overview of Android binder IPC implementation
Kernel Module Programming
Design and Concepts of Android Graphics
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part I
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Embedded Android : System Development - Part III
Embedded Android Workshop
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android Internals
Understanding binder in android
Android booting sequece and setup and debugging
Ad

Viewers also liked (20)

PDF
Using QEMU for cross development
PDF
Android binder-ipc
PDF
Tricky implementation of Go ARM soft float
PPTX
IPC: AIDL is not a curse
PDF
QEMU in Cross building
PDF
Android On Ubuntu for developer
PDF
波形で見るBig.little
PDF
Unix v6 セミナー vol. 5
PDF
Logging system of Android
PDF
Froyo DalvikVM JIT
PDF
Oscar compiler for power reduction
PDF
Reusing your existing software on Android
PDF
Tips of Malloc & Free
PDF
V6 unix in okinawa
PDF
自動並列化コンパイラをAndroidに適用してみた
PDF
Deep learning入門
PDF
Binderのはじめの一歩とAndroid
PDF
Logging system of Android
PDF
Deep dive into Android Data Binding
PDF
Basic of virtual memory of Linux
Using QEMU for cross development
Android binder-ipc
Tricky implementation of Go ARM soft float
IPC: AIDL is not a curse
QEMU in Cross building
Android On Ubuntu for developer
波形で見るBig.little
Unix v6 セミナー vol. 5
Logging system of Android
Froyo DalvikVM JIT
Oscar compiler for power reduction
Reusing your existing software on Android
Tips of Malloc & Free
V6 unix in okinawa
自動並列化コンパイラをAndroidに適用してみた
Deep learning入門
Binderのはじめの一歩とAndroid
Logging system of Android
Deep dive into Android Data Binding
Basic of virtual memory of Linux
Ad

Similar to Android ipm 20110409 (20)

KEY
Integration and Batch Processing on Cloud Foundry
PDF
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
PDF
Cluster management with Kubernetes
PDF
Dockerize it: stop living in the past and embrace the future by Alex Nadalin
PDF
Dockerize it! @ Codemotion 2016 in Rome
PDF
Dockerize it: stop living in the past and embrace the future
PPTX
Developer Friendly API Design
PDF
Scaling docker with kubernetes
KEY
Spring in the Cloud - using Spring with Cloud Foundry
PDF
Rooting Out Root: User namespaces in Docker
PDF
Find your own iOS kernel bug
PDF
Demystfying container-networking
PDF
DockerCon 2022 - From legacy to Kubernetes, securely & quickly
PDF
stackconf 2024 | Buzzing across the eBPF Landscape and into the Hive by Bill ...
PDF
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
PDF
Evented applications with RabbitMQ and CakePHP
KEY
Concurrency in ruby
PDF
Barcamp PT
PPTX
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
PPTX
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
Integration and Batch Processing on Cloud Foundry
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
Cluster management with Kubernetes
Dockerize it: stop living in the past and embrace the future by Alex Nadalin
Dockerize it! @ Codemotion 2016 in Rome
Dockerize it: stop living in the past and embrace the future
Developer Friendly API Design
Scaling docker with kubernetes
Spring in the Cloud - using Spring with Cloud Foundry
Rooting Out Root: User namespaces in Docker
Find your own iOS kernel bug
Demystfying container-networking
DockerCon 2022 - From legacy to Kubernetes, securely & quickly
stackconf 2024 | Buzzing across the eBPF Landscape and into the Hive by Bill ...
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
Evented applications with RabbitMQ and CakePHP
Concurrency in ruby
Barcamp PT
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final

More from Tetsuyuki Kobayashi (20)

PDF
some topic of ffmpeg
PDF
New VIdeo CODEC AV1
PDF
Try new transport protocol SRT (ver. 2)
PDF
Try new transport protocol SRT
PDF
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
PDF
WebOS Open Source Edition を試してみた
PDF
Linuxのユーザーランドをinitから全てまるごとgolangで書く
PDF
組み込みLinuxでのGolangのススメ(Go con版)
PDF
組み込みLinuxでのGolangのススメ
PDF
ARM 64bit has come!
PDF
Virtual memory 20070222-en
PDF
Simple and efficient way to get the last log using MMAP
PDF
PDF
ADB(Android Debug Bridge): How it works?
PDF
Tweaking Google TV emulator
ODP
Inter-process communication of Android
PDF
Android is NOT just 'Java on Linux'
PDF
Init of Android
PDF
Let's play with Goldfish
PDF
Opensource Android
some topic of ffmpeg
New VIdeo CODEC AV1
Try new transport protocol SRT (ver. 2)
Try new transport protocol SRT
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
WebOS Open Source Edition を試してみた
Linuxのユーザーランドをinitから全てまるごとgolangで書く
組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ
ARM 64bit has come!
Virtual memory 20070222-en
Simple and efficient way to get the last log using MMAP
ADB(Android Debug Bridge): How it works?
Tweaking Google TV emulator
Inter-process communication of Android
Android is NOT just 'Java on Linux'
Init of Android
Let's play with Goldfish
Opensource Android

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Encapsulation theory and applications.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
KodekX | Application Modernization Development
PDF
Electronic commerce courselecture one. Pdf
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
Machine learning based COVID-19 study performance prediction
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Dropbox Q2 2025 Financial Results & Investor Presentation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Encapsulation theory and applications.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KodekX | Application Modernization Development
Electronic commerce courselecture one. Pdf
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf

Android ipm 20110409

  • 1. Inter-process method invocation in Android 2011.4.9 Tetsuyuki Kobayashi 1
  • 2. Who am I?  20+ years involved in embedded systems  10 years in real time OS, such as iTRON  10 years in embedded Java Virtual Machine  Now GCC, Linux, QEMU, Android, …  Blogs  http://d.hatena.ne.jp/embedded/ (Personal)  http://blog.kmckk.com/ (Corporate)  Twitter  @tetsu_koba 2
  • 3. Today's topic  inter process communications in Android  Inter process method invocation using Binder  AIDL  Example of inter process method invocation 3
  • 4. Inter Process Communication Activity Activity Window Alarm Manager Manager Manager Kernel 4
  • 5. Abstraction of Inter Process Communication More abstract Intent AIDL Binder No need to use Binder directly. AIDL requires multi-thread programming 5 In most case Intent is easy and powerful enough.
  • 6. Invoking method via interface caller callee In the same process 6
  • 7. Inter-process invocation caller interface caller interface How? callee interface callee 7
  • 8. Inter-process invocation caller interface Proxy caller interface Binder in kernel Binder Thread callee Stub interface callee 8
  • 9. android.os.Parcel Delivering arguments of method ”flatten” ”unflatten” transmit 9
  • 10. Describing in UML ... <<interface>> Proxy Stub 10
  • 11. Describing in UML ... caller <<interface>> calls implements Proxy Stub extends callee 11
  • 12. AIDL Auto generated from .aidl file caller <<interface>> Proxy Stub callee 12
  • 13. Use case: Who calls ”onPause” in Activity? 2:Send message Activity by Handler 3:”onPause” is called queue Looper in main thread Activity Manager Main Main Binder Thread Thread Binder Thread #1 Thread #1 Kernel 1:Call ”schedulePauseActivity” across process 13
  • 14. Binder  /etc/binder  Not for general purpose. Tuned for specific transaction.  Multi-thread aware  Have internal data per thead  (CF. Socket have internal data per fd.)  Not use ”write” and ”read”. Write and read at once by ”ioctl”. 14
  • 15. Transaction of Binder Process A and B have different memory space. They can not see each other. Kernel Process B Process A Binder Copy memory by copy_from _user Then, wake up process B Kernel Process B Binder Process A Copy memory by copy_to_user 15
  • 16. See also rd  3 session of Yokohama Android Platform club  http://www.yokohama.android-pf.org/study/dai-san-kai-benkyou-kai  1st session of Android SDK work group  http://www.android-group.jp/index.php?%CA%D9%B6%AF%B2%F1%2FAndr  KMC blog  http://blog.kmckk.com/archives/3611344.html  http://blog.kmckk.com/archives/3613707.html  http://blog.kmckk.com/archives/3627888.html  http://blog.kmckk.com/archives/3645070.html  http://blog.kmckk.com/archives/3647635.html  http://blog.kmckk.com/archives/3617229.html 16
  • 17. Q&A Thank you for listening! Any comments to blogs are welcome. 17