mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 11:22:21 +00:00
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:
15
src/org/thoughtcrime/securesms/util/PowerManagerCompat.java
Normal file
15
src/org/thoughtcrime/securesms/util/PowerManagerCompat.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public class PowerManagerCompat {
|
||||
|
||||
public static boolean isDeviceIdleMode(@NonNull PowerManager powerManager) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
return powerManager.isDeviceIdleMode();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user