on mobile devices

Jozef Mlích

Department of Computer Graphics and Multimedia Brno University of Technology, Faculty of Information Technology Božetěchova 2, 612 66 Brno, Czech Republic [email protected]

http://www.fit.vutbr.cz/~imlich/ Application Development for Mobile DevicesTAM 2020 8.12.2020 | 1 / 32 Outline  Motivation  Alternative operating systems  Where to get hardware  Architecture of mobile  Development

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 2 / 32 Motivation

Motivation  Do it your self – learn something  Special needs – Create new concept / add some extra feature / very special hardware  Security – how we can trust to Chinese/Russian/US/* product?  Longevity – security updates are available ~ 2 – 6 years depending on vendor  Vendor lock-in – US Export laws

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 4 / 32

Distributions  postmarketOS  Nemo Mobile   KDE Neon  Mobian  NixOS  Leste  LuneOS  SailfishOS  Sxmo  PureOS  openSUSE  Fedora  AVMultiPhone  Arch Linux ARM  GloDroid  Manjaro ARM  Gentoo  AsteroidOS   LineageOS

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 6 / 32 Desktop Environment  xfce4  Maemo  Nemo  Plasma Mobile  Phosh  Android

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 7 / 32 Hardware

Hardware  5  PinePhone  F(x)tec Pro  Dragonbox Pyra  4, N900   And others

Find your device at https://wiki.postmarketos.org/wiki/All_devices

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 9 / 32 Architecture

Architecture depends on your needs

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 11 / 32 Hardware

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 12 / 32 Architecture I  Bootloader  Kernel – Drivers (+libhybris) – AOSP – Not sure what API is the right one for given task – /proc or GPSD or dbus  GUI – Framebuffer, XOrg, Wayland – On-screen keyboard

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 13 / 32 Architecture II  Modem / Networking – oFono, Network Manager, AT+?, QMI  Audio – PulseAudio profiles  Userspace applications

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 14 / 32 Bootloader

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 15 / 32 Boot  FSBL (hardware ROM)  Bootstrapping  Bootloader – chicken or the egg problem – u-boot (blob, bootldr, redboot, – Limited resources able, etc.)  Kernel  Requirements  Device tree / EFI – Keyboard vs. Volume keys vs  Initramfs Touch screen only – charging  Rootfs + (SYS V init)

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 16 / 32 Multimedia

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 17 / 32 Development

Development  (Cross) Compilation  Remote debugging  Profiling  Security  End user apps

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 19 / 32 Compilation

export CC=/usr/local/bin/arm-linux-gnueabi-gcc export CFLAGS=-I /usr/local/arm_root/include make myproject.pro -r -spec linux-g++-maemo

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 20 / 32 Remote debugging

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 21 / 32 Profiling  Monitor – CPU load – Memory consumption – Network traffic (change of IM timeout added +1h) – Number of waking up and suspends (-states) – Frequency of CPU – Interrupts (IRQs) (or NAPI) Pro-tip: try to use “heartbeat” or  gproof, powertop, and much more ::VeryCoarseTimer to spare some CPU ticks.

(perf cheat sheet) Android AlarmManager.setInexactRepeating(..)

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 22 / 32 Profiling

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 23 / 32 Performance cheat sheet ( 1 of 8 )

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 24 / 32 Security  Hardware security – Intel Management Engine – Baseband  UEFI  Posix permission, ACLs  SELinux  Chroots, Cgroup, Containers  portals

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 25 / 32 End user apps  Anbox – android machine on linux – services are allowed only in Android  Packaging – *., *.rpm, *.apk – depends on distro – Flatpak, snap, appimage  Monetization

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 26 / 32 Questions?

Questions  How does embedded hardware (phones) boots?  What Linux distributions do we have? Are there some alternative Android distribution?  Which indicators should be observed when developing mobile applications? How we can observe them?  How we can reduce power consumption?  How is the security designed on mobile linux distributions?

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 28 / 32 References  Performance cheat sheet http://www.brendangregg.com/linuxperf.html  CCC Chaos Communication Congress https://fahrplan.events.ccc.de/congress/2016/Fahrplan/events.  http://elinux.org/  Hoque, M.A., M. Siekkinen, and J.K. Nurminen. “On the Energy Efficiency of Proxy-based Traffic Shaping for Mobile Audio Streaming.” In 2011 IEEE Consumer Communications and Networking Conference (CCNC), 891 –895, 2011.  Alternative Androids – https://copperhead.co/ https://lineageos.org/ https://www.replicant.us/

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 29 / 32 Do we have time yet?

PostmarketOS  Based on Alpine Linux  https://postmarketos.org/  /etc/deviceinfo  Cross-compile all armhf- packages  Effective caching out of the box (ccache)  Flasher abstraction – Fastboot – heimdall  UI (Phosh, Plasma, , LuneOS ui, XFCE4, weston)

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 31 / 32 Motivation  Baseband exploitation – AT+QCMD=uname -a

http://www.fit.vutbr.cz/~imlich/ TAM 2020 | 32 / 32