Update registration to allow PIN entry.

This commit is contained in:
Greyson Parrelli
2020-04-07 13:19:53 -04:00
parent 6b37675a81
commit acbfff89d3
46 changed files with 1206 additions and 161 deletions

View File

@@ -28,6 +28,8 @@ public final class KbsValues {
/**
* Deliberately does not clear the {@link #MASTER_KEY}.
*
* Should only be called by {@link org.thoughtcrime.securesms.pin.PinState}
*/
public void clearRegistrationLockAndPin() {
store.beginWrite()
@@ -37,6 +39,7 @@ public final class KbsValues {
.commit();
}
/** Should only be set by {@link org.thoughtcrime.securesms.pin.PinState}. */
public synchronized void setKbsMasterKey(@NonNull KbsPinData pinData, @NonNull String localPinHash) {
MasterKey masterKey = pinData.getMasterKey();
String tokenResponse;
@@ -53,6 +56,7 @@ public final class KbsValues {
.commit();
}
/** Should only be set by {@link org.thoughtcrime.securesms.pin.PinState}. */
public synchronized void setV2RegistrationLockEnabled(boolean enabled) {
store.beginWrite().putBoolean(V2_LOCK_ENABLED, enabled).apply();
}

View File

@@ -85,6 +85,7 @@ public final class PinValues {
return PinKeyboardType.fromCode(store.getString(KEYBOARD_TYPE, null));
}
/** Should only be set by {@link org.thoughtcrime.securesms.pin.PinState} */
public void setPinState(@NonNull String pinState) {
store.beginWrite().putString(PIN_STATE, pinState).commit();
}

View File

@@ -10,7 +10,8 @@ import java.security.SecureRandom;
public class StorageServiceValues {
private static final String LAST_SYNC_TIME = "storage.last_sync_time";
private static final String LAST_SYNC_TIME = "storage.last_sync_time";
private static final String NEEDS_ACCOUNT_RESTORE = "storage.needs_account_restore";
private final KeyValueStore store;
@@ -29,4 +30,12 @@ public class StorageServiceValues {
public void onSyncCompleted() {
store.beginWrite().putLong(LAST_SYNC_TIME, System.currentTimeMillis()).apply();
}
public boolean needsAccountRestore() {
return store.getBoolean(NEEDS_ACCOUNT_RESTORE, false);
}
public void setNeedsAccountRestore(boolean value) {
store.beginWrite().putBoolean(NEEDS_ACCOUNT_RESTORE, value).apply();
}
}