phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

(android) Split app into variants

Open dpad85 opened this issue 5 months ago • 0 comments

This PR splits the Android application into two variants, using the flavour mechanism of Android:

  • a google variant, with support for FCM notifications for just-in-time payments and background processing. It embeds some Google Play Services libraries.
  • a foss variant without any of the Google Play Services libraries, that is, without the FCM notifications.

The rest of the application is the same between the two variants.

Why make a non-google variant

It allows us to:

  • publish the app on non-Google app stores with strict requirements on the libraries used (e.g. with F-Droid, libraries must all be open source, which is not the case of the Play Service libraries)
  • be less dependent on 3rd parties, whether it's FCM or Google Play
  • give users more choice

Background processing without FCM

To receive payments Phoenix must be online. To make it possible for payments to be received even if the app is not running (which is the case most of the time for an app on a mobile device), we have been using FCM notifications.

This will still be the case on the google variant.

However the foss variant cannot use FCM. The alternative is to let Phoenix run in the background all the time, using a "foreground" service (i.e., you'll get a permanent notification for Phoenix in the Foreground Tasks Manager). This is similar to what Simplex is doing for chat messages.

Experimental feature

A new button has been added in Settings > Experimental features. Starting the service must be initiated manually by the user. If the service is not started then the app will behave normally, except that it won't be able to receive payments when the app is closed or in the background (depending on the Android version).

imageimageimage

image image image

Impact on battery

Due to the Doze/Stand-by mode optimisations, this background mode needs to acquire a partial wake-lock when started, so that the service is not eagerly killed by Android. This has a significant impact on battery usage.

How reliable is it

Tests look good, and payments are faster than with FCM. However it remains to be seen whether it's reliable enough on a vast array of devices to be worth the battery cost. If not, we'll need to reassess.

It's also possible that, in the longer term, the permanent foreground service solution is restricted on Android altogether.

dpad85 avatar Sep 05 '24 16:09 dpad85