mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Separate PINs from Registration Lock.
You can now have a PIN without having registration lock. Note: We still need to change the registration flow to allow non-reglock users to enter their PIN.
This commit is contained in:
@@ -3,6 +3,9 @@ package org.thoughtcrime.securesms.util;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
/**
|
||||
* Helps prevent all the @Nullable warnings when working with LiveData.
|
||||
*/
|
||||
public class DefaultValueLiveData<T> extends MutableLiveData<T> {
|
||||
|
||||
private final T defaultValue;
|
||||
|
||||
@@ -53,7 +53,6 @@ public final class FeatureFlags {
|
||||
private static final String PINS_FOR_ALL_MANDATORY = "android.pinsForAllMandatory";
|
||||
private static final String PINS_MEGAPHONE_KILL_SWITCH = "android.pinsMegaphoneKillSwitch";
|
||||
private static final String PROFILE_NAMES_MEGAPHONE = "android.profileNamesMegaphone";
|
||||
private static final String STORAGE_SERVICE = "android.storageService.2";
|
||||
private static final String ATTACHMENTS_V3 = "android.attachmentsV3";
|
||||
|
||||
/**
|
||||
@@ -67,7 +66,6 @@ public final class FeatureFlags {
|
||||
PINS_MEGAPHONE_KILL_SWITCH,
|
||||
PROFILE_NAMES_MEGAPHONE,
|
||||
MESSAGE_REQUESTS,
|
||||
STORAGE_SERVICE,
|
||||
ATTACHMENTS_V3
|
||||
);
|
||||
|
||||
@@ -90,7 +88,6 @@ public final class FeatureFlags {
|
||||
*/
|
||||
private static final Set<String> HOT_SWAPPABLE = Sets.newHashSet(
|
||||
PINS_MEGAPHONE_KILL_SWITCH,
|
||||
STORAGE_SERVICE,
|
||||
ATTACHMENTS_V3
|
||||
);
|
||||
|
||||
@@ -183,9 +180,15 @@ public final class FeatureFlags {
|
||||
return value;
|
||||
}
|
||||
|
||||
/** Starts showing prompts for users to create PINs. */
|
||||
/**
|
||||
* - Starts showing prompts for users to create PINs.
|
||||
* - Shows new reminder UI.
|
||||
* - Shows new settings UI.
|
||||
* - Syncs to storage service.
|
||||
*/
|
||||
public static boolean pinsForAll() {
|
||||
return SignalStore.registrationValues().pinWasRequiredAtRegistration() ||
|
||||
SignalStore.kbsValues().isV2RegistrationLockEnabled() ||
|
||||
pinsForAllMandatory() ||
|
||||
getValue(PINS_FOR_ALL, false);
|
||||
}
|
||||
@@ -206,16 +209,6 @@ public final class FeatureFlags {
|
||||
TextSecurePreferences.getFirstInstallVersion(ApplicationDependencies.getApplication()) < 600;
|
||||
}
|
||||
|
||||
/** Whether or not we can actually restore data on a new installation. NOT remote-configurable. */
|
||||
public static boolean storageServiceRestore() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Whether or not we sync to the storage service. */
|
||||
public static boolean storageService() {
|
||||
return getValue(STORAGE_SERVICE, false);
|
||||
}
|
||||
|
||||
/** Whether or not we use the attachments v3 form. */
|
||||
public static boolean attachmentsV3() {
|
||||
return getValue(ATTACHMENTS_V3, false);
|
||||
|
||||
@@ -159,10 +159,12 @@ public class TextSecurePreferences {
|
||||
@Deprecated
|
||||
private static final String REGISTRATION_LOCK_PIN_PREF_V1 = "pref_registration_lock_pin";
|
||||
|
||||
public static final String REGISTRATION_LOCK_PREF_V2 = "pref_registration_lock_v2";
|
||||
|
||||
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";
|
||||
|
||||
public static final String KBS_PIN_CHANGE = "pref_kbs_change";
|
||||
public static final String SIGNAL_PIN_CHANGE = "pref_kbs_change";
|
||||
|
||||
private static final String SERVICE_OUTAGE = "pref_service_outage";
|
||||
private static final String LAST_OUTAGE_CHECK_TIME = "pref_last_outage_check_time";
|
||||
@@ -252,7 +254,7 @@ public class TextSecurePreferences {
|
||||
return getStringPreference(context, REGISTRATION_LOCK_PIN_PREF_V1, null);
|
||||
}
|
||||
|
||||
public static void clearOldRegistrationLockPin(@NonNull Context context) {
|
||||
public static void clearRegistrationLockV1(@NonNull Context context) {
|
||||
//noinspection deprecation
|
||||
PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.edit()
|
||||
@@ -264,7 +266,7 @@ public class TextSecurePreferences {
|
||||
* @deprecated Use only for migrations to the Key Backup Store registration pinV2.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setDeprecatedRegistrationLockPin(@NonNull Context context, String pin) {
|
||||
public static void setV1RegistrationLockPin(@NonNull Context context, String pin) {
|
||||
//noinspection deprecation
|
||||
setStringPreference(context, REGISTRATION_LOCK_PIN_PREF_V1, pin);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class SimpleTask {
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,15 @@ public class SimpleTask {
|
||||
* the main thread. Essentially {@link AsyncTask}, but lambda-compatible.
|
||||
*/
|
||||
public static <E> void run(@NonNull BackgroundTask<E> backgroundTask, @NonNull ForegroundTask<E> foregroundTask) {
|
||||
SignalExecutors.BOUNDED.execute(() -> {
|
||||
run(SignalExecutors.BOUNDED, backgroundTask, foregroundTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a task on the specified {@link Executor} and passes the result of the computation to a
|
||||
* task that is run on the main thread. Essentially {@link AsyncTask}, but lambda-compatible.
|
||||
*/
|
||||
public static <E> void run(@NonNull Executor executor, @NonNull BackgroundTask<E> backgroundTask, @NonNull ForegroundTask<E> foregroundTask) {
|
||||
executor.execute(() -> {
|
||||
final E result = backgroundTask.run();
|
||||
Util.runOnMain(() -> foregroundTask.run(result));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user