Skip to content

Commit

Permalink
Update PIN feature flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Feb 6, 2020
1 parent 6281449 commit 5e59f77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,8 @@ public void setKeyboardType(@NonNull PinKeyboardType keyboardType) {
public @NonNull PinKeyboardType getKeyboardType() {
return PinKeyboardType.fromCode(store.getString(KEYBOARD_TYPE, null));
}

public boolean hasMigratedToPinsForAll() {
return store.getString(KEYBOARD_TYPE, null) != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ public final class FeatureFlags {
private static final String MESSAGE_REQUESTS = generateKey("messageRequests");
private static final String USERNAMES = generateKey("usernames");
private static final String STORAGE_SERVICE = generateKey("storageService");
private static final String PINS_FOR_ALL = generateKey("beta.pinsForAll"); // TODO [alex] remove beta prefix
private static final String PINS_FOR_ALL = generateKey("pinsForAll");
private static final String PINS_MEGAPHONE_KILL_SWITCH = generateKey("pinsMegaphoneKillSwitch");

/**
* We will only store remote values for flags in this set. If you want a flag to be controllable
* remotely, place it in here.
*/
private static final Set<String> REMOTE_CAPABLE = Sets.newHashSet(
PINS_MEGAPHONE_KILL_SWITCH
PINS_FOR_ALL,
PINS_MEGAPHONE_KILL_SWITCH
);

/**
Expand Down Expand Up @@ -87,7 +88,7 @@ public final class FeatureFlags {
* Flags in this set will stay true forever once they receive a true value from a remote config.
*/
private static final Set<String> STICKY = Sets.newHashSet(
PINS_FOR_ALL // TODO [alex] -- add android.beta.pinsForAll to sticky set when we remove prefix
PINS_FOR_ALL
);

private static final Map<String, Boolean> REMOTE_VALUES = new TreeMap<>();
Expand Down Expand Up @@ -154,7 +155,9 @@ public static boolean storageService() {

/** Enables new KBS UI and notices but does not require user to set a pin */
public static boolean pinsForAll() {
return SignalStore.registrationValues().pinWasRequiredAtRegistration() || getValue(PINS_FOR_ALL, false);
return SignalStore.registrationValues().pinWasRequiredAtRegistration() ||
SignalStore.kbsValues().hasMigratedToPinsForAll() ||
getValue(PINS_FOR_ALL, false);
}

/** Safety flag to disable Pins for All Megaphone */
Expand Down

0 comments on commit 5e59f77

Please sign in to comment.