SlideShare a Scribd company logo
1
Android's HIDL:
Treble in the HAL
YouTubeTM
Livestream
March 28th
2018
Karim Yaghmour
@karimyaghmour
karim.yaghmour@opersys.com
2
These slides are made available to you under a Creative Commons Share-
Alike 3.0 license. The full terms of this license are here:
https://creativecommons.org/licenses/by-sa/3.0/
Attribution requirements and misc., PLEASE READ:
● This slide must remain as-is in this specific location (slide #2), everything
else you are free to change; including the logo :-)
● Use of figures in other documents must feature the below “Originals at”
URL immediately under that figure and the below copyright notice where
appropriate.
● You are free to fill in the “Delivered and/or customized by” space on the
right as you see fit.
● You are FORBIDEN from using the default “About” slide as-is or any of its
contents.
● You are FORBIDEN from using any content provided by 3rd parties without
the EXPLICIT consent from those parties.
(C) Copyright 2018, Opersys inc.
These slides created by: Karim Yaghmour
Originals at: www.opersys.com/community/docs
Delivered and/or customized by
3
About
● Author of:
● Introduced Linux Trace Toolkit in 1999
● Originated Adeos and relayfs (kernel/relay.c)
● Training, Custom Dev, Consulting, ...
4
Agenda
1. Introduction
2. Basics
3. HAL Architecture Rework
4. Walkthrough
5. Adding a New HIDL
6. Support Infrastructure
5
1. Introduction
● Goals
● Origins
● Architecture recap
6
1.1. Goals
● Recap HIDL's origins
● Describe what HIDL does
● Outline how it fits into Android architecture
● Detail how to use it and how it works
7
1.2. Origins
● Part of Android's Project Treble
● Extends existing HAL concepts
● Similar to AIDL
8
1.3. Architecture Recap
9
10
11
/frameworks/base/services/core/java/...
/frameworks/base/services/core/jni/
/hardware/libhardware/
/device/[MANUF.]/[DEVICE]
Kernel or module
/frameworks/base/core/...
AOSP-provided
ASL
Manuf.-provided
Manuf. license
Manuf.-provided
GPL-license
12
HIDLVNDK
VINTF
HIDL
VINTF
13
2. Basics
● HAL's role
● Traditional HAL before 8.x
● HIDL
● Links
14
2.1. HAL's Role
● Per-device-type hardware abstraction
● Example:
● SurfaceFlinger uses hwcomposer HAL
● Location uses gps HAL
● Lights uses lights HAL
● Etc.
● Google specifies HAL signature
● Manufacturer/SoC vendor provides HAL implementation
● Reference implementations:
● Leads devices found in AOSP
● SoC vendor reference designs/boards in BSP
15
2.2. Traditional HAL Before 8.x
● Google specifies HALs as “C” header files
● HAL module author uses header in implementation
● Resulting binary shipped as part of release
● Modules loaded at boot time by system services
● Headers could (and did) change between versions
● Required reworking, rebuilding, reshipping new
version
● To update to a new version of Android:
● All modules had to be updated, be they trivial or difficult
16
2.3. HIDL
● “Hardware Interface Definition Language”
● New layer under system services
● Formalized and versioned HAL interface definitions
●
Similar to AIDL, yet different
●
Example HIDLs in 8.x/Oreo:
● graphics/composer 2.1
● gnss 1.0
● Etc.
●
Once published, a given HIDL definition is immutable:
● Even in 9.x/P, graphics/composer 2.1 and gnss 1.0 will be the same as in 8.x.
● Fresh port assumes using latest HAL sig available
● Most importantly:
● Modules created against a given signature should continue to work so long as that
signature is supported.
● Depends on Google, but incentives are aligned
● More on this in tomorrow's presentation
17
2.4. Links
● General doc:
● https://source.android.com/devices/architecture/hidl/
● C++
● https://source.android.com/devices/architecture/hidl-
cpp/
● Java
● https://source.android.com/devices/architecture/hidl-
java/
18
3. HAL Architecture Rework
● Overall architecture
● Detailed architecture / Java
● Detailed architecture / C++
19
3.1. Overall Architecture
20
3.2. Detailed Architecture / Java
21
3.3. Detailed Architecture C++
22
4. Walkthrough
● JNI Layer
● HIDL Layer
● HIDL Glue
23
4.1. JNI Layer
●
JNI Java<->C/C++ method/function registration -- same before and after Treble:
● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/java/com/android/server/SystemServer.java
● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/java/com/android/server/SystemServer.java#367
● System.loadLibrary("android_servers"); ==> Loads libandroid_servers.so
●
This file defines which JNI files to compile into libandroid_servers.so:
●
http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/core/jni/Android.mk
●
Including: com_android_server_lights_LightsService.cpp
●
This file defines the rules to build libandroid_servers.so:
● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/Android.mk
●
Another file compiled into libandroid_servers.so is onload.cpp:
● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/core/jni/onload.cpp
● That file contains a function called: JNI_OnLoad()
● JNI_OnLoad() is automatically called by ART when libandroid_servers.so is loaded.
●
JNI_OnLoad contains calls to JNI registration functions, such as register_android_server_LightsService(env);
●
http://aosp.opersys.com/xref/android-
8.1.0_r1/xref/frameworks/base/services/core/jni/com_android_server_lights_LightsService.cpp:register_android_server_LightsService()
● JniRegisterNativeMethods()
●
jniRegisterNativeMethods() calls into the ART VM to register C/C++ calls against a Java class.
24
4.2. HIDL Layer
● http://aosp.opersys.com/xref/android-
8.1.0_r9/xref/frameworks/base/services/core/java/com/android/server/lights/LightsServic
e.java:
● LightsService constructor
●
setLightLocked calls on setLight_native
● http://aosp.opersys.com/xref/android-
8.1.0_r9/xref/frameworks/base/services/core/jni/com_android_server_lights_LightsServic
e.cpp:setLight_native()
●
LightHal::associate();
●
Ilight::getService();
● http://aosp.opersys.com/xref/android-
8.1.0_r9/xref/hardware/interfaces/light/2.0/default/Light.cpp:HIDL_FETCH_ILight()
● GetLightDevice()
●
hw_get_module ()
●
dlopen() ==> results in lights.[hw-board].so to be loaded
25
4.3. HIDL Glue
● There are two main paths with HIDL:
●
Same-Process (passthrough)
●
Binderized
● This build file can generate BOTH options:
● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/hardware/interfaces/light/2.0/default/Android.mk
– android.hardware.light@2.0-impl.so ==> default same-process implementation
– android.hardware.light@2.0-service ==> binderized remote process
● The default binderized process in the case of lights (i.e. android.hardware.light@2.0-service) essentially loads
android.hardware.light@2.0-impl.so.
● Example *legacy* lights module implementation:
● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/device/huawei/angler/liblight/lights.c
●
This is the file that would be calling into drivers in the kernel.
● The decision to use passthrough vs. binderized service depends on the board-specific manifest.xml:
●
http://aosp.opersys.com/xref/android-8.1.0_r9/xref/device/generic/goldfish/manifest.xml
26
5. Adding a New HIDL
● New interface definition
● Use of update-makefiles.sh
● Use of hidl-gen
● See/implement default implementation
● Tweak default implementation makefiles
● Add entry in product manifest
27
6. Support Infrastructure
● HIDL tools (host + device) + libraries
● Manifest file parts + device-specific mk files
● Online doc/reference
● On-device:
● File locations
● Loaded files in address space
● Processes
● Etc.
28
Thank you ...
karim.yaghmour@opersys.com
29
Acknowledgements:
● Several diagrams distributed by Google under
CC-BY-SA license or ASL 2.0.
Ad

More Related Content

What's hot (20)

"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
Emertxe Information Technologies Pvt Ltd
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
Opersys inc.
 
Binder: Android IPC
Binder: Android IPCBinder: Android IPC
Binder: Android IPC
Shaul Rosenzwieg
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Low Level View of Android System Architecture
Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
National Cheng Kung University
 
Android AIDL Concept
Android AIDL ConceptAndroid AIDL Concept
Android AIDL Concept
Charile Tsai
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
National Cheng Kung University
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
Linaro
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
National Cheng Kung University
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
Nanik Tolaram
 
Android Internals
Android InternalsAndroid Internals
Android Internals
Opersys inc.
 
Android Things : Building Embedded Devices
Android Things : Building Embedded DevicesAndroid Things : Building Embedded Devices
Android Things : Building Embedded Devices
Emertxe Information Technologies Pvt Ltd
 
Android Binder: Deep Dive
Android Binder: Deep DiveAndroid Binder: Deep Dive
Android Binder: Deep Dive
Zafar Shahid, PhD
 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depth
Chris Simmonds
 
Android device driver structure introduction
Android device driver structure introductionAndroid device driver structure introduction
Android device driver structure introduction
William Liang
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
Opersys inc.
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Android AIDL Concept
Android AIDL ConceptAndroid AIDL Concept
Android AIDL Concept
Charile Tsai
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
Linaro
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
Nanik Tolaram
 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depth
Chris Simmonds
 
Android device driver structure introduction
Android device driver structure introductionAndroid device driver structure introduction
Android device driver structure introduction
William Liang
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 

Similar to Android's HIDL: Treble in the HAL (20)

Inside Android's UI at AnDevCon IV
Inside Android's UI at AnDevCon IVInside Android's UI at AnDevCon IV
Inside Android's UI at AnDevCon IV
Opersys inc.
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
Opersys inc.
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
Opersys inc.
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
Opersys inc.
 
Android Things: Android for IoT
Android Things: Android for IoTAndroid Things: Android for IoT
Android Things: Android for IoT
Opersys inc.
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
Opersys inc.
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
Opersys inc.
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Android Platform Debugging & Development
Android Platform Debugging & Development Android Platform Debugging & Development
Android Platform Debugging & Development
Qualcomm Developer Network
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
Opersys inc.
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
Opersys inc.
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
Opersys inc.
 
Inside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon VInside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon V
Opersys inc.
 
Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014
Opersys inc.
 
Inside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon VIInside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon VI
Opersys inc.
 
Brillo/Weave Internals
Brillo/Weave InternalsBrillo/Weave Internals
Brillo/Weave Internals
Opersys inc.
 
Extending Android's Platform Toolsuite
Extending Android's Platform ToolsuiteExtending Android's Platform Toolsuite
Extending Android's Platform Toolsuite
Opersys inc.
 
Running Code in the Android Stack at ABS 2014
Running Code in the Android Stack at ABS 2014Running Code in the Android Stack at ABS 2014
Running Code in the Android Stack at ABS 2014
Opersys inc.
 
Running Code in the Android Stack at ELCE 2013
Running Code in the Android Stack at ELCE 2013Running Code in the Android Stack at ELCE 2013
Running Code in the Android Stack at ELCE 2013
Opersys inc.
 
Inside Android's UI at AnDevCon IV
Inside Android's UI at AnDevCon IVInside Android's UI at AnDevCon IV
Inside Android's UI at AnDevCon IV
Opersys inc.
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
Opersys inc.
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
Opersys inc.
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
Opersys inc.
 
Android Things: Android for IoT
Android Things: Android for IoTAndroid Things: Android for IoT
Android Things: Android for IoT
Opersys inc.
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
Opersys inc.
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
Opersys inc.
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
Opersys inc.
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
Opersys inc.
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
Opersys inc.
 
Inside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon VInside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon V
Opersys inc.
 
Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014
Opersys inc.
 
Inside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon VIInside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon VI
Opersys inc.
 
Brillo/Weave Internals
Brillo/Weave InternalsBrillo/Weave Internals
Brillo/Weave Internals
Opersys inc.
 
Extending Android's Platform Toolsuite
Extending Android's Platform ToolsuiteExtending Android's Platform Toolsuite
Extending Android's Platform Toolsuite
Opersys inc.
 
Running Code in the Android Stack at ABS 2014
Running Code in the Android Stack at ABS 2014Running Code in the Android Stack at ABS 2014
Running Code in the Android Stack at ABS 2014
Opersys inc.
 
Running Code in the Android Stack at ELCE 2013
Running Code in the Android Stack at ELCE 2013Running Code in the Android Stack at ELCE 2013
Running Code in the Android Stack at ELCE 2013
Opersys inc.
 
Ad

More from Opersys inc. (20)

Android Automotive
Android AutomotiveAndroid Automotive
Android Automotive
Opersys inc.
 
Android 10 Internals Update
Android 10 Internals UpdateAndroid 10 Internals Update
Android 10 Internals Update
Opersys inc.
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
Opersys inc.
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
Opersys inc.
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Opersys inc.
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Opersys inc.
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
Opersys inc.
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Opersys inc.
 
Project Ara
Project AraProject Ara
Project Ara
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
Opersys inc.
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Android Automotive
Android AutomotiveAndroid Automotive
Android Automotive
Opersys inc.
 
Android 10 Internals Update
Android 10 Internals UpdateAndroid 10 Internals Update
Android 10 Internals Update
Opersys inc.
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
Opersys inc.
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
Opersys inc.
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Opersys inc.
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Opersys inc.
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
Opersys inc.
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
Opersys inc.
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
Opersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Ad

Recently uploaded (20)

How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 

Android's HIDL: Treble in the HAL

  • 1. 1 Android's HIDL: Treble in the HAL YouTubeTM Livestream March 28th 2018 Karim Yaghmour @karimyaghmour [email protected]
  • 2. 2 These slides are made available to you under a Creative Commons Share- Alike 3.0 license. The full terms of this license are here: https://creativecommons.org/licenses/by-sa/3.0/ Attribution requirements and misc., PLEASE READ: ● This slide must remain as-is in this specific location (slide #2), everything else you are free to change; including the logo :-) ● Use of figures in other documents must feature the below “Originals at” URL immediately under that figure and the below copyright notice where appropriate. ● You are free to fill in the “Delivered and/or customized by” space on the right as you see fit. ● You are FORBIDEN from using the default “About” slide as-is or any of its contents. ● You are FORBIDEN from using any content provided by 3rd parties without the EXPLICIT consent from those parties. (C) Copyright 2018, Opersys inc. These slides created by: Karim Yaghmour Originals at: www.opersys.com/community/docs Delivered and/or customized by
  • 3. 3 About ● Author of: ● Introduced Linux Trace Toolkit in 1999 ● Originated Adeos and relayfs (kernel/relay.c) ● Training, Custom Dev, Consulting, ...
  • 4. 4 Agenda 1. Introduction 2. Basics 3. HAL Architecture Rework 4. Walkthrough 5. Adding a New HIDL 6. Support Infrastructure
  • 5. 5 1. Introduction ● Goals ● Origins ● Architecture recap
  • 6. 6 1.1. Goals ● Recap HIDL's origins ● Describe what HIDL does ● Outline how it fits into Android architecture ● Detail how to use it and how it works
  • 7. 7 1.2. Origins ● Part of Android's Project Treble ● Extends existing HAL concepts ● Similar to AIDL
  • 9. 9
  • 10. 10
  • 13. 13 2. Basics ● HAL's role ● Traditional HAL before 8.x ● HIDL ● Links
  • 14. 14 2.1. HAL's Role ● Per-device-type hardware abstraction ● Example: ● SurfaceFlinger uses hwcomposer HAL ● Location uses gps HAL ● Lights uses lights HAL ● Etc. ● Google specifies HAL signature ● Manufacturer/SoC vendor provides HAL implementation ● Reference implementations: ● Leads devices found in AOSP ● SoC vendor reference designs/boards in BSP
  • 15. 15 2.2. Traditional HAL Before 8.x ● Google specifies HALs as “C” header files ● HAL module author uses header in implementation ● Resulting binary shipped as part of release ● Modules loaded at boot time by system services ● Headers could (and did) change between versions ● Required reworking, rebuilding, reshipping new version ● To update to a new version of Android: ● All modules had to be updated, be they trivial or difficult
  • 16. 16 2.3. HIDL ● “Hardware Interface Definition Language” ● New layer under system services ● Formalized and versioned HAL interface definitions ● Similar to AIDL, yet different ● Example HIDLs in 8.x/Oreo: ● graphics/composer 2.1 ● gnss 1.0 ● Etc. ● Once published, a given HIDL definition is immutable: ● Even in 9.x/P, graphics/composer 2.1 and gnss 1.0 will be the same as in 8.x. ● Fresh port assumes using latest HAL sig available ● Most importantly: ● Modules created against a given signature should continue to work so long as that signature is supported. ● Depends on Google, but incentives are aligned ● More on this in tomorrow's presentation
  • 17. 17 2.4. Links ● General doc: ● https://source.android.com/devices/architecture/hidl/ ● C++ ● https://source.android.com/devices/architecture/hidl- cpp/ ● Java ● https://source.android.com/devices/architecture/hidl- java/
  • 18. 18 3. HAL Architecture Rework ● Overall architecture ● Detailed architecture / Java ● Detailed architecture / C++
  • 22. 22 4. Walkthrough ● JNI Layer ● HIDL Layer ● HIDL Glue
  • 23. 23 4.1. JNI Layer ● JNI Java<->C/C++ method/function registration -- same before and after Treble: ● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/java/com/android/server/SystemServer.java ● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/java/com/android/server/SystemServer.java#367 ● System.loadLibrary("android_servers"); ==> Loads libandroid_servers.so ● This file defines which JNI files to compile into libandroid_servers.so: ● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/core/jni/Android.mk ● Including: com_android_server_lights_LightsService.cpp ● This file defines the rules to build libandroid_servers.so: ● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/Android.mk ● Another file compiled into libandroid_servers.so is onload.cpp: ● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/frameworks/base/services/core/jni/onload.cpp ● That file contains a function called: JNI_OnLoad() ● JNI_OnLoad() is automatically called by ART when libandroid_servers.so is loaded. ● JNI_OnLoad contains calls to JNI registration functions, such as register_android_server_LightsService(env); ● http://aosp.opersys.com/xref/android- 8.1.0_r1/xref/frameworks/base/services/core/jni/com_android_server_lights_LightsService.cpp:register_android_server_LightsService() ● JniRegisterNativeMethods() ● jniRegisterNativeMethods() calls into the ART VM to register C/C++ calls against a Java class.
  • 24. 24 4.2. HIDL Layer ● http://aosp.opersys.com/xref/android- 8.1.0_r9/xref/frameworks/base/services/core/java/com/android/server/lights/LightsServic e.java: ● LightsService constructor ● setLightLocked calls on setLight_native ● http://aosp.opersys.com/xref/android- 8.1.0_r9/xref/frameworks/base/services/core/jni/com_android_server_lights_LightsServic e.cpp:setLight_native() ● LightHal::associate(); ● Ilight::getService(); ● http://aosp.opersys.com/xref/android- 8.1.0_r9/xref/hardware/interfaces/light/2.0/default/Light.cpp:HIDL_FETCH_ILight() ● GetLightDevice() ● hw_get_module () ● dlopen() ==> results in lights.[hw-board].so to be loaded
  • 25. 25 4.3. HIDL Glue ● There are two main paths with HIDL: ● Same-Process (passthrough) ● Binderized ● This build file can generate BOTH options: ● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/hardware/interfaces/light/2.0/default/Android.mk – [email protected] ==> default same-process implementation – [email protected] ==> binderized remote process ● The default binderized process in the case of lights (i.e. [email protected]) essentially loads [email protected]. ● Example *legacy* lights module implementation: ● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/device/huawei/angler/liblight/lights.c ● This is the file that would be calling into drivers in the kernel. ● The decision to use passthrough vs. binderized service depends on the board-specific manifest.xml: ● http://aosp.opersys.com/xref/android-8.1.0_r9/xref/device/generic/goldfish/manifest.xml
  • 26. 26 5. Adding a New HIDL ● New interface definition ● Use of update-makefiles.sh ● Use of hidl-gen ● See/implement default implementation ● Tweak default implementation makefiles ● Add entry in product manifest
  • 27. 27 6. Support Infrastructure ● HIDL tools (host + device) + libraries ● Manifest file parts + device-specific mk files ● Online doc/reference ● On-device: ● File locations ● Loaded files in address space ● Processes ● Etc.
  • 29. 29 Acknowledgements: ● Several diagrams distributed by Google under CC-BY-SA license or ASL 2.0.