A dive into Jolla AppSupport

You might be aware of Jolla, a Finnish company that emerged after Nokia decided to stop using MeeGo and went with Windows Phone instead. Around 2012 Jolla started out by making their own hardware (these days they no longer do) and they have their own OS based on the MeeGo stack, SailfishOS.

Because the app availability on Sailfish OS is rather slim, Jolla has built excellent middleware to run Android apps on Sailfish OS: AppSupport, known as Aliendalvik internally in Sailfish OS. Conceptually, Aliendalvik is a lot like Waydroid: It runs a modified Android system inside an LXC container, sharing the kernel with the host system. Compared to Waydroid, Aliendalvik has much better integration with the host. It shows Android apps as individual Wayland windows, it forwards notifications and MPRIS from Android, syncs Contacts from the host into Android, uses the native on-screen keyboard, and much much more.

Sailfish OS itself is free software and Jolla appears to be quite proud of this and their connection with the community (they have a forum where developers hang out and even implement ideas from users regularly). However, Aliendalvik is unfortunately proprietary: You only get binaries, no source code, and it’s only shipped as part of the images for their officially supported phones. To try it you first have to get your hands on one of these four Sony Xperia phones and then buy the Sailfish OS image in the Jolla online shop.

That said, once you bought and installed that image, you can play around with Sailfish OS and Aliendalvik. My initial experience was that Sailfish OS works fairly well and feels a lot more mature than what we have with GNOME Shell Mobile or Phosh (that’s not really a surprise given that it’s largely the same stack that was powering the N900, whereas our stack is completely different and a lot more work-in-progress). What blew me away though was how seamless the Aliendalvik integration is: Once you managed to install an Android app store, these Android apps feel almost completely native. If you didn’t know better you couldn’t tell it’s actually a containerized second OS.

Naturally, this sparked my interest in reverse engineering. After all, the Sailfish OS stack is so similar to ours that this thing might run on different distros, too. So I SSHed (yes, you can enable SSH in developer options!) into the phone and started exploring the internals of the OS a bit more in depth.

Diving into the Sailfish OS stack

The Sailfish userspace is mostly based on the same technologies that GNOME and KDE use: glibc, systemd, DBus, RPM and PackageKit, PulseAudio, BlueZ, Wayland, and Qt. They run their own Wayland compositor (lipstick, based on QtCompositor), apps run sandboxed using Firejail, networking is handled by ConnMan, the modem is handled by oFono, and sensors (apparently together with various other things) are handled using MCE, which is probably the furthest away from our stack.

The interesting thing here is that due to the fairly standard userspace Sailfish is using, the Android integration is mostly using standard freedesktop APIs to integrate with the host OS: Running Android apps are exposed as individual Wayland surfaces/windows, notifications from Android appear as org.freedesktop.Notification messages on DBus, music player controls are exposed using MPRIS, and even text input for android apps can be provided using the Wayland text input protocol.

This means that basically Aliendalvik should work just as well on a standard Linux distribution like Fedora, Arch Linux, or Debian. The Android container can be started using standard linux container tooling and the host integration binaries are compiled for ARM64 and mostly link to various open source Qt libraries.

Running it on Arch

So yeah, by now you probably have an idea where this is going: I replaced the underlying OS with Arch Linux ARM, and after a day or two I had bootup logs from the Android container. Another few days of getting all the system services inside Android to start and I had the Android settings app popping up as a Wayland window in GNOME Shell. By then I was pretty much hooked and wanted to get all the host integration working.

With a bunch of DBus API shimming, providing Qt libraries needed by the host-integration and small adjustments in the compositor and libwayland, the whole thing “just works”.

I’ve documented the reverse engineering work on this Github repo, including a very rough step-by-step manual of how to run things. Obviously I can’t share any binaries or other files proprietary to Jolla.

It’s closed source, how is any of this useful?

Well, first of all, reverse engineering is fun, and getting software like Aliendalvik to run on GNOME is a great challenge. From my personal standpoint, this is already enough justification ­čÖé

The usefulness of this work to the greater community depends on what Jolla will do going forward.

The Linux mobile community is growing, there’s better upstream software and hardware support than ever, and we have amazing communities of talented people; postmarketOS, KDE, GNOME, UBPorts, to name just a few. I’m convinced though that if we want Linux on phones to become an option for everyone, there’s no way around the need for well-integrated support for Android apps.

One option might be for Jolla to officially support running Aliendalvik on other desktop environments than Sailfish OS and offer the Aliendalvik binaries using a third-party repo. Users could then buy the software and get personalized access credentials to this repo, similar to how it works on Sailfish OS (Aliendalvik itself already implements a bunch of Wayland protocols which aren’t used in Lipstick, so it’s probably running under different compositors and trying to be a standard-compliant Wayland client already).

But in my opinion, the real potential for Aliendalvik would be in making it part of the open source community. Availability to the broader Linux community would mean we could work together and help fixing bugs, implement new features, and cooperate on the underlying stack to better meet Aliendalvik’s needs. And while Waydroid as the current FLOSS solution is great already, getting it to the point where Aliendalvik currently is at will take a lot of time and effort. It’s a shame we’ll have to redo that work when there’s a great solution out there already.

What’s next?

I’d like this post to be seen as invitation to both the FLOSS community and to Jolla.

As a community I think we should put more focus on Waydroid, sadly development there has slowed down recently. We need Android app compatibility if we want to get anywhere close to competing with Apple and Google. Every day we leave this problem unsolved is a win for them and a loss for the rest of the world.

On the other hand, I’d like to invite Jolla (or whoever actually owns Aliendalvik) to get in touch with the community about this. The industry is moving towards open source solutions, these days faster than ever. FLOSS software has become the standard in basically all areas. Aliendalvik could profit a lot from making this step, too.

Thanks for reading! If you have any insights or want to help figuring this problem out, please reach out to me at verdre@v0yd.nl.

15 thoughts on “A dive into Jolla AppSupport”

          1. Nice. I see that the camera is not supported on PostmarketOS. Did you manage to get it to work? If not it’ll look for a driver.

  1. I completely agree with you for mobile linux to take off it needs android app support.

    One thing i recall is the reason why the android compatability layer in sailfish has to be paid for is because it was made by an external company and they (Jolla) has to pay for it.

    But cant you just do what they did and copy it as in use the same method not like copy their code and add to waydroid?

    also never did i understood why the people behind wine never got into doing the same thing but instead windows app for android apps.

    sorry for my bad english

    Greetings from the netherlands

    1. Jolla acquired “enough rights” in their own words to develop on Alien Dalvik and use it more broadly. They’ve also licensed the technology to manufactures of smart car entertainment systems – a business which is now split into a separate company.
      Also I think the reason for not licensing Alien Dalvik to other mobile distributions and community ports of Sailfish is due to limited man power and the fact that they have to focus strictly on stuff which give them substantial income and/or a future.

      I’ll try to get more info on the Alien Dalvik situation in the next Sailfish community meeting.

      1. Nice ,All i want to say that as a low profile consumer any flashing tool is important also.I mean something easy I own a OnePlus 6t and ended up bricking it ,nothing dramatic but all i wanna say is thanks for bringing this experience and letting us to admire and YES IF YOU MANAGE TO ADD THOSE ANDROID APPS THIS BATTLE IS OVER AND LINUX WIN. Im just a Linux fan and I hope will see soon what you said implemented..

  2. This is absolutely amazing! Do you know if you HAVE to own an Xperia device to get the binaries if you are willing to pay for the software anyway?

    Thank you

    1. Right now you need to own a device to get the binaries, yes.

      Sailfish OS uses standard RPM repos though, so all that would need to be done is figure out the API to get the personalized repo URL from the Jolla account, and then you can start downloading the aliendalvik packages without owning a device.

  3. Very interesting post. I’m reading from my Xperia 10 with Sailfish using Firefox in Aliendalvik. I love SF. This is my 3┬░ sony device and next 10III is waiting its flash. I think Jolla needs support from the community like your work. New device and alternative it’s a need but…ÔÇŁ a long bigÔÇŁ mistake in Jolla marketing chooses…hope for other different future chooses!

  4. This was a very interesting read!

    It’s a shame that you need to have a SF device to get the binaries first. As others have commented, I think it would be beneficial for Jolla to release it to the wider community. I, for instance, would gladly pay for the entire OS just for the binaries if the results are like the video in the article.

    I completely agree with you that in order for Mobile Linux to be wildly adopted, it needs Android App support. I honestly am a bit surprised to see the discourse online where many don’t want Android App support at all. I work in mobile games and we had an interesting discussion about mobile linux before. Most, if not all, games and apps, won’t be ported to Linux simply because there is no secured and standartized payment systems setup like Android and Apple have.

    We cannot expect the masses to adopt a new ecosystem when it means they would need to give up apps that are basically ingrained into their everyday lives. Even someone like me, using Ubuntu Touch (Fairphone 3+) and Droidian (Pixel 3a xl) for the last few years, I still need Waydroid to validate my ID in Sweden for various services. Without it, Linux would simply not be an option, no matter how good the OS matures with every update.

    I honestly hope that your research here bears fruit. Opening up the discussion so Jolla can figure out a way to open Aliendalvik and have a bigger impact in the Mobile Linux community.

Leave a Reply

Your email address will not be published. Required fields are marked *