mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 08:08:33 +00:00
Remove KBS feature flag.
This commit is contained in:
parent
4f921d761d
commit
ed0c4b8de5
@ -212,10 +212,8 @@ public final class RegistrationLockDialog {
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
RegistrationLockReminders.scheduleReminder(context, true);
|
RegistrationLockReminders.scheduleReminder(context, true);
|
||||||
|
|
||||||
if (FeatureFlags.kbs()) {
|
Log.i(TAG, "Pin V1 successfully remembered, scheduling a migration to V2");
|
||||||
Log.i(TAG, "Pin V1 successfully remembered, scheduling a migration to V2");
|
ApplicationDependencies.getJobManager().add(new RegistrationPinV2MigrationJob());
|
||||||
ApplicationDependencies.getJobManager().add(new RegistrationPinV2MigrationJob());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -285,32 +283,25 @@ public final class RegistrationLockDialog {
|
|||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... voids) {
|
protected Boolean doInBackground(Void... voids) {
|
||||||
try {
|
try {
|
||||||
if (FeatureFlags.kbs()) {
|
Log.i(TAG, "Setting pin on KBS");
|
||||||
Log.i(TAG, "Setting pin on KBS");
|
|
||||||
|
|
||||||
KbsValues kbsValues = SignalStore.kbsValues();
|
KbsValues kbsValues = SignalStore.kbsValues();
|
||||||
MasterKey masterKey = kbsValues.getOrCreateMasterKey();
|
MasterKey masterKey = kbsValues.getOrCreateMasterKey();
|
||||||
KeyBackupService keyBackupService = ApplicationDependencies.getKeyBackupService();
|
KeyBackupService keyBackupService = ApplicationDependencies.getKeyBackupService();
|
||||||
KeyBackupService.PinChangeSession pinChangeSession = keyBackupService.newPinChangeSession();
|
KeyBackupService.PinChangeSession pinChangeSession = keyBackupService.newPinChangeSession();
|
||||||
HashedPin hashedPin = PinHashing.hashPin(pinValue, pinChangeSession);
|
HashedPin hashedPin = PinHashing.hashPin(pinValue, pinChangeSession);
|
||||||
RegistrationLockData kbsData = pinChangeSession.setPin(hashedPin, masterKey);
|
RegistrationLockData kbsData = pinChangeSession.setPin(hashedPin, masterKey);
|
||||||
RegistrationLockData restoredData = keyBackupService.newRestoreSession(kbsData.getTokenResponse())
|
RegistrationLockData restoredData = keyBackupService.newRestoreSession(kbsData.getTokenResponse())
|
||||||
.restorePin(hashedPin);
|
.restorePin(hashedPin);
|
||||||
|
|
||||||
if (!restoredData.getMasterKey().equals(masterKey)) {
|
if (!restoredData.getMasterKey().equals(masterKey)) {
|
||||||
throw new AssertionError("Failed to set the pin correctly");
|
throw new AssertionError("Failed to set the pin correctly");
|
||||||
} else {
|
|
||||||
Log.i(TAG, "Set and retrieved pin on KBS successfully");
|
|
||||||
}
|
|
||||||
|
|
||||||
kbsValues.setRegistrationLockMasterKey(restoredData, PinHashing.localPinHash(pinValue));
|
|
||||||
TextSecurePreferences.clearOldRegistrationLockPin(context);
|
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "Setting V1 pin");
|
Log.i(TAG, "Set and retrieved pin on KBS successfully");
|
||||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
|
||||||
accountManager.setPin(pinValue);
|
|
||||||
TextSecurePreferences.setDeprecatedRegistrationLockPin(context, pinValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kbsValues.setRegistrationLockMasterKey(restoredData, PinHashing.localPinHash(pinValue));
|
||||||
|
TextSecurePreferences.clearOldRegistrationLockPin(context);
|
||||||
TextSecurePreferences.setRegistrationLockLastReminderTime(context, System.currentTimeMillis());
|
TextSecurePreferences.setRegistrationLockLastReminderTime(context, System.currentTimeMillis());
|
||||||
TextSecurePreferences.setRegistrationLockNextReminderInterval(context, RegistrationLockReminders.INITIAL_INTERVAL);
|
TextSecurePreferences.setRegistrationLockNextReminderInterval(context, RegistrationLockReminders.INITIAL_INTERVAL);
|
||||||
return true;
|
return true;
|
||||||
|
@ -13,7 +13,6 @@ import org.thoughtcrime.securesms.keyvalue.KbsValues;
|
|||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
import org.thoughtcrime.securesms.lock.PinHashing;
|
import org.thoughtcrime.securesms.lock.PinHashing;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.signalservice.api.KeyBackupService;
|
import org.whispersystems.signalservice.api.KeyBackupService;
|
||||||
import org.whispersystems.signalservice.api.KeyBackupServicePinException;
|
import org.whispersystems.signalservice.api.KeyBackupServicePinException;
|
||||||
@ -57,11 +56,6 @@ public final class RegistrationPinV2MigrationJob extends BaseJob {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onRun() throws IOException, UnauthenticatedResponseException, KeyBackupServicePinException {
|
protected void onRun() throws IOException, UnauthenticatedResponseException, KeyBackupServicePinException {
|
||||||
if (!FeatureFlags.kbs()) {
|
|
||||||
Log.i(TAG, "Not migrating pin to KBS");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TextSecurePreferences.isV1RegistrationLockEnabled(context)) {
|
if (!TextSecurePreferences.isV1RegistrationLockEnabled(context)) {
|
||||||
Log.i(TAG, "Registration lock disabled");
|
Log.i(TAG, "Registration lock disabled");
|
||||||
return;
|
return;
|
||||||
|
@ -27,7 +27,6 @@ import org.thoughtcrime.securesms.push.AccountManagerFactory;
|
|||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
import org.thoughtcrime.securesms.service.DirectoryRefreshListener;
|
import org.thoughtcrime.securesms.service.DirectoryRefreshListener;
|
||||||
import org.thoughtcrime.securesms.service.RotateSignedPreKeyListener;
|
import org.thoughtcrime.securesms.service.RotateSignedPreKeyListener;
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||||
import org.whispersystems.libsignal.state.PreKeyRecord;
|
import org.whispersystems.libsignal.state.PreKeyRecord;
|
||||||
@ -248,10 +247,8 @@ public final class CodeVerificationRequest {
|
|||||||
//noinspection deprecation Only acceptable place to write the old pin enabled state.
|
//noinspection deprecation Only acceptable place to write the old pin enabled state.
|
||||||
TextSecurePreferences.setV1RegistrationLockEnabled(context, pin != null);
|
TextSecurePreferences.setV1RegistrationLockEnabled(context, pin != null);
|
||||||
if (pin != null) {
|
if (pin != null) {
|
||||||
if (FeatureFlags.kbs()) {
|
Log.i(TAG, "Pin V1 successfully entered during registration, scheduling a migration to Pin V2");
|
||||||
Log.i(TAG, "Pin V1 successfully entered during registration, scheduling a migration to Pin V2");
|
ApplicationDependencies.getJobManager().add(new RegistrationPinV2MigrationJob());
|
||||||
ApplicationDependencies.getJobManager().add(new RegistrationPinV2MigrationJob());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SignalStore.kbsValues().setRegistrationLockMasterKey(kbsData, PinHashing.localPinHash(pin));
|
SignalStore.kbsValues().setRegistrationLockMasterKey(kbsData, PinHashing.localPinHash(pin));
|
||||||
|
@ -50,7 +50,6 @@ public final class FeatureFlags {
|
|||||||
private static final String PROFILE_DISPLAY = generateKey("profileDisplay");
|
private static final String PROFILE_DISPLAY = generateKey("profileDisplay");
|
||||||
private static final String MESSAGE_REQUESTS = generateKey("messageRequests");
|
private static final String MESSAGE_REQUESTS = generateKey("messageRequests");
|
||||||
private static final String USERNAMES = generateKey("usernames");
|
private static final String USERNAMES = generateKey("usernames");
|
||||||
private static final String KBS = generateKey("kbs");
|
|
||||||
private static final String STORAGE_SERVICE = generateKey("storageService");
|
private static final String STORAGE_SERVICE = generateKey("storageService");
|
||||||
private static final String PINS_FOR_ALL = generateKey("beta.pinsForAll"); // TODO [alex] remove beta prefix
|
private static final String PINS_FOR_ALL = generateKey("beta.pinsForAll"); // TODO [alex] remove beta prefix
|
||||||
private static final String PINS_MEGAPHONE_KILL_SWITCH = generateKey("pinsMegaphoneKillSwitch");
|
private static final String PINS_MEGAPHONE_KILL_SWITCH = generateKey("pinsMegaphoneKillSwitch");
|
||||||
@ -76,7 +75,6 @@ public final class FeatureFlags {
|
|||||||
* more burden on the reader to ensure that the app experience remains consistent.
|
* more burden on the reader to ensure that the app experience remains consistent.
|
||||||
*/
|
*/
|
||||||
private static final Set<String> HOT_SWAPPABLE = Sets.newHashSet(
|
private static final Set<String> HOT_SWAPPABLE = Sets.newHashSet(
|
||||||
KBS,
|
|
||||||
PINS_MEGAPHONE_KILL_SWITCH
|
PINS_MEGAPHONE_KILL_SWITCH
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -144,16 +142,9 @@ public final class FeatureFlags {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set or migrate PIN to KBS */
|
/** Storage service. */
|
||||||
public static boolean kbs() {
|
|
||||||
return getValue(KBS, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Storage service. Requires {@link #kbs()}. */
|
|
||||||
public static boolean storageService() {
|
public static boolean storageService() {
|
||||||
boolean value = getValue(STORAGE_SERVICE, false);
|
return getValue(STORAGE_SERVICE, false);
|
||||||
if (value && !kbs()) throw new MissingFlagRequirementError();
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Enables new KBS UI and notices but does not require user to set a pin */
|
/** Enables new KBS UI and notices but does not require user to set a pin */
|
||||||
|
@ -160,7 +160,6 @@ public class TextSecurePreferences {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
private static final String REGISTRATION_LOCK_PIN_PREF_V1 = "pref_registration_lock_pin";
|
private static final String REGISTRATION_LOCK_PIN_PREF_V1 = "pref_registration_lock_pin";
|
||||||
|
|
||||||
private static final String REGISTRATION_LOCK_LAST_REMINDER_TIME = "pref_registration_lock_last_reminder_time";
|
|
||||||
private static final String REGISTRATION_LOCK_LAST_REMINDER_TIME_POST_KBS = "pref_registration_lock_last_reminder_time_post_kbs";
|
private static final String REGISTRATION_LOCK_LAST_REMINDER_TIME_POST_KBS = "pref_registration_lock_last_reminder_time_post_kbs";
|
||||||
private static final String REGISTRATION_LOCK_NEXT_REMINDER_INTERVAL = "pref_registration_lock_next_reminder_interval";
|
private static final String REGISTRATION_LOCK_NEXT_REMINDER_INTERVAL = "pref_registration_lock_next_reminder_interval";
|
||||||
|
|
||||||
@ -272,16 +271,11 @@ public class TextSecurePreferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long getRegistrationLockLastReminderTime(@NonNull Context context) {
|
public static long getRegistrationLockLastReminderTime(@NonNull Context context) {
|
||||||
return getLongPreference(context, getAppropriateReminderKey(), 0);
|
return getLongPreference(context, REGISTRATION_LOCK_LAST_REMINDER_TIME_POST_KBS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRegistrationLockLastReminderTime(@NonNull Context context, long time) {
|
public static void setRegistrationLockLastReminderTime(@NonNull Context context, long time) {
|
||||||
setLongPreference(context, getAppropriateReminderKey(), time);
|
setLongPreference(context, REGISTRATION_LOCK_LAST_REMINDER_TIME_POST_KBS, time);
|
||||||
}
|
|
||||||
|
|
||||||
private static String getAppropriateReminderKey() {
|
|
||||||
return FeatureFlags.kbs() ? REGISTRATION_LOCK_LAST_REMINDER_TIME_POST_KBS
|
|
||||||
: REGISTRATION_LOCK_LAST_REMINDER_TIME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getRegistrationLockNextReminderInterval(@NonNull Context context) {
|
public static long getRegistrationLockNextReminderInterval(@NonNull Context context) {
|
||||||
|
@ -121,14 +121,6 @@ public class SignalServiceAccountManager {
|
|||||||
return this.pushServiceSocket.getSenderCertificateLegacy();
|
return this.pushServiceSocket.getSenderCertificateLegacy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Remove this method once KBS is live.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setPin(String pin) throws IOException {
|
|
||||||
this.pushServiceSocket.setPin(pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* V1 Pin setting has been replaced by KeyBackupService.
|
* V1 Pin setting has been replaced by KeyBackupService.
|
||||||
* Now you can only remove the old pin but there is no need to remove the old pin if setting a KBS Pin.
|
* Now you can only remove the old pin but there is no need to remove the old pin if setting a KBS Pin.
|
||||||
|
@ -297,11 +297,6 @@ public class PushServiceSocket {
|
|||||||
makeServiceRequest(String.format(Locale.US, REQUEST_PUSH_CHALLENGE, gcmRegistrationId, e164number), "GET", null);
|
makeServiceRequest(String.format(Locale.US, REQUEST_PUSH_CHALLENGE, gcmRegistrationId, e164number), "GET", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPin(String pin) throws IOException {
|
|
||||||
RegistrationLock accountLock = new RegistrationLock(pin);
|
|
||||||
makeServiceRequest(PIN_PATH, "PUT", JsonUtil.toJson(accountLock));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Note: Setting a KBS Pin will clear this */
|
/** Note: Setting a KBS Pin will clear this */
|
||||||
public void removePin() throws IOException {
|
public void removePin() throws IOException {
|
||||||
makeServiceRequest(PIN_PATH, "DELETE", null);
|
makeServiceRequest(PIN_PATH, "DELETE", null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user