Yocto layer for a4l, which runs unmodified Android apps as Wayland clients on a Linux system: no emulator, no device image.
It targets wrynose, for x86_64 and aarch64, with glibc.
| Recipe | Builds | From |
|---|---|---|
a4l |
the a4l executable, at a commit after release 0.1.0 |
source, in Yocto |
a4l-skia |
the Skia a4l is pinned to (chrome/m150), as a static prefix in the sysroot | source, in Yocto |
a4l-aosp-runtime |
ART, the framework jars, the bionic runtime, a CA store and the a4l-run launcher |
a tarball you stage from an AOSP tree |
a4l-keyring |
an unlocked Secret Service keyring for AndroidKeyStore; needs meta-gnome |
this layer |
packagegroup-a4l |
pulls in a4l and a4l-aosp-runtime, and recommends packagegroup-a4l-services |
|
core-image-a4l |
a Weston image with packagegroup-a4l |
|
packagegroup-a4l-services |
the host daemons a4l's service backends talk to (A4L_SERVICES) |
a4l needs a host ART build and the framework from an AOSP tree at
android-13.0.0_r84. That is a Soong build and Yocto does not do it, so
a4l-aosp-runtime packages its outputs from a tarball. a4l and a4l-skia
build with no AOSP tree on the build machine. Without the staged files a4l
builds with no native thread attach, and the executable alone prints its
version and module list and cannot run an app.
openembedded-core, wrynosemeta-openembedded/meta-oe(sdbus-c++, pugixml, bubblewrap)- optional:
meta-openembedded/meta-multimediafor thepipewireandlibcameraPACKAGECONFIGs ofa4l - optional:
meta-openembedded/meta-gnomefora4l-keyring
The clang toolchain is openembedded-core's. a4l-skia is built with it;
a4l is built with the default toolchain.
DISTRO_FEATURES needs wayland, and with the default PACKAGECONFIG also
vulkan and opengl.
bitbake-layers add-layer .../meta-android-4-linux
bitbake a4l # the executable and its SkiaTo run apps on the target, stage the runtime once per architecture and tell the build where the tarballs are:
# on the machine that has the AOSP tree, with an a4l checkout at A4L_SRCREV
git -C a4l checkout 0c5da497a2b441b9f44305d431690c751641256d # A4L_SRCREV
scripts/a4l-stage-aosp-runtime.sh --arch aarch64 --a4l a4l --aosp /path/to/aosp \
--webview --boot-image --out /srv/a4l/a4l-aosp-runtime-aarch64.tar.zst
scripts/a4l-stage-aosp-runtime.sh --arch x86_64 --a4l a4l --aosp /path/to/aosp \
--webview --boot-image --out /srv/a4l/a4l-aosp-runtime-x86_64.tar.zstBeside each tarball the script writes a4l-aosp-runtime-<arch>.bionic-offsets.h,
the layout of bionic's thread block in that tree. Keep the two together in
A4L_AOSP_RUNTIME_DIR: a4l is compiled against the header, and
a4l-aosp-runtime refuses a tarball whose manifest does not name it. The
script prints the tarball's sha256 when it is done.
# local.conf
A4L_AOSP_RUNTIME_DIR = "/srv/a4l"
# optional: accept only these tarballs
A4L_AOSP_RUNTIME_SHA256:aarch64 = "<sha256 the script printed>"
A4L_AOSP_RUNTIME_SHA256:x86-64 = "<sha256 the script printed>"
The tarball is a local file with no checksum in the recipe, so by default
whatever is at that path is packaged. With A4L_AOSP_RUNTIME_SHA256 set the
build fails on a tarball with another sum.
bitbake core-image-a4lcore-image-a4l is core-image-weston's base (Weston, a terminal, ssh) with
packagegroup-a4l and 1 GiB of extra room for apps. It needs wayland vulkan opengl pam in DISTRO_FEATURES. For another image, add the packagegroup:
IMAGE_INSTALL:append = " packagegroup-a4l"
Until A4L_AOSP_RUNTIME_DIR is set, a4l-aosp-runtime is skipped at parse time
and says why.
On the target, in a Wayland session:
a4l-run app.apk --present
a4l-run app.apk --present --ivi-surface-id=9000 # ivi-shella4l-run is the installed counterpart of a4l's tools/run-apk.sh: it sets the
same ACL_* environment from /usr/lib/a4l and builds nothing. It sets
ACL_PRESENT_GPU=1 unless you set it, and enters a bubblewrap namespace that
puts the Android fonts at /system, which Flutter apps need to draw text.
The staging script only reads the tree. It stops with the name of the first thing it cannot find.
- Both architectures:
lunch aosp_x86_64-eng, host ART (m build-art-host), the framework boot jars,framework-res, the target's fonts, and bionic. The jars and data are architecture-independent and come from this one build. - x86_64:
libandroid_runtime, and a4l'slibacl_graphics_jniandlibacl_gles_jniinout/host/linux-x86/lib64(a4ltools/aosp/graphics_jni,tools/aosp/gles_jni). - aarch64: the
linux_glibc_arm64outputs of a4l'stools/aosp/glibc-arm64/README.md, both lists in it, and thelinux_bionic_arm64bionic outputs.
The script builds a4l's two dex jars (aclshims.jar, hostboot.jar) and its
bionic-side libraries from the a4l checkout you give it, so they match the
executable. It records that commit in the tarball, and the recipe refuses a
tarball staged from another commit than A4L_SRCREV
(A4L_AOSP_RUNTIME_STRICT = "0" turns that into a warning).
libacl_graphics_jni.so and libacl_gles_jni.so are taken as the AOSP tree
last built them, from a copy of a4l's tools/aosp/graphics_jni and
gles_jni. Each carries a stamp of the sources it was compiled from, and the
script stops if that is not the stamp of the checkout's sources: run a4l's
tools/sync-aosp-jni.sh and build the two libraries in the tree again. The
MANIFEST records both stamps.
The tarball has a layout version in its MANIFEST, and the recipe reads
layout 3 only. A tarball staged with an older copy of the script is refused
with "stage it again".
| Variable | Default | |
|---|---|---|
A4L_SRCREV |
0c5da497, after v0.1.0 |
the a4l commit built; set in conf/layer.conf |
A4L_AOSP_RUNTIME_DIR |
unset | directory holding a4l-aosp-runtime-<arch>.tar.zst and .bionic-offsets.h |
A4L_AOSP_RUNTIME_STRICT |
1 |
refuse a tarball from another a4l commit |
A4L_AOSP_RUNTIME_SHA256 |
unset | sha256 the tarball must have; set it per architecture |
A4L_FONTS_CORE |
three faces | the font files of a4l-aosp-runtime-fonts-core; see "Fonts at run time" |
A4L_SERVICES |
by DISTRO_FEATURES |
the daemons of packagegroup-a4l-services; see "Service backends at run time" |
A4L_RUNTIME_DIR |
/usr/lib/a4l |
where the runtime is installed; a boot image is tied to it (--prefix) |
Moving A4L_SRCREV means moving the three SRCREVs beside it in
a4l_git.bb to the revisions in that commit's subprojects/*.wrap, the Skia
revisions in a4l-skia_150.bb if third_party/skia/METADATA changed, and
staging the tarballs again.
Each PACKAGECONFIG sets one of a4l's Meson feature options to enabled or
disabled and adds its dependency. A part that is on and whose dependency is
missing fails at configure.
Default: automotive skia gl dmabuf-codec alsa gstreamer sdbus secret crypto.
skia |
the Ganesh Vulkan present path (ACL_PRESENT_GPU=1); without it a4l presents through wl_shm |
gl |
host EGL and GLES: GLSurfaceView, SDL2, Unity, libGDX |
dmabuf-codec |
hardware video decode (V4L2; OpenMAX and VA-API where the device has them) |
gstreamer |
video decode through the highest-ranked installed GStreamer decoder |
ffmpeg |
software decode and SoundPool. Off by default: the ffmpeg recipe needs LICENSE_FLAGS_ACCEPTED += "commercial" |
alsa, pipewire |
audio output; pipewire needs meta-multimedia |
libcamera |
cameras; needs meta-multimedia |
sdbus |
every D-Bus backend: network, Bluetooth, battery, storage, location, notifications, portals; see "Service backends at run time" |
secret |
AndroidKeyStore on the Secret Service; see "The keystore at run time" |
crypto |
APK signature verification with OpenSSL's libcrypto |
drm-cxx |
KMS scanout sink of the split-process path |
automotive |
the automotive profile (-Dprofile_automotive) |
sdbus links a4l to D-Bus and nothing else. Each Android service is answered
from a host daemon that a4l looks for when an app starts; with the daemon
absent the app is told there is none (no Bluetooth adapter, no network, no
battery), and a4l logs the backend it chose. packagegroup-a4l-services
installs the daemons named in A4L_SERVICES, and packagegroup-a4l
recommends it.
A4L_SERVICES |
Package | Android side | Bus | In the default |
|---|---|---|---|---|
bluetooth |
bluez5 |
android.bluetooth |
system | with bluetooth in DISTRO_FEATURES |
zeroconf |
avahi-daemon |
android.net.nsd |
system | with zeroconf in DISTRO_FEATURES |
battery |
upower |
BatteryManager |
system | yes |
power-profiles |
power-profiles-daemon |
power-save mode | system | no |
storage |
udisks2 |
removable volumes | system | with polkit |
location |
geoclue |
LocationManager |
system | yes |
gpsd |
gpsd |
LocationManager, with ACL_LOCATION=gpsd |
TCP 2947 | no |
portal |
xdg-desktop-portal |
open a link or mail, dark/light, device permissions | session | with polkit |
keyring |
a4l-keyring |
AndroidKeyStore |
session | with meta-gnome |
pipewire |
pipewire wireplumber |
audio, with ACL_AUDIO=pipewire |
no; meta-multimedia | |
networkmanager, connman |
ConnectivityManager, WifiManager |
system | no |
Network. a4l reads network state from the daemon that already runs the
device's network: ConnMan, NetworkManager or systemd-networkd, the first it
finds in that order (ACL_NET_BACKEND names one). The default installs none of
them, because an image has made that choice and two of them fight over the
interfaces; systemd-networkd comes with systemd. Only the NetworkManager
backend tells an app about Wi-Fi (SSID, signal, link speed); under the others
Wi-Fi reads as off. An app that looks for its devices only on Wi-Fi can be
shown a wired link as Wi-Fi with ACL_NET_WIRED_AS_WIFI=1 (a4l
docs/pi-network.md).
Not chosen here. xdg-desktop-portal needs a backend for the desktop in
use (xdg-desktop-portal-gtk in meta-gnome, -wlr in meta-multimedia).
Notifications need a notification daemon on the session bus, which is the
shell's. The session-bus rows need a4l to run in the user's session, as the
keystore does.
Set the list in local.conf to change it, for example a head unit on ConnMan
with a GNSS receiver:
A4L_SERVICES = "bluetooth zeroconf connman gpsd keyring"
secret links libsecret, which is only the client side. An app's
AndroidKeyStore keys persist when a Secret Service provider is on the user's
session bus with its default keyring unlocked. Otherwise a4l keeps them in
memory and says so when the app starts:
keystore backend: secret-service (login keyring) keys persist
keystore backend: memory (non-persistent) keys are lost at exit
An app that registers a device key (a messenger) then has to sign in again at
every start. A board that boots straight to a compositor has no login that
would create and unlock a keyring, so this layer has a4l-keyring:
- it is in
dynamic-layers/gnome-layerand exists whenmeta-gnomeis inbblayers.conf(which needsmeta-networkingandmeta-python);packagegroup-a4lthen recommends it; - it depends on
gnome-keyringand installs a systemd user unit,a4l-keyring.service, enabled for every user, that runsgnome-keyring-daemon --replace --unlock --components=secretswith the password in~/.config/a4l/keyring-pass; - with no such file it writes a random password on the first run, mode 0600. Write the file yourself first (no trailing newline) to choose the password.
It needs systemd and pam in DISTRO_FEATURES, and a4l has to run in that
user's session: XDG_RUNTIME_DIR set and DBUS_SESSION_BUS_ADDRESS naming
the same bus. To check:
busctl --user get-property org.freedesktop.secrets \
/org/freedesktop/secrets/collection/login org.freedesktop.Secret.Collection Lockedb false is an unlocked keyring. Any other Secret Service provider works in
place of gnome-keyring. On a board with nobody at its screen set
ACL_KEYRING_PROMPT=0, so that a locked keyring does not hold the app's start
on an unlock prompt. ACL_KEYSTORE_BACKEND=memory forces the memory backend.
a4l's docs/pi-keyring.md has the manual steps and what the password protects.
Android code takes its fonts from fixed paths, not from fontconfig. The
framework reads /system/etc/fonts.xml for the families there are, and a
native engine (Flutter's Skia) reads the same file and takes each face it
names from /system/fonts and /fonts. With no /system, or with a family
whose face is missing, an app runs and draws no text.
-
The tree is installed at
/usr/lib/a4l/system. How it gets to/systemis a PACKAGECONFIG ofa4l-aosp-runtime:bubblewrap(default)a4l-runbinds it at/systemand/fontsin a namespace of the app's own; the root file system has no Android paths. Needs unprivileged user namespaces in the kernel.rootfs-linksinstalls a4l-aosp-runtime-rootfs-links:/system,/fontsand/apex/com.android.tzdataare links in the root file system, anda4l-runuses no namespace.PACKAGECONFIG:pn-a4l-aosp-runtime = "rootfs-links"No
DISTRO_FEATURESentry says whether the kernel has unprivileged user namespaces, so it cannot be derived; set it in the distro or machine configuration that knows the kernel. With both set the links are used and bubblewrap is there forACL_SANDBOX_UID. With neither, no app draws text. -
a4l-aosp-runtime-fonts-core, a hard dependency, holdsfonts.xml(a4l'stools/aosp/fonts-min.xml) and the faces it names: the default andsans-seriffamily,serifandmonospace(A4L_FONTS_CORE). The build fails iffonts.xmlhas nosans-seriffamily or names a face that is missing, empty, or outside that package. -
a4l-aosp-runtime-fonts-extra(recommended, about 75 MB) is the rest of AOSP'ssystem/fonts: other scripts, CJK, emoji. -
a4l-runsays on stderr when it cannot provide/system, and why.
Starting a4l run yourself, without a4l-run, gives the app no /system
unless that package is installed.
Android code does not read the system's trust bundle. conscrypt (every Java
HTTPS connection, and WebView) reads one PEM per root from
$ANDROID_ROOT/etc/security/cacerts; Dart and an app's own native TLS read
/system/etc/security/cacerts. Without that store every HTTPS connection an
app makes is refused ("Trust anchor for certification path not found").
a4l-aosp-runtimebuilds the store from theca-certificatesrecipe, the roots the image itself trusts, and installs it at/usr/lib/a4l/system/etc/security/cacerts. It is in the package, so it is there on a read-only root file system and needs nothing run at first boot.- It installs
/etc/ca-certificates/update.d/a4l-cacerts, a hook ofupdate-ca-certificates. A root added on the target (a.crtunder/usr/local/share/ca-certificates, thenupdate-ca-certificates) is added to the Android store too, and a removed one is removed. On a read-only root file system the hook says so and leaves the store as built; add the root at build time instead, to theca-certificatesrecipe. - It depends on
ca-certificates, which brings theopensslcommand the hook uses. What a4l does on the host side of an app, such as GStreamer or FFmpeg fetching a stream, trusts the system bundle and not the Android store. - A certificate an app's user installs is not supported: there is no user-added store.
Two things outside this layer decide whether a valid certificate is accepted:
- The clock. A board with no battery-backed clock starts in the past and every certificate is "not yet valid" until the time is set. Have time synchronization in the image (systemd-timesyncd is in systemd's default PACKAGECONFIG) and working before an app starts.
- APK signatures are checked against the certificate in the APK, with
libcrypto.so.3(cryptoPACKAGECONFIG). No CA store is involved.
- The wayland-cxx-scanner code generator runs while a4l compiles. The
a4lrecipe builds it for the build machine from the revision a4l pins, and does not use awayland-cxx-scanner-nativerecipe from another layer. a4l-skiais built with clang (TOOLCHAIN = "clang") and the distribution's C++ runtime, with the GN arguments of wayland-cxx-scanner'sscripts/build-skia.sh. It installs nothing on the target.a4lis built with the distribution's default toolchain on both architectures. Release 0.1.0 does not build that way: GCC 15 does not link its arm64 build, and an optimized build crashes in the first app library that callsGetEnv. Both are fixed atA4L_SRCREV(a4l PRs #413 and #412).- The runtime tarball is prebuilt. The staging script puts the
NOTICEfiles of seven AOSP projects in it underlicenses/(ART, bionic's libc, libcore, frameworks/base, conscrypt, ICU and the Roboto fonts), and the recipe'sLIC_FILES_CHKSUMis on those. That is most of what the tarball is built from and not all of it: collect the remaining notices from the AOSP tree before you ship an image with it. - No JDK is needed to build. a4l includes
jni.handjvmti.h, which upstream takes from the build machine's JDK; the recipe passes AOSP's OpenJDK headers at the pinned revision with-Djni_include.--vm=jvmis compiled in but its framework classes are not built, and it would need a JRE on the target;--vm=artis whata4l-runuses. - To attach an app's native threads to bionic, a4l builds a bionic thread
block by hand and needs its layout, which differs by architecture and is
measured from bionic's private headers. The staging script measures it
(a4l's
tools/gen-bionic-offsets.sh) and the recipe passes the header with-Dbionic_offsetsand-Dbionic_attach=enabled, so nothing on the build machine is read for it. WithA4L_AOSP_RUNTIME_DIRunset,a4lis built with-Dbionic_attach=disabled: an app whose native code starts threads does not run on it.
Built on wrynose with openembedded-core, meta-poky and meta-oe, for
qemuarm64 and qemux86-64: a4l, a4l-skia, a4l-aosp-runtime,
packagegroup-a4l and core-image-a4l, with the default PACKAGECONFIGs and
tarballs staged with --webview --boot-image.
Run, x86_64 only: core-image-a4l in QEMU with KVM, two apps from F-Droid
started with a4l-run app.apk --present in the Weston session. A Java-only
app (a clock) and a WebView app (a map) both drew, and the map took input. That
exercises a4l-run, the bubblewrap namespace, the fonts under /system, the
Vulkan present path and the WebView.
Not tested:
- aarch64 has been built and not run.
- Whether the ART boot image is used, the
update-ca-certificateshook, and an HTTPS connection from Java code. a4l-keyringhas not been built; the test build had no meta-gnome.- The
rootfs-linksPACKAGECONFIG, and thepipewire,libcamera,ffmpeganddrm-cxxPACKAGECONFIGs ofa4l, have not been built.
a4l presents through Vulkan and needs a device that exports dma-bufs. Under
runqemu the guest has none, and an app stops at acl-gpu: createDevice fail: the QEMU that openembedded-core builds has a virglrenderer without
Venus. A host QEMU that has it works, with the image's kernel and root file
system (QEMU 10.2 here, on a Mesa host driver):
zstd -d core-image-a4l-qemux86-64.rootfs.ext4.zst -o rootfs.ext4
qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -m 4096 \
-object memory-backend-memfd,id=mem1,size=4G \
-machine q35,i8042=off,memory-backend=mem1 \
-device virtio-vga-gl,hostmem=4G,blob=true,venus=true \
-display gtk,gl=on \
-drive file=rootfs.ext4,if=virtio,format=raw -snapshot \
-device virtio-net-pci,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-:22 \
-usb -device usb-tablet -device usb-kbd \
-kernel bzImage -append 'root=/dev/vda rw ip=dhcp console=ttyS0'ACL_PRESENT_GPU=0 does not select another path: a4l reads any value as on,
and its wl_shm path cannot show a real app.
pip install oelint-adv shellcheck-py shfmt-py
scripts/lint.sh # oelint-adv, shellcheck, then a shfmt diff
scripts/lint.sh --fix # the same, and shfmt rewrites the shell scriptsoelint-adv only reports; its findings are fixed by hand.
.oelint-constants.json names the layer's own variables for it.
The layer's metadata and scripts are MIT (COPYING.MIT). a4l is Apache-2.0.