Control CDS refresh interval with a feature flag.

This commit is contained in:
Greyson Parrelli
2021-01-12 12:47:34 -05:00
parent d5fb71b63f
commit 5370605815
2 changed files with 14 additions and 5 deletions

View File

@@ -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;

View File

@@ -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);