mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-03 15:11:42 +01:00
Add flag to try different alarm for scheduled messages.
This commit is contained in:
committed by
Alex Hart
parent
4dea1d8aa1
commit
51e12b2c76
@@ -18,6 +18,7 @@ import androidx.annotation.WorkerThread;
|
||||
import org.signal.core.util.PendingIntentFlags;
|
||||
import org.signal.core.util.ThreadUtil;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
|
||||
/**
|
||||
@@ -108,7 +109,13 @@ public abstract class TimedEventManager<E> {
|
||||
boolean hasManagerPermission = Build.VERSION.SDK_INT < 31 || alarmManager.canScheduleExactAlarms();
|
||||
if (hasManagerPermission) {
|
||||
try {
|
||||
alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(timestamp, showIntent), pendingIntent);
|
||||
if (RemoteConfig.exactAlarm()) {
|
||||
Log.d(TAG, "[trySetExactAlarm] Using setExactAndAllowWhileIdle()");
|
||||
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, timestamp, pendingIntent);
|
||||
} else {
|
||||
Log.d(TAG, "[trySetExactAlarm] Using setAlarmClock()");
|
||||
alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(timestamp, showIntent), pendingIntent);
|
||||
}
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
|
||||
@@ -1343,5 +1343,16 @@ object RemoteConfig {
|
||||
hotSwappable = false
|
||||
)
|
||||
|
||||
/**
|
||||
* Whether to use setExactAlarmAndAllowWhileIdle for exact alarms.
|
||||
*/
|
||||
@JvmStatic
|
||||
@get:JvmName("exactAlarm")
|
||||
val exactAlarm: Boolean by remoteBoolean(
|
||||
key = "android.exactAlarm",
|
||||
defaultValue = false,
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user