mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-25 19:47:31 +00:00
Control CDS refresh interval with a feature flag.
This commit is contained in:
@@ -6,14 +6,13 @@ import android.content.Intent;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class DirectoryRefreshListener extends PersistentAlarmManagerListener {
|
||||
|
||||
private static final long INTERVAL = TimeUnit.HOURS.toMillis(24);
|
||||
|
||||
@Override
|
||||
protected long getNextScheduledExecutionTime(Context context) {
|
||||
return TextSecurePreferences.getDirectoryRefreshTime(context);
|
||||
@@ -25,7 +24,9 @@ public class DirectoryRefreshListener extends PersistentAlarmManagerListener {
|
||||
ApplicationDependencies.getJobManager().add(new DirectoryRefreshJob(true));
|
||||
}
|
||||
|
||||
long newTime = System.currentTimeMillis() + INTERVAL;
|
||||
long interval = TimeUnit.SECONDS.toMillis(FeatureFlags.cdsRefreshIntervalSeconds());
|
||||
long newTime = System.currentTimeMillis() + interval;
|
||||
|
||||
TextSecurePreferences.setDirectoryRefreshTime(context, newTime);
|
||||
|
||||
return newTime;
|
||||
|
@@ -66,6 +66,7 @@ public final class FeatureFlags {
|
||||
private static final String GV1_MIGRATION_JOB = "android.groupsV1Migration.job";
|
||||
private static final String SEND_VIEWED_RECEIPTS = "android.sendViewedReceipts";
|
||||
private static final String CUSTOM_VIDEO_MUXER = "android.customVideoMuxer";
|
||||
private static final String CDS_REFRESH_INTERVAL = "cds.syncInterval.seconds";
|
||||
|
||||
/**
|
||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||
@@ -87,7 +88,8 @@ public final class FeatureFlags {
|
||||
GV1_FORCED_MIGRATE,
|
||||
GROUP_CALLING,
|
||||
SEND_VIEWED_RECEIPTS,
|
||||
CUSTOM_VIDEO_MUXER
|
||||
CUSTOM_VIDEO_MUXER,
|
||||
CDS_REFRESH_INTERVAL
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -119,7 +121,8 @@ public final class FeatureFlags {
|
||||
CLIENT_EXPIRATION,
|
||||
GROUP_CALLING,
|
||||
GV1_MIGRATION_JOB,
|
||||
CUSTOM_VIDEO_MUXER
|
||||
CUSTOM_VIDEO_MUXER,
|
||||
CDS_REFRESH_INTERVAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -270,6 +273,11 @@ public final class FeatureFlags {
|
||||
return getBoolean(CUSTOM_VIDEO_MUXER, false);
|
||||
}
|
||||
|
||||
/** The time in between routine CDS refreshes, in seconds. */
|
||||
public static int cdsRefreshIntervalSeconds() {
|
||||
return getInteger(CDS_REFRESH_INTERVAL, (int) TimeUnit.HOURS.toSeconds(48));
|
||||
}
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
||||
return new TreeMap<>(REMOTE_VALUES);
|
||||
|
Reference in New Issue
Block a user