-
Notifications
You must be signed in to change notification settings - Fork 731
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
UnifiedPush #6228
UnifiedPush #6228
Conversation
This PR fixed #2743 |
Signed-off-by: sim <[email protected]>
…e constructor to clean up the API
vector/src/main/java/im/vector/app/core/pushers/UnifiedPushStore.kt
Outdated
Show resolved
Hide resolved
vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt
Outdated
Show resolved
Hide resolved
vector/src/test/java/im/vector/app/core/pushers/PushParserTest.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small remarks. Didn't test but good work!
vector/build.gradle
Outdated
@@ -348,6 +348,7 @@ dependencies { | |||
implementation project(":library:multipicker") | |||
implementation 'androidx.multidex:multidex:2.0.1' | |||
|
|||
implementation libs.jetbrains.kotlinReflect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, coming from the original PR, removed.
* [4] https://github.com/p1gp1g/sygnal/blob/unifiedpush/sygnal/upfcmpushkin.py (Not tested for a while) | ||
*/ | ||
fun parseData(message: String, firebaseFormat: Boolean): PushData? { | ||
val moshi = MatrixJsonParser.getMoshi() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope of this PR, I think
) | ||
} | ||
|
||
private fun gRegister( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why gRegister
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's from the original PR. Will rename some fun here, to follow our naming convention.
@@ -113,37 +125,59 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() { | |||
* when the InstanceID token is initially generated, so this is where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the comments ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment deleted.
private val vectorFeatures: VectorFeatures, | ||
private val fcmHelper: FcmHelper, | ||
) { | ||
private val up = UnifiedPush |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be injected too by adding a provides in a module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just an alias
to UnifiedPush
object. I will remove it, it does not bring anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes!
SonarCloud Quality Gate failed. |
Thank you for pursuing that goal! Element-FDroid is using way too much battery when idling... However, the use of UnifiedPush will only reduce the total amount of energy spent if the use of energy by the UnifiedPush Distributor (Gotify-UP, ntfy, ...) is lower than the avoided use of energy by the applications using UnifiedPush. In a case where Element is the only battery-expensive always-online app, the use of UnifiedPush currently does not reduce the total amount of energy spent (as far as I can tell); both Gotify-UP and ntfy actually use more energy than Element-FDroid in sync mode "real time". Here's a screenshot showing the battery usage of
Both Matrix clients are configured for the same account, so Element will probably have had to process more info via /sync than SchildiChat via UnifiedPush. (Yes, Conversations also is always-online.) |
Just a few things:
PS : have you disable battery optimization for ntfy ? |
sadly i have some experience with ntfy.sh on websocket, to save battery try json-stream over http. I do not know, how ntfy.sh has implemented websocket so battery hungry. |
Interesting. I wish there was a low-energy UnifiedPush Distributor app that I could recommend to my non-technical users, i.e. that can be run without them having to maintain a server-side thing.
Well, the numbers look completely reasonable. Typical energy consumption of that reference device (running Element, not running ntfy, mostly idling) is ~1.5% of battery capacity per hour (you'll have to believe me that it's been like that for many months). So after 11 hours since charging, I'd expect ~84% of battery capacity to be left. As the screenshot shows, the device did only have 76% left and said that ntfy had used 8% – if that's a lucky coincidence, I should go and buy lottery tickets. ;-)
Yes, ntfy prompted me to "fix" that setting (if I remember the wording correctly), warning about potential issues with notifications. I'm not leaning towards ignoring ntfy's recommendation, as (A) I'd expect my users to also follow the recommendation, and (B) nothing is worse for them than missing notifications, not even enormous battery usage... |
Type of change
Content
This PR includes the content of #3448 and some rework.
Other changes:
./docs/unifiedpush.md
BackgroundSyncStarter
andFcmHelper
are now injected 634acbcConfig
object 03f05a3Known bugs:
What can be done later: add a way to explain to the users how to install an external distributor.
Motivation and context
Closes #2743
It should highly reduce the battery usage of F-Droid version.
Screenshots / GIFs
New VectorFeature flag
New setting in notification (F-Droid)
The list of available distributors will be displayed here:
When Ntfy is selected, we got this notification:
And in the Ntfy app:
New setting in notification (GPlay)
Tests
Refer to #3448 (comment)
Tested devices
Checklist