mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 10:20:25 +01:00
Add the ability to opt out of PINs.
This commit is contained in:
@@ -20,6 +20,7 @@ public final class KbsValues extends SignalStoreValues {
|
||||
private static final String PIN = "kbs.pin";
|
||||
private static final String LOCK_LOCAL_PIN_HASH = "kbs.registration_lock_local_pin_hash";
|
||||
private static final String LAST_CREATE_FAILED_TIMESTAMP = "kbs.last_create_failed_timestamp";
|
||||
public static final String OPTED_OUT = "kbs.opted_out";
|
||||
|
||||
KbsValues(KeyValueStore store) {
|
||||
super(store);
|
||||
@@ -41,6 +42,7 @@ public final class KbsValues extends SignalStoreValues {
|
||||
.remove(LOCK_LOCAL_PIN_HASH)
|
||||
.remove(PIN)
|
||||
.remove(LAST_CREATE_FAILED_TIMESTAMP)
|
||||
.remove(OPTED_OUT)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@@ -142,6 +144,33 @@ 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}.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
public synchronized boolean hasOptedOut() {
|
||||
return getBoolean(OPTED_OUT, false);
|
||||
}
|
||||
|
||||
public synchronized @Nullable TokenResponse getRegistrationLockTokenResponse() {
|
||||
String token = getStore().getString(TOKEN_RESPONSE, null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user