Skip to content

Commit

Permalink
Fix some PinState bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Apr 24, 2020
1 parent 575caa5 commit cca85bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/org/thoughtcrime/securesms/pin/PinState.java
Expand Up @@ -181,6 +181,12 @@ public static synchronized void onPinChangedOrCreated(@NonNull Context context,
@WorkerThread
public static synchronized void onEnableRegistrationLockForUserWithPin() throws IOException {
Log.i(TAG, "onEnableRegistrationLockForUserWithPin()");

if (getState() == State.PIN_WITH_REGISTRATION_LOCK_ENABLED) {
Log.i(TAG, "Registration lock already enabled. Skipping.");
return;
}

assertState(State.PIN_WITH_REGISTRATION_LOCK_DISABLED);

SignalStore.kbsValues().setV2RegistrationLockEnabled(false);
Expand All @@ -198,6 +204,12 @@ public static synchronized void onEnableRegistrationLockForUserWithPin() throws
@WorkerThread
public static synchronized void onDisableRegistrationLockForUserWithPin() throws IOException {
Log.i(TAG, "onDisableRegistrationLockForUserWithPin()");

if (getState() == State.PIN_WITH_REGISTRATION_LOCK_DISABLED) {
Log.i(TAG, "Registration lock already disabled. Skipping.");
return;
}

assertState(State.PIN_WITH_REGISTRATION_LOCK_ENABLED);

SignalStore.kbsValues().setV2RegistrationLockEnabled(true);
Expand Down
Expand Up @@ -194,6 +194,7 @@ public static synchronized boolean usernames() {
public static boolean pinsForAll() {
return SignalStore.registrationValues().pinWasRequiredAtRegistration() ||
SignalStore.kbsValues().isV2RegistrationLockEnabled() ||
SignalStore.kbsValues().hasPin() ||
pinsForAllMandatory() ||
getValue(PINS_FOR_ALL_LEGACY, false) ||
getValue(PINS_FOR_ALL, false);
Expand Down

0 comments on commit cca85bf

Please sign in to comment.