ACINQ / phoenix

Phoenix is a self-custodial Bitcoin wallet using Lightning to send/receive payments.
https://phoenix.acinq.co
Apache License 2.0
679 stars 98 forks source link

(android) Split app into variants #620

Open dpad85 opened 2 months ago

dpad85 commented 2 months ago

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

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

Why make a non-google variant

It allows us to:

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.