kopia lustrzana https://github.com/ryukoposting/Signal-Android
Always use inferred PIN state.
Saving the PIN state could lead to it being stale or mismanaged, and tbh we were using the inferred state to _set_ the value anyway.fork-5.53.8
rodzic
5009bd4e6a
commit
96a75a7f7f
|
@ -1627,7 +1627,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
if (itemAnimator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ViewCompat.setElevation(viewHolder.itemView, 0);
|
||||
lastTouched = null;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ public final class PinValues extends SignalStoreValues {
|
|||
private static final String LAST_SUCCESSFUL_ENTRY = "pin.last_successful_entry";
|
||||
private static final String NEXT_INTERVAL = "pin.interval_index";
|
||||
private static final String KEYBOARD_TYPE = "kbs.keyboard_type";
|
||||
private static final String PIN_STATE = "pin.pin_state";
|
||||
public static final String PIN_REMINDERS_ENABLED = "pin.pin_reminders_enabled";
|
||||
|
||||
PinValues(KeyValueStore store) {
|
||||
|
@ -108,13 +107,4 @@ public final class PinValues extends SignalStoreValues {
|
|||
putLong(NEXT_INTERVAL, maxInterval);
|
||||
}
|
||||
}
|
||||
|
||||
/** Should only be set by {@link org.thoughtcrime.securesms.pin.PinState} */
|
||||
public void setPinState(@NonNull String pinState) {
|
||||
getStore().beginWrite().putString(PIN_STATE, pinState).commit();
|
||||
}
|
||||
|
||||
public @Nullable String getPinState() {
|
||||
return getString(PIN_STATE, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.pin.PinState;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
public class LogSectionPin implements LogSection {
|
||||
|
@ -16,7 +17,7 @@ public class LogSectionPin implements LogSection {
|
|||
|
||||
@Override
|
||||
public @NonNull CharSequence getContent(@NonNull Context context) {
|
||||
return new StringBuilder().append("State: ").append(SignalStore.pinValues().getPinState()).append("\n")
|
||||
return new StringBuilder().append("State: ").append(PinState.getState()).append("\n")
|
||||
.append("Last Successful Reminder Entry: ").append(SignalStore.pinValues().getLastSuccessfulEntryTime()).append("\n")
|
||||
.append("Next Reminder Interval: ").append(SignalStore.pinValues().getCurrentInterval()).append("\n")
|
||||
.append("ReglockV1: ").append(TextSecurePreferences.isV1RegistrationLockEnabled(context)).append("\n")
|
||||
|
|
|
@ -73,8 +73,6 @@ public final class PinState {
|
|||
SignalStore.kbsValues().clearRegistrationLockAndPin();
|
||||
TextSecurePreferences.setV1RegistrationLockEnabled(context, false);
|
||||
}
|
||||
|
||||
updateState(buildInferredStateFromOtherFields());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,8 +88,6 @@ public final class PinState {
|
|||
SignalStore.storageService().setNeedsAccountRestore(false);
|
||||
resetPinRetryCount(context, pin);
|
||||
ClearFallbackKbsEnclaveJob.clearAll();
|
||||
|
||||
updateState(buildInferredStateFromOtherFields());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,8 +97,6 @@ public final class PinState {
|
|||
SignalStore.kbsValues().clearRegistrationLockAndPin();
|
||||
SignalStore.storageService().setNeedsAccountRestore(false);
|
||||
SignalStore.kbsValues().setPinForgottenOrSkipped(true);
|
||||
|
||||
updateState(buildInferredStateFromOtherFields());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,8 +130,6 @@ public final class PinState {
|
|||
} else {
|
||||
Log.i(TAG, "Not the first time setting a PIN. Enclave: " + kbsEnclave.getEnclaveName());
|
||||
}
|
||||
|
||||
updateState(buildInferredStateFromOtherFields());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,8 +151,6 @@ public final class PinState {
|
|||
assertState(State.PIN_WITH_REGISTRATION_LOCK_DISABLED, State.NO_REGISTRATION_LOCK);
|
||||
|
||||
optOutOfPin();
|
||||
|
||||
updateState(buildInferredStateFromOtherFields());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,8 +176,6 @@ public final class PinState {
|
|||
.newPinChangeSession(SignalStore.kbsValues().getRegistrationLockTokenResponse())
|
||||
.enableRegistrationLock(SignalStore.kbsValues().getOrCreateMasterKey());
|
||||
SignalStore.kbsValues().setV2RegistrationLockEnabled(true);
|
||||
|
||||
updateState(State.PIN_WITH_REGISTRATION_LOCK_ENABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,8 +197,6 @@ public final class PinState {
|
|||
.newPinChangeSession(SignalStore.kbsValues().getRegistrationLockTokenResponse())
|
||||
.disableRegistrationLock();
|
||||
SignalStore.kbsValues().setV2RegistrationLockEnabled(false);
|
||||
|
||||
updateState(State.PIN_WITH_REGISTRATION_LOCK_DISABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,8 +222,6 @@ public final class PinState {
|
|||
|
||||
kbsValues.setKbsMasterKey(kbsData, pin);
|
||||
TextSecurePreferences.clearRegistrationLockV1(context);
|
||||
|
||||
updateState(buildInferredStateFromOtherFields());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -346,24 +330,7 @@ public final class PinState {
|
|||
}
|
||||
}
|
||||
|
||||
private static @NonNull State getState() {
|
||||
String serialized = SignalStore.pinValues().getPinState();
|
||||
|
||||
if (serialized != null) {
|
||||
return State.deserialize(serialized);
|
||||
} else {
|
||||
State state = buildInferredStateFromOtherFields();
|
||||
SignalStore.pinValues().setPinState(state.serialize());
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateState(@NonNull State state) {
|
||||
Log.i(TAG, "Updating state to: " + state);
|
||||
SignalStore.pinValues().setPinState(state.serialize());
|
||||
}
|
||||
|
||||
private static @NonNull State buildInferredStateFromOtherFields() {
|
||||
public static @NonNull State getState() {
|
||||
Context context = ApplicationDependencies.getApplication();
|
||||
KbsValues kbsValues = SignalStore.kbsValues();
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue