NotKit/platform-api-gnss-waydroid-proxy

A multiplexing proxy for GNSS HAL on Ubuntu Touch with Waydroid

★ 0Forks 0C++GitHub ↗Compare

README

platform-api-gnss-waydroid-proxy

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.

Installation

1. Build and install the library

# 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.0

2. Load via LD_PRELOAD in lomiri-location-service

sudo 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-service

3. Configure Waydroid

Create 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>
EOF

Update 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.xml

Edit the file and remove the GNSS <hal> block:

sudo nano /var/lib/waydroid/overlay_rw/system/system/etc/hosthals.xml

Remove:

<hal>
    <name>android.hardware.gnss</name>
    <priority>true</priority>
</hal>

Then restart Waydroid and it should no longer break GPS in the system.

License

LGPL-2.1-only

Based on code from:

Contributors

NotKit

Issues