mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Update registration for new restore flows.
This commit is contained in:
committed by
Greyson Parrelli
parent
aad2624bd5
commit
22c4e2d084
@@ -240,7 +240,7 @@ public class PinRestoreEntryFragment extends LoggingFragment {
|
||||
Activity activity = requireActivity();
|
||||
|
||||
if (RemoteConfig.messageBackups() && !SignalStore.registration().hasCompletedRestore()) {
|
||||
final Intent transferOrRestore = RestoreActivity.getIntentForTransferOrRestore(activity);
|
||||
final Intent transferOrRestore = RestoreActivity.getRestoreIntent(activity);
|
||||
transferOrRestore.putExtra(PassphraseRequiredActivity.NEXT_INTENT_EXTRA, MainActivity.clearTop(requireContext()));
|
||||
startActivity(transferOrRestore);
|
||||
} else if (Recipient.self().getProfileName().isEmpty() || !AvatarHelper.hasAvatar(activity, Recipient.self().getId())) {
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.thoughtcrime.securesms.pin
|
||||
import android.app.backup.BackupManager
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.annotation.WorkerThread
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.signal.core.util.Stopwatch
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.BuildConfig
|
||||
@@ -163,10 +164,13 @@ object SvrRepository {
|
||||
Log.i(TAG, "[restoreMasterKeyPostRegistration] Successfully restored master key. $implementation", true)
|
||||
stopwatch.split("restore")
|
||||
|
||||
SignalStore.registration.localRegistrationMetadata?.let { metadata ->
|
||||
SignalStore.registration.localRegistrationMetadata = metadata.copy(masterKey = response.masterKey.serialize().toByteString(), pin = userPin)
|
||||
}
|
||||
|
||||
SignalStore.svr.setMasterKey(response.masterKey, userPin)
|
||||
SignalStore.svr.isRegistrationLockEnabled = false
|
||||
SignalStore.pin.resetPinReminders()
|
||||
SignalStore.svr.isPinForgottenOrSkipped = false
|
||||
SignalStore.pin.keyboardType = pinKeyboardType
|
||||
SignalStore.storageService.setNeedsAccountRestore(false)
|
||||
|
||||
@@ -264,7 +268,6 @@ object SvrRepository {
|
||||
Log.i(TAG, "[setPin] Success!", true)
|
||||
|
||||
SignalStore.svr.setMasterKey(masterKey, userPin)
|
||||
SignalStore.svr.isPinForgottenOrSkipped = false
|
||||
responses
|
||||
.filterIsInstance<BackupResponse.Success>()
|
||||
.forEach {
|
||||
@@ -321,6 +324,9 @@ object SvrRepository {
|
||||
SignalStore.pin.resetPinReminders()
|
||||
|
||||
AppDependencies.jobManager.add(ResetSvrGuessCountJob())
|
||||
} else if (masterKey != null) {
|
||||
Log.i(TAG, "[onRegistrationComplete] ReRegistered with key without pin")
|
||||
SignalStore.svr.setMasterKey(masterKey, null)
|
||||
} else if (hasPinToRestore) {
|
||||
Log.i(TAG, "[onRegistrationComplete] Has a PIN to restore.", true)
|
||||
SignalStore.svr.clearRegistrationLockAndPin()
|
||||
@@ -342,7 +348,6 @@ object SvrRepository {
|
||||
operationLock.withLock {
|
||||
SignalStore.svr.clearRegistrationLockAndPin()
|
||||
SignalStore.storageService.setNeedsAccountRestore(false)
|
||||
SignalStore.svr.isPinForgottenOrSkipped = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,7 +369,7 @@ object SvrRepository {
|
||||
@Throws(IOException::class)
|
||||
fun enableRegistrationLockForUserWithPin() {
|
||||
operationLock.withLock {
|
||||
check(SignalStore.svr.hasPin() && !SignalStore.svr.hasOptedOut()) { "Must have a PIN to set a registration lock!" }
|
||||
check(SignalStore.svr.hasOptedInWithAccess() && !SignalStore.svr.hasOptedOut()) { "Must have a PIN to set a registration lock!" }
|
||||
|
||||
Log.i(TAG, "[enableRegistrationLockForUserWithPin] Enabling registration lock.", true)
|
||||
AppDependencies.signalServiceAccountManager.enableRegistrationLock(SignalStore.svr.masterKey)
|
||||
@@ -378,7 +383,7 @@ object SvrRepository {
|
||||
@Throws(IOException::class)
|
||||
fun disableRegistrationLockForUserWithPin() {
|
||||
operationLock.withLock {
|
||||
check(SignalStore.svr.hasPin() && !SignalStore.svr.hasOptedOut()) { "Must have a PIN to disable registration lock!" }
|
||||
check(SignalStore.svr.hasOptedInWithAccess() && !SignalStore.svr.hasOptedOut()) { "Must have a PIN to disable registration lock!" }
|
||||
|
||||
Log.i(TAG, "[disableRegistrationLockForUserWithPin] Disabling registration lock.", true)
|
||||
AppDependencies.signalServiceAccountManager.disableRegistrationLock()
|
||||
@@ -408,7 +413,7 @@ object SvrRepository {
|
||||
false
|
||||
}
|
||||
|
||||
if (newToken && SignalStore.svr.hasPin()) {
|
||||
if (newToken && SignalStore.svr.hasOptedInWithAccess()) {
|
||||
BackupManager(AppDependencies.application).dataChanged()
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
@@ -469,7 +474,7 @@ object SvrRepository {
|
||||
private val hasNoRegistrationLock: Boolean
|
||||
get() {
|
||||
return !SignalStore.svr.isRegistrationLockEnabled &&
|
||||
!SignalStore.svr.hasPin() &&
|
||||
!SignalStore.svr.hasOptedInWithAccess() &&
|
||||
!SignalStore.svr.hasOptedOut()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user