1package com.peachpasswords.sync23import android.content.Context4import dagger.hilt.android.qualifiers.ApplicationContext5import javax.inject.Inject6import javax.inject.Singleton789101112@Singleton13class SyncFreshStartResetter @Inject constructor(14 @ApplicationContext private val context: Context,15 private val devices: PairedDeviceStore,16 private val pendingDevices: PendingVouchedDeviceStore,17 private val alerts: SyncAlertStore,18 private val outcomes: SyncOutcomeStore,19 private val relaySettings: RelaySettingsStore,20 private val backgroundSync: BackgroundSyncPreference,21 private val lockedSyncSpool: LockedSyncSpoolStore,22) {23 fun reset() {24 resetSyncStateForFreshStart(25 stopService = { PeachSyncService.stop(context) },26 clearDevices = devices::clear,27 clearPendingDevices = pendingDevices::clear,28 clearAlerts = alerts::clear,29 clearOutcomes = outcomes::reset,30 clearRelaySettings = relaySettings::reset,31 clearBackgroundPreference = backgroundSync::reset,32 clearLocalIdentity = { clearDeviceIdentity(context) },33 clearLockedSyncSpool = lockedSyncSpool::clear,34 )35 }36}3738internal fun resetSyncStateForFreshStart(39 stopService: () -> Unit,40 clearDevices: () -> Unit,41 clearPendingDevices: () -> Unit,42 clearAlerts: () -> Unit,43 clearOutcomes: () -> Unit,44 clearRelaySettings: () -> Unit,45 clearBackgroundPreference: () -> Unit,46 clearLocalIdentity: () -> Unit,47 clearLockedSyncSpool: () -> Unit = {},48) {49 stopService()50 clearDevices()51 clearPendingDevices()52 clearAlerts()53 clearOutcomes()54 clearRelaySettings()55 clearBackgroundPreference()56 clearLocalIdentity()57 clearLockedSyncSpool()58}