Update pin opt-out strings and behavior.

This commit is contained in:
Greyson Parrelli
2020-07-10 18:06:51 -04:00
parent e2021231c6
commit fce3df0c82
8 changed files with 60 additions and 76 deletions

View File

@@ -62,6 +62,7 @@ public final class KbsValues extends SignalStoreValues {
.putString(LOCK_LOCAL_PIN_HASH, PinHashing.localPinHash(pin))
.putString(PIN, pin)
.putLong(LAST_CREATE_FAILED_TIMESTAMP, -1)
.putBoolean(OPTED_OUT, false)
.commit();
}
@@ -144,27 +145,16 @@ public final class KbsValues extends SignalStoreValues {
return getLocalPinHash() != null;
}
/**
* Should only be called by {@link org.thoughtcrime.securesms.pin.PinState}.
*/
public synchronized void optIn() {
putBoolean(OPTED_OUT, false);
}
/**
* Should only be called by {@link org.thoughtcrime.securesms.pin.PinState}.
*/
/** Should only be called by {@link org.thoughtcrime.securesms.pin.PinState}. */
public synchronized void optOut() {
putBoolean(OPTED_OUT, true);
}
/**
* Should only be called by {@link org.thoughtcrime.securesms.pin.PinState}.
*/
public synchronized void resetMasterKey() {
getStore().beginWrite()
.remove(MASTER_KEY)
.apply();
.putBoolean(OPTED_OUT, true)
.remove(TOKEN_RESPONSE)
.putBlob(MASTER_KEY, MasterKey.createNew(new SecureRandom()).serialize())
.remove(LOCK_LOCAL_PIN_HASH)
.remove(PIN)
.putLong(LAST_CREATE_FAILED_TIMESTAMP, -1)
.commit();
}
public synchronized boolean hasOptedOut() {