Make sender key max age remote configurable.
This commit is contained in:
parent
f31e12572a
commit
35393fc331
2 changed files with 11 additions and 5 deletions
|
@ -63,8 +63,6 @@ public final class GroupSendUtil {
|
||||||
|
|
||||||
private static final String TAG = Log.tag(GroupSendUtil.class);
|
private static final String TAG = Log.tag(GroupSendUtil.class);
|
||||||
|
|
||||||
private static final long MAX_KEY_AGE = TimeUnit.DAYS.toMillis(30);
|
|
||||||
|
|
||||||
private GroupSendUtil() {}
|
private GroupSendUtil() {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,7 +221,7 @@ public final class GroupSendUtil {
|
||||||
long keyCreateTime = SenderKeyUtil.getCreateTimeForOurKey(context, distributionId);
|
long keyCreateTime = SenderKeyUtil.getCreateTimeForOurKey(context, distributionId);
|
||||||
long keyAge = System.currentTimeMillis() - keyCreateTime;
|
long keyAge = System.currentTimeMillis() - keyCreateTime;
|
||||||
|
|
||||||
if (keyCreateTime != -1 && keyAge > MAX_KEY_AGE) {
|
if (keyCreateTime != -1 && keyAge > FeatureFlags.senderKeyMaxAge()) {
|
||||||
Log.w(TAG, "Key is " + (keyAge) + " ms old (~" + TimeUnit.MILLISECONDS.toDays(keyAge) + " days). Rotating.");
|
Log.w(TAG, "Key is " + (keyAge) + " ms old (~" + TimeUnit.MILLISECONDS.toDays(keyAge) + " days). Rotating.");
|
||||||
SenderKeyUtil.rotateOurKey(context, distributionId);
|
SenderKeyUtil.rotateOurKey(context, distributionId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ public final class FeatureFlags {
|
||||||
private static final String RETRY_RECEIPT_LIFESPAN = "android.retryReceiptLifespan";
|
private static final String RETRY_RECEIPT_LIFESPAN = "android.retryReceiptLifespan";
|
||||||
private static final String RETRY_RESPOND_MAX_AGE = "android.retryRespondMaxAge";
|
private static final String RETRY_RESPOND_MAX_AGE = "android.retryRespondMaxAge";
|
||||||
private static final String SENDER_KEY = "android.senderKey.5";
|
private static final String SENDER_KEY = "android.senderKey.5";
|
||||||
|
private static final String SENDER_KEY_MAX_AGE = "android.senderKeyMaxAge";
|
||||||
private static final String RETRY_RECEIPTS = "android.retryReceipts";
|
private static final String RETRY_RECEIPTS = "android.retryReceipts";
|
||||||
private static final String SUGGEST_SMS_BLACKLIST = "android.suggestSmsBlacklist";
|
private static final String SUGGEST_SMS_BLACKLIST = "android.suggestSmsBlacklist";
|
||||||
private static final String MAX_GROUP_CALL_RING_SIZE = "global.calling.maxGroupCallRingSize";
|
private static final String MAX_GROUP_CALL_RING_SIZE = "global.calling.maxGroupCallRingSize";
|
||||||
|
@ -121,7 +122,8 @@ public final class FeatureFlags {
|
||||||
SUGGEST_SMS_BLACKLIST,
|
SUGGEST_SMS_BLACKLIST,
|
||||||
MAX_GROUP_CALL_RING_SIZE,
|
MAX_GROUP_CALL_RING_SIZE,
|
||||||
GROUP_CALL_RINGING,
|
GROUP_CALL_RINGING,
|
||||||
CDSH
|
CDSH,
|
||||||
|
SENDER_KEY_MAX_AGE
|
||||||
);
|
);
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -174,7 +176,8 @@ public final class FeatureFlags {
|
||||||
SENDER_KEY,
|
SENDER_KEY,
|
||||||
MAX_GROUP_CALL_RING_SIZE,
|
MAX_GROUP_CALL_RING_SIZE,
|
||||||
GROUP_CALL_RINGING,
|
GROUP_CALL_RINGING,
|
||||||
CDSH
|
CDSH,
|
||||||
|
SENDER_KEY_MAX_AGE
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -377,6 +380,11 @@ public final class FeatureFlags {
|
||||||
return getBoolean(SENDER_KEY, true);
|
return getBoolean(SENDER_KEY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** How long a sender key can live before it needs to be rotated. */
|
||||||
|
public static long senderKeyMaxAge() {
|
||||||
|
return Math.min(getLong(SENDER_KEY_MAX_AGE, TimeUnit.DAYS.toMillis(14)), TimeUnit.DAYS.toMillis(90));
|
||||||
|
}
|
||||||
|
|
||||||
/** A comma-delimited list of country codes that should not be told about SMS during onboarding. */
|
/** A comma-delimited list of country codes that should not be told about SMS during onboarding. */
|
||||||
public static @NonNull String suggestSmsBlacklist() {
|
public static @NonNull String suggestSmsBlacklist() {
|
||||||
return getString(SUGGEST_SMS_BLACKLIST, "");
|
return getString(SUGGEST_SMS_BLACKLIST, "");
|
||||||
|
|
Loading…
Add table
Reference in a new issue