A multiplexing proxy for GNSS on Ubuntu Touch with Waydroid. Lets both lomiri-location-service and Waydroid access the GPS HAL without fighting over it.
Both lomiri-location-service and Waydroid attempt to use the Android GPS HAL at the same time. Since only one can connect, whichever service grabs it first breaks GPS for the other. This library sits in the middle and lets both of them share it.
The proper solution would be for Waydroid to implement its own GNSS HAL service, rather than both trying to access the host HAL directly. This is just an evening project - an experiment to see if it can make life on UT a bit easier.
# In a suitable ARM64 environment with UBPorts repos and libgbinder-dev installed
meson setup builddir
ninja -C builddir
# On device
sudo cp builddir/libplatform-api-gnss-waydroid-proxy.so.0.1.0 /usr/lib/aarch64-linux-gnu/libplatform-api-gnss-waydroid-proxy.so.0sudo mkdir -p /etc/systemd/system/lomiri-location-service.service.d/Create /etc/systemd/system/lomiri-location-service.service.d/override.conf:
[Service]
Environment="LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libplatform-api-gnss-waydroid-proxy.so.0"Apply:
sudo systemctl daemon-reload
sudo systemctl restart lomiri-location-serviceCreate the VINTF manifest:
sudo mkdir -p /var/lib/waydroid/overlay_rw/vendor/etc/vintf/manifest/
sudo tee /var/lib/waydroid/overlay_rw/vendor/etc/vintf/manifest/gnss.xml > /dev/null << 'EOF'
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.gnss</name>
<version>2</version>
<interface>
<name>IGnss</name>
<instance>default</instance>
</interface>
</hal>
</manifest>
EOFUpdate the hosthals configuration:
sudo mkdir -p /var/lib/waydroid/overlay_rw/system/system/etc/
sudo cp /var/lib/waydroid/rootfs/system/etc/hosthals.xml \
/var/lib/waydroid/overlay_rw/system/system/etc/hosthals.xmlEdit the file and remove the GNSS <hal> block:
sudo nano /var/lib/waydroid/overlay_rw/system/system/etc/hosthals.xmlRemove:
<hal>
<name>android.hardware.gnss</name>
<priority>true</priority>
</hal>Then restart Waydroid and it should no longer break GPS in the system.
LGPL-2.1-only
Based on code from: