Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(android) Split app into variants #620

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

dpad85
Copy link
Member

@dpad85 dpad85 commented Sep 5, 2024

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.

The google flavor is able to use FCM notifications for background
processing. A FCM token is registered automatically.

The foss flavor does not embed any google play services and instead
relies on a permanent foreground service to process payments in the
background. This experimental service is opt-in and needs to be
manually started by the user. The user can configure whether or not
a partial wake lock should be acquired (enabled by default).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant