Hybris

Libhybris is an Android compatibility layer, allowing libraries compiled with bionic (Android) libc to be loaded by applications built with different libc (originally glibc, musl in postmarketOS case). It allows a device to run proprietary Android userspace drivers on top of a downstream kernel by running parts of Android in a container. The upsides and downsides of this approach are discussed in.

Currently, libhybris for postmarketOS exists in the form of the hybrisaports repo, and exists as an unofficial method of running postmarketOS without having to work on mainline or kernel drivers (assuming your kernel is compatible).

The aim is for the hybrisOS project to coexist with postmarketOS and ideally make it possible for users to experience postmarketOS on devices that otherwise wouldn't be able to run it (due to missing mainline support or poor quality kernels).

= Booting hybris on your device =

Get in touch
For help, feel free to come chat with us in #hybrisos:kde.org on Matrix, or @hybrisOS on Telegram!

= Halium 9 based ports =

Target Device
For Halium adaptation to work, your device must have:


 * armv7 or aarch64 architecture
 * Linux 3.17 or newer(need getrandom and memfd_create syscalls) - it is possible to backport these to 3.4 and perhaps 3.10
 * Project Treble support and Android 9 /vendor partition OR official Halium-9 port without Treble halium devices list.

Preparing kernel
For preparing kernel, you need to clone your device kernel repo (Lineage OS kernel is recommended), as well as the halium-boot repo:

Then, check kernel config with this command:

It is recommended to run the command twice to make sure everything got fixed. Then run the command again without  flag to check that it was able to find and enable all needed config options.

You should now push your defconfig changes up to a public git repository and follow the porting guide to create your kernel package using the kernel you just modified (don't forget to come back here after!).

pmaports
To add hybris packages to pmaports run the following:

Building
Make sure your kernel package is up to date:

Generate udev rules
Similarly to the ubports GSI, you will need to generate udev rules to make sure android device nodes and files all get the right permissions. Boot your device into TWRP and get a shell, then run:

Then from your host:

Make device-specific hybris package
Devices wishing to use hybris packages must use a slightly modified device package in order to make sure all the hybris packages get installed.

From an existing device package
If you already have a device package, you can simply make a copy - don't forget to change the device codename in the  file!

Apply needed modifications for hybris
Copy the  file you generated above to the new device package.

Use the OnePlus 6 device repo as an example to add the following changes to your APKBUILD. source="   ...    70-halium.rules    ... " subpackages="	$pkgname-nonfree-userland:nonfree_userland	$pkgname-hybris	$pkgname-hybris-x11:hybris_x11	$pkgname-hybris-phosh:hybris_phosh	$pkgname-hybris-quirks:hybris_quirks "

nonfree_userland { pkgdesc="Libhybris (Android 9) hardware adaptation packages" depends="$pkgname-hybris" mkdir "$subpkgdir" }

hybris { pkgdesc="Metapackage for libhybris (Android 9) adaptation" depends="hybris-gsi-9.0 pulseaudio-modules-droid-9.0 bluebinder" mkdir "$subpkgdir" }

hybris_x11 { pkgdesc="X11 modules for libhybris (Android 9) adaptation" depends="hybris-base-9.0-x11" install_if="$pkgname-hybris libx11" mkdir $subpkgdir }

hybris_phosh { pkgdesc="Phosh configuration for libhybris adaptation" install_if="$pkgname-hybris postmarketos-ui-phosh" depends="wlroots-hwc2" mkdir $subpkgdir }

hybris_quirks { pkgdesc="Fixes for this libhybris adaptation specific quirks" depends="hexdump hostapd dnsmasq" install_if="$pkgname-hybris" mkdir $subpkgdir }
 * 1) Any quirks or extra packages needed for this port

You can now follow the postmarketOS install guide as normal from the installation section.

= Halium 7 based ports =

= See also =
 * Old hybris pmaports
 * Previous version of this wiki page (before libhybris support was dropped from postmarketOS)
 * WIP Android 9 support for pmaports
 * Initial packaging of libhybris
 * Droid 4: the device for which NotKit originally made the libhybris support
 * Gemini PDA: NotKit also made it work with libhybris
 * One year of postmarketOS: libhybris and optional proprietary components
 * 219 days of postmarketOS: libre drivers and libhybris
 * Team meeting
 * halium-related packages
 * hybrisOS project page


 * Old hybris pmaports
 * Previous version of this wiki page (before libhybris support was dropped from postmarketOS)
 * WIP Android 9 support for pmaports
 * Initial packaging of libhybris
 * Droid 4: the device for which NotKit originally made the libhybris support
 * Gemini PDA: NotKit also made it work with libhybris
 * One year of postmarketOS: libhybris and optional proprietary components
 * 219 days of postmarketOS: libre drivers and libhybris