Slide 1

Slide 1 text

Can we adopt Eclipse IoT projects on Android Embedded Devices? Matteo Di Pirro - Nicola La Gloria - Saeed Rezaee

Slide 2

Slide 2 text

About us 2 ● Since 2012 Kynetics has been a global provider of Embedded Operating Systems ● Kynetics is recognized as global partner, supporting a variety of vendors, ODMs and Chipmakers ● Over 150 projects developed for Fortune 500 companies and large enterprises ● Kynetics is active in the embedded software community, as member and contributor ○ Member of the Eclipse Foundation since 2017 ○ Leader of the Eclipse Hara Project ● Offices: Santa Clara, CA (USA), Los Angeles CA (USA), Padova (Italy)

Slide 3

Slide 3 text

Agenda ● Java Native Interface ● Remarkable differences between Android and Java ● Case studies ○ Eclipse Hara ○ Eclipse Leshan ○ Eclipse Mosquitto ● Conclusions 3

Slide 4

Slide 4 text

Java Native Interface ● Used to incorporate native code (e.g. C/C++) in Java applications ○ Java apps to call native libraries ○ Native apps to use the JVM ● Applications using JNI may lose Java benefits ○ Portability ○ Safety 4

Slide 5

Slide 5 text

APK vs JAR (vs AAR) ● JAR ○ Designed for distribution of Java applications ○ Contains .class files ● APK ○ Designed for distribution of Android applications ○ Similar to JAR, but with DEX files ○ AAR ■ Similar to APKs, but for Android libraries 5

Slide 6

Slide 6 text

Runtime ● Android Runtime (ART) is optimized for mobile devices ● Different than JVM! ○ Different bytecode (.dex vs .class) ○ Different language level ● Some Java features are not available in Android ○ Or come with restrictions 6

Slide 7

Slide 7 text

Case Studies 7

Slide 8

Slide 8 text

Eclipse Hara ● Kotlin library to speed up the development of hawkBit DDI native clients ● OS independent ● Architecture independent ○ Based on the JVM and available for many architectures ● Designed to facilitate the integration of native update Services 8

Slide 9

Slide 9 text

Eclipse Leshan ● Server/client implementation of LWM2M ○ Remote device management and telemetry ● Set of Java libraries ○ Using Maven ● Provides sample client and server ● We focused on running the demo client on Android 9

Slide 10

Slide 10 text

Eclipse Leshan Client on Android ● Build System Tweaks ○ JAR Metadata files ○ Duplicated transitive dependencies ○ SLF4J ● Code Tweaks ○ NetworkOnMainThreadException ○ Use of unsupported Java features ○ Resource loading ○ Permissions 10

Slide 11

Slide 11 text

Roboto bold 36 11 Eclipse Leshan Demo

Slide 12

Slide 12 text

Eclipse Mosquitto ● Message broker implementing MQTT ● Provides C libraries to implement clients ● We focused on running the sample C-based client to Android ● Using C libraries required JNI ○ Android wrapper around native code 12

Slide 13

Slide 13 text

Eclipse Mosquitto - Import Native Library ● Build the library using CMake ○ Using Android Native Development Kit ○ Specifying target architecture and Android API level ● Copy .so file in the Android project ● Develop native wrapper ● CMakeLists.txt file ○ Include library headers and binary files ○ Link native wrapper 13

Slide 14

Slide 14 text

Roboto bold 36 14 Eclipse Mosquitto Demo

Slide 15

Slide 15 text

Conclusions Can we adopt Eclipse IoT projects on Android Embedded Devices?

Slide 16

Slide 16 text

Conclusions Can we adopt Eclipse IoT projects on Android Embedded Devices? Yes, … but the porting effort depends on the project!

Slide 17

Slide 17 text

Conclusions ● We analyzed projects with different premises for the porting ○ Java compatible or with some incompatibilities to cure ○ Native ■ JNI required ■ Android native toolchain ● Port or create Android supported building scripts ○ Different artifact packaging ● Isolate and port specific unsupported Java features

Slide 18

Slide 18 text

Android's user-space is so different from stock Linux, you can easily say that Android is not in any way a Linux system, except for the kernel. Robert Love Reach out! [email protected]