Android AIDL Concept

cha122977 1,931 views 20 slides Dec 19, 2016
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

Shared on Android Taipei in 2016 Dec 19th


Slide Content

Android AIDL Concept Charlie Tsai @ Android Study Group

Charlie Tsai @ Android Study Group [email protected] Software Engineer

Agenda Introduction of AIDL Write your AIDL files Implementation of AIDL

Introduction of AIDL

?AIDL? Android Interface Definition Language Main approach is IPC (Inter-Process Communication) Support types: All primitive types, CharSequence & String, List & Map, Parcelable class

IPC Issue Memories of Process A Process B of Process B X Cannot Access (Memory protection by Kernel)

How AIDL solve IPC issue Memories of Process A Process B of Process B Linux Kernel & Binder Driver Access Access

Write Your AIDL File Write *.aidl for your AIDL interface You can turn your Parcelable Class into AIDL Include if you use Other AIDL class/interface Note: List will become ArrayList in another side Map will become HashMap in another side (WHY?)

AIDL Data Structure MyData.java MyData.aidl

AIDL Interface IMyAidlInterface.aidl

How Parcelable Work

String int Data in memory (order is matter)

Usages of AIDL

Export Your Service Allow to be bound by other App.

Use Other’s Service Copy *.aidl file into your project (Because you need to know this Interface)

Generated File by AIDL

I Interface: Basic interface can be used for IPC android.os.IBinder: Core class of IPC Use YourInterface.asInterface(IBinder) to case IBinder to YourInterface. Use IBinder.queryLocalInterface() to know if this IBinder is in local or remote. If IBinder is in local, call function directly. If IBinder is a remote object, use transact and parcel to call function. Let’s see the source code…

Questions?

固定聚會:每週三@果子咖啡(近捷運南京復興站) 技術分享:每月底週六14:30 - 17:30 以及眾多不定期活動(ex: Workshop)

Thanks!