Use foreground services to process notification when appropriate.

Right now, the only condition is once every 3 minutes on Android 12.

This is ok because Android 12 will allow us (once every 2 minutes or
so) to start a foreground service, and it won't show it for the first 10
seconds. So we can kind of do it without any visual penalty.
This commit is contained in:
Greyson Parrelli
2022-04-18 11:27:32 -04:00
committed by GitHub
parent 8cfc013960
commit e09ce4c820
4 changed files with 54 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ public final class MiscellaneousValues extends SignalStoreValues {
private static final String CENSORSHIP_SERVICE_REACHABLE = "misc.censorship.service_reachable";
private static final String LAST_GV2_PROFILE_CHECK_TIME = "misc.last_gv2_profile_check_time";
private static final String CDS_TOKEN = "misc.cds_token";
private static final String LAST_FCM_FOREGROUND_TIME = "misc.last_fcm_foreground_time";
MiscellaneousValues(@NonNull KeyValueStore store) {
super(store);
@@ -149,4 +150,12 @@ public final class MiscellaneousValues extends SignalStoreValues {
.putBlob(CDS_TOKEN, token)
.commit();
}
public long getLastFcmForegroundServiceTime() {
return getLong(LAST_FCM_FOREGROUND_TIME, 0);
}
public void setLastFcmForegroundServiceTime(long time) {
putLong(LAST_FCM_FOREGROUND_TIME, time);
}
}