Ensure notifications are processed after receiving GCM message.

It's unreliable to run these tasks on WorkManager, as there's no
scheduling guarantees.
This commit is contained in:
Greyson Parrelli
2018-10-05 15:23:33 -07:00
parent 1c197ad93d
commit 1b736e9e04
11 changed files with 208 additions and 63 deletions

View File

@@ -162,6 +162,8 @@ public class TextSecurePreferences {
private static final String NOTIFICATION_CHANNEL_VERSION = "pref_notification_channel_version";
private static final String NOTIFICATION_MESSAGES_CHANNEL_VERSION = "pref_notification_messages_channel_version";
private static final String NEEDS_MESSAGE_PULL = "pref_needs_message_pull";
public static boolean isScreenLockEnabled(@NonNull Context context) {
return getBooleanPreference(context, SCREEN_LOCK, false);
}
@@ -983,6 +985,14 @@ public class TextSecurePreferences {
setIntegerPrefrence(context, NOTIFICATION_MESSAGES_CHANNEL_VERSION, version);
}
public static boolean getNeedsMessagePull(Context context) {
return getBooleanPreference(context, NEEDS_MESSAGE_PULL, false);
}
public static void setNeedsMessagePull(Context context, boolean needsMessagePull) {
setBooleanPreference(context, NEEDS_MESSAGE_PULL, needsMessagePull);
}
public static void setBooleanPreference(Context context, String key, boolean value) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(key, value).apply();
}