Move new classes to repo package
as they all relate to interacting with the backup repository
This commit is contained in:
parent
32e116ffe1
commit
307ccf57de
54 changed files with 210 additions and 148 deletions
|
@ -11,6 +11,8 @@ import android.content.pm.PackageInfo
|
|||
import android.os.ParcelFileDescriptor
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.MediumTest
|
||||
import com.stevesoltys.seedvault.repo.BackupData
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import io.mockk.CapturingSlot
|
||||
import io.mockk.Runs
|
||||
|
|
|
@ -10,12 +10,12 @@ import androidx.test.filters.MediumTest
|
|||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.google.protobuf.ByteString
|
||||
import com.stevesoltys.seedvault.proto.SnapshotKt.blob
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupData
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupReceiver
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.BackupData
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
import com.stevesoltys.seedvault.transport.backup.SnapshotCreatorFactory
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import com.stevesoltys.seedvault.repo.SnapshotCreatorFactory
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import io.mockk.Runs
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.every
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.stevesoltys.seedvault.backend.webdav.storagePluginModuleWebDav
|
|||
import com.stevesoltys.seedvault.crypto.cryptoModule
|
||||
import com.stevesoltys.seedvault.header.headerModule
|
||||
import com.stevesoltys.seedvault.metadata.metadataModule
|
||||
import com.stevesoltys.seedvault.repo.repoModule
|
||||
import com.stevesoltys.seedvault.restore.install.installModule
|
||||
import com.stevesoltys.seedvault.restore.restoreUiModule
|
||||
import com.stevesoltys.seedvault.settings.AppListRetriever
|
||||
|
@ -147,6 +148,7 @@ open class App : Application() {
|
|||
restoreModule,
|
||||
installModule,
|
||||
storageModule,
|
||||
repoModule,
|
||||
workerModule,
|
||||
restoreUiModule,
|
||||
appModule
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.stevesoltys.seedvault.getStorageContext
|
|||
import com.stevesoltys.seedvault.permitDiskReads
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.settings.StoragePluginType
|
||||
import com.stevesoltys.seedvault.transport.backup.BlobCache
|
||||
import com.stevesoltys.seedvault.repo.BlobCache
|
||||
import org.calyxos.seedvault.core.backends.Backend
|
||||
import org.calyxos.seedvault.core.backends.BackendFactory
|
||||
import org.calyxos.seedvault.core.backends.BackendProperties
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.stevesoltys.seedvault.encodeBase64
|
|||
import com.stevesoltys.seedvault.header.VERSION
|
||||
import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR
|
||||
import com.stevesoltys.seedvault.proto.Snapshot
|
||||
import com.stevesoltys.seedvault.transport.backup.hexFromProto
|
||||
import com.stevesoltys.seedvault.repo.hexFromProto
|
||||
import com.stevesoltys.seedvault.worker.BASE_SPLIT
|
||||
import org.calyxos.backup.storage.crypto.StreamCrypto.toByteArray
|
||||
import java.nio.ByteBuffer
|
||||
|
|
|
@ -3,14 +3,13 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.stevesoltys.seedvault.MemoryLogger
|
||||
import com.stevesoltys.seedvault.backend.BackendManager
|
||||
import com.stevesoltys.seedvault.crypto.Crypto
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.SnapshotManager
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.delay
|
||||
import org.calyxos.seedvault.core.backends.AppBackupFileType.Blob
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 The Calyx Institute
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import com.stevesoltys.seedvault.proto.Snapshot.Blob
|
||||
|
||||
/**
|
||||
* Essential metadata returned when storing backup data.
|
||||
*
|
||||
* @param chunkIds an ordered(!) list of the chunk IDs required to re-assemble the backup data.
|
||||
* @param blobMap a mapping from chunk ID to [Blob] on the backend.
|
||||
* Needed for fetching blobs from the backend for re-assembly.
|
||||
*/
|
||||
data class BackupData(
|
||||
val chunkIds: List<String>,
|
||||
val blobMap: Map<String, Blob>,
|
||||
) {
|
||||
/**
|
||||
* The uncompressed plaintext size of all blobs.
|
||||
*/
|
||||
val size get() = blobMap.values.sumOf { it.uncompressedLength }.toLong()
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.stevesoltys.seedvault.crypto.Crypto
|
||||
|
@ -15,23 +15,6 @@ import org.calyxos.seedvault.core.toHexString
|
|||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
|
||||
/**
|
||||
* Essential metadata returned when storing backup data.
|
||||
*
|
||||
* @param chunkIds an ordered(!) list of the chunk IDs required to re-assemble the backup data.
|
||||
* @param blobMap a mapping from chunk ID to [Blob] on the backend.
|
||||
* Needed for fetching blobs from the backend for re-assembly.
|
||||
*/
|
||||
data class BackupData(
|
||||
val chunkIds: List<String>,
|
||||
val blobMap: Map<String, Blob>,
|
||||
) {
|
||||
/**
|
||||
* The uncompressed plaintext size of all blobs.
|
||||
*/
|
||||
val size get() = blobMap.values.sumOf { it.uncompressedLength }.toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* The single point for receiving data for backup.
|
||||
* Data received will get split into smaller chunks, if needed.
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Context.MODE_APPEND
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.github.luben.zstd.ZstdOutputStream
|
||||
|
@ -14,7 +14,7 @@ import com.stevesoltys.seedvault.crypto.Crypto
|
|||
import com.stevesoltys.seedvault.header.VERSION
|
||||
import com.stevesoltys.seedvault.proto.Snapshot.Blob
|
||||
import com.stevesoltys.seedvault.proto.SnapshotKt.blob
|
||||
import com.stevesoltys.seedvault.transport.backup.Padding.getPadTo
|
||||
import com.stevesoltys.seedvault.repo.Padding.getPadTo
|
||||
import okio.Buffer
|
||||
import okio.buffer
|
||||
import okio.sink
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.restore
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import com.android.internal.R.attr.handle
|
||||
import com.github.luben.zstd.ZstdInputStream
|
||||
|
@ -17,11 +17,8 @@ import org.calyxos.seedvault.core.backends.AppBackupFileType
|
|||
import org.calyxos.seedvault.core.toHexString
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.File
|
||||
import java.io.FilterInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.SequenceInputStream
|
||||
import java.nio.ByteBuffer
|
||||
import java.security.GeneralSecurityException
|
||||
import java.util.Enumeration
|
||||
|
||||
|
@ -107,42 +104,3 @@ internal class Loader(
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private class PaddedInputStream(inputStream: InputStream) : FilterInputStream(inputStream) {
|
||||
|
||||
val size: Int
|
||||
var bytesRead: Int = 0
|
||||
|
||||
init {
|
||||
val sizeBytes = ByteArray(4)
|
||||
val bytesRead = inputStream.read(sizeBytes)
|
||||
if (bytesRead != 4) {
|
||||
throw IOException("Could not read padding size: ${sizeBytes.toHexString()}")
|
||||
}
|
||||
size = ByteBuffer.wrap(sizeBytes).getInt()
|
||||
}
|
||||
|
||||
override fun read(): Int {
|
||||
if (bytesRead >= size) return -1
|
||||
return getReadBytes(super.read())
|
||||
}
|
||||
|
||||
override fun read(b: ByteArray, off: Int, len: Int): Int {
|
||||
if (bytesRead >= size) return -1
|
||||
if (bytesRead + len >= size) {
|
||||
return getReadBytes(super.read(b, off, size - bytesRead))
|
||||
}
|
||||
return getReadBytes(super.read(b, off, len))
|
||||
}
|
||||
|
||||
override fun available(): Int {
|
||||
return size - bytesRead
|
||||
}
|
||||
|
||||
private fun getReadBytes(read: Int): Int {
|
||||
if (read == -1) return -1
|
||||
bytesRead += read
|
||||
if (bytesRead > size) return -1
|
||||
return read
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 The Calyx Institute
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import org.calyxos.seedvault.core.toHexString
|
||||
import java.io.FilterInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
internal class PaddedInputStream(inputStream: InputStream) : FilterInputStream(inputStream) {
|
||||
|
||||
private val size: Int
|
||||
private var bytesRead: Int = 0
|
||||
|
||||
init {
|
||||
val sizeBytes = ByteArray(4)
|
||||
val bytesRead = inputStream.read(sizeBytes)
|
||||
if (bytesRead != 4) {
|
||||
throw IOException("Could not read padding size: ${sizeBytes.toHexString()}")
|
||||
}
|
||||
size = ByteBuffer.wrap(sizeBytes).getInt()
|
||||
}
|
||||
|
||||
override fun read(): Int {
|
||||
if (bytesRead >= size) return -1
|
||||
return getReadBytes(super.read())
|
||||
}
|
||||
|
||||
override fun read(b: ByteArray, off: Int, len: Int): Int {
|
||||
if (bytesRead >= size) return -1
|
||||
if (bytesRead + len >= size) {
|
||||
return getReadBytes(super.read(b, off, size - bytesRead))
|
||||
}
|
||||
return getReadBytes(super.read(b, off, len))
|
||||
}
|
||||
|
||||
override fun available(): Int {
|
||||
return size - bytesRead
|
||||
}
|
||||
|
||||
private fun getReadBytes(read: Int): Int {
|
||||
if (read == -1) return -1
|
||||
bytesRead += read
|
||||
if (bytesRead > size) return -1
|
||||
return read
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.log2
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 The Calyx Institute
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.dsl.module
|
||||
import java.io.File
|
||||
|
||||
val repoModule = module {
|
||||
single { BackupReceiver(get(), get(), get()) }
|
||||
single { BlobCache(androidContext()) }
|
||||
single { BlobCreator(get(), get()) }
|
||||
single { Loader(get(), get()) }
|
||||
single {
|
||||
val snapshotFolder = File(androidContext().filesDir, FOLDER_SNAPSHOTS)
|
||||
SnapshotManager(snapshotFolder, get(), get(), get())
|
||||
}
|
||||
factory { SnapshotCreatorFactory(androidContext(), get(), get(), get(), get()) }
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
|
@ -24,24 +24,12 @@ import com.stevesoltys.seedvault.proto.Snapshot.Apk
|
|||
import com.stevesoltys.seedvault.proto.Snapshot.App
|
||||
import com.stevesoltys.seedvault.proto.Snapshot.Blob
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
import com.stevesoltys.seedvault.transport.backup.isSystemApp
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import org.calyxos.seedvault.core.backends.AppBackupFileType
|
||||
import org.calyxos.seedvault.core.toHexString
|
||||
|
||||
/**
|
||||
* Creates a new [SnapshotCreator], because one is only valid for a single backup run.
|
||||
*/
|
||||
internal class SnapshotCreatorFactory(
|
||||
private val context: Context,
|
||||
private val clock: Clock,
|
||||
private val packageService: PackageService,
|
||||
private val settingsManager: SettingsManager,
|
||||
private val metadataManager: MetadataManager,
|
||||
) {
|
||||
fun createSnapshotCreator() =
|
||||
SnapshotCreator(context, clock, packageService, settingsManager, metadataManager)
|
||||
}
|
||||
|
||||
/**
|
||||
* Assembles snapshot information over the course of a single backup run
|
||||
* and creates a [Snapshot] object in the end by calling [finalizeSnapshot].
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 The Calyx Institute
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import android.content.Context
|
||||
import com.stevesoltys.seedvault.Clock
|
||||
import com.stevesoltys.seedvault.metadata.MetadataManager
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
|
||||
/**
|
||||
* Creates a new [SnapshotCreator], because one is only valid for a single backup run.
|
||||
*/
|
||||
internal class SnapshotCreatorFactory(
|
||||
private val context: Context,
|
||||
private val clock: Clock,
|
||||
private val packageService: PackageService,
|
||||
private val settingsManager: SettingsManager,
|
||||
private val metadataManager: MetadataManager,
|
||||
) {
|
||||
fun createSnapshotCreator() =
|
||||
SnapshotCreator(context, clock, packageService, settingsManager, metadataManager)
|
||||
}
|
|
@ -3,14 +3,13 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import com.github.luben.zstd.ZstdOutputStream
|
||||
import com.stevesoltys.seedvault.backend.BackendManager
|
||||
import com.stevesoltys.seedvault.crypto.Crypto
|
||||
import com.stevesoltys.seedvault.header.VERSION
|
||||
import com.stevesoltys.seedvault.proto.Snapshot
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import org.calyxos.seedvault.core.backends.AppBackupFileType
|
||||
import org.calyxos.seedvault.core.toHexString
|
||||
|
@ -19,6 +18,8 @@ import java.io.File
|
|||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
internal const val FOLDER_SNAPSHOTS = "snapshots"
|
||||
|
||||
/**
|
||||
* Manages interactions with snapshots, such as loading, saving and removing them.
|
||||
* Also keeps a reference to the [latestSnapshot] that holds important re-usable data.
|
|
@ -27,9 +27,9 @@ import com.stevesoltys.seedvault.restore.install.ApkInstallState.FAILED_SYSTEM_A
|
|||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.IN_PROGRESS
|
||||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.QUEUED
|
||||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.SUCCEEDED
|
||||
import com.stevesoltys.seedvault.transport.backup.getBlobHandles
|
||||
import com.stevesoltys.seedvault.repo.getBlobHandles
|
||||
import com.stevesoltys.seedvault.transport.backup.isSystemApp
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.transport.restore.RestorableBackup
|
||||
import com.stevesoltys.seedvault.worker.hashSignature
|
||||
import kotlinx.coroutines.TimeoutCancellationException
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.stevesoltys.seedvault.metadata.PackageState
|
|||
import com.stevesoltys.seedvault.metadata.PackageState.NO_DATA
|
||||
import com.stevesoltys.seedvault.metadata.PackageState.QUOTA_EXCEEDED
|
||||
import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
import java.io.IOException
|
||||
|
|
|
@ -5,21 +5,11 @@
|
|||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
|
||||
import com.stevesoltys.seedvault.transport.SnapshotManager
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.dsl.module
|
||||
import java.io.File
|
||||
|
||||
val backupModule = module {
|
||||
single { BackupInitializer(get()) }
|
||||
single { BackupReceiver(get(), get(), get()) }
|
||||
single { BlobCache(androidContext()) }
|
||||
single { BlobCreator(get(), get()) }
|
||||
single {
|
||||
val snapshotFolder = File(androidContext().filesDir, "snapshots")
|
||||
SnapshotManager(snapshotFolder, get(), get(), get())
|
||||
}
|
||||
single { SnapshotCreatorFactory(androidContext(), get(), get(), get(), get()) }
|
||||
single { InputFactory() }
|
||||
single {
|
||||
PackageService(
|
||||
|
|
|
@ -14,6 +14,8 @@ import android.content.pm.PackageInfo
|
|||
import android.os.ParcelFileDescriptor
|
||||
import android.util.Log
|
||||
import com.stevesoltys.seedvault.backend.isOutOfSpace
|
||||
import com.stevesoltys.seedvault.repo.BackupData
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
import java.io.Closeable
|
||||
|
|
|
@ -14,6 +14,8 @@ import android.app.backup.BackupTransport.TRANSPORT_OK
|
|||
import android.content.pm.PackageInfo
|
||||
import android.os.ParcelFileDescriptor
|
||||
import android.util.Log
|
||||
import com.stevesoltys.seedvault.repo.BackupData
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import java.io.IOException
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.stevesoltys.seedvault.header.HeaderReader
|
|||
import com.stevesoltys.seedvault.header.MAX_SEGMENT_LENGTH
|
||||
import com.stevesoltys.seedvault.header.UnsupportedVersionException
|
||||
import com.stevesoltys.seedvault.header.getADForFull
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import libcore.io.IoUtils.closeQuietly
|
||||
import org.calyxos.seedvault.core.backends.AppBackupFileType.Blob
|
||||
import org.calyxos.seedvault.core.backends.LegacyAppBackupFile
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.stevesoltys.seedvault.decodeBase64
|
|||
import com.stevesoltys.seedvault.header.HeaderReader
|
||||
import com.stevesoltys.seedvault.header.UnsupportedVersionException
|
||||
import com.stevesoltys.seedvault.header.getADForKV
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.transport.backup.KVDb
|
||||
import com.stevesoltys.seedvault.transport.backup.KvDbManager
|
||||
import libcore.io.IoUtils.closeQuietly
|
||||
|
|
|
@ -27,10 +27,11 @@ import com.stevesoltys.seedvault.metadata.DecryptionFailedException
|
|||
import com.stevesoltys.seedvault.metadata.MetadataManager
|
||||
import com.stevesoltys.seedvault.metadata.MetadataReader
|
||||
import com.stevesoltys.seedvault.proto.Snapshot
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.D2D_TRANSPORT_FLAGS
|
||||
import com.stevesoltys.seedvault.transport.DEFAULT_TRANSPORT_FLAGS
|
||||
import com.stevesoltys.seedvault.transport.backup.getBlobHandles
|
||||
import com.stevesoltys.seedvault.repo.getBlobHandles
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
import org.calyxos.seedvault.core.backends.AppBackupFileType
|
||||
import org.calyxos.seedvault.core.backends.Backend
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.koin.dsl.module
|
|||
|
||||
val restoreModule = module {
|
||||
single { OutputFactory() }
|
||||
single { Loader(get(), get()) }
|
||||
single { KVRestore(get(), get(), get(), get(), get(), get(), get()) }
|
||||
single { FullRestore(get(), get(), get(), get(), get(), get()) }
|
||||
single {
|
||||
|
|
|
@ -20,9 +20,9 @@ import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER
|
|||
import com.stevesoltys.seedvault.R
|
||||
import com.stevesoltys.seedvault.metadata.MetadataManager
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
import com.stevesoltys.seedvault.transport.backup.hexFromProto
|
||||
import com.stevesoltys.seedvault.repo.hexFromProto
|
||||
import com.stevesoltys.seedvault.worker.BackupRequester
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.koin.core.component.KoinComponent
|
||||
|
|
|
@ -18,10 +18,10 @@ import com.stevesoltys.seedvault.proto.Snapshot.Apk
|
|||
import com.stevesoltys.seedvault.proto.Snapshot.Blob
|
||||
import com.stevesoltys.seedvault.proto.SnapshotKt.split
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupReceiver
|
||||
import com.stevesoltys.seedvault.transport.backup.forProto
|
||||
import com.stevesoltys.seedvault.transport.backup.hexFromProto
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.repo.forProto
|
||||
import com.stevesoltys.seedvault.repo.hexFromProto
|
||||
import com.stevesoltys.seedvault.transport.backup.isNotUpdatedSystemApp
|
||||
import com.stevesoltys.seedvault.transport.backup.isTestOnly
|
||||
import org.calyxos.seedvault.core.toHexString
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.stevesoltys.seedvault.metadata.MetadataManager
|
|||
import com.stevesoltys.seedvault.metadata.PackageState.NOT_ALLOWED
|
||||
import com.stevesoltys.seedvault.metadata.PackageState.WAS_STOPPED
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.SnapshotManager
|
||||
import com.stevesoltys.seedvault.repo.SnapshotManager
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
import com.stevesoltys.seedvault.transport.backup.isStopped
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
|
|
|
@ -25,7 +25,7 @@ import androidx.work.WorkerParameters
|
|||
import com.stevesoltys.seedvault.R
|
||||
import com.stevesoltys.seedvault.backend.BackendManager
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
import com.stevesoltys.seedvault.ui.notification.NOTIFICATION_ID_OBSERVER
|
||||
import org.koin.core.component.KoinComponent
|
||||
|
|
|
@ -18,10 +18,10 @@ import com.stevesoltys.seedvault.R
|
|||
import com.stevesoltys.seedvault.crypto.Crypto
|
||||
import com.stevesoltys.seedvault.crypto.TYPE_ICONS
|
||||
import com.stevesoltys.seedvault.proto.Snapshot
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupReceiver
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.calyxos.backup.storage.crypto.StreamCrypto.toByteArray
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
package com.stevesoltys.seedvault.worker
|
||||
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.dsl.module
|
||||
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import com.stevesoltys.seedvault.backend.BackendManager
|
||||
import com.stevesoltys.seedvault.transport.SnapshotManager
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import io.mockk.Runs
|
||||
import io.mockk.andThenJust
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import com.stevesoltys.seedvault.getRandomByteArray
|
||||
import com.stevesoltys.seedvault.proto.Snapshot
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import android.content.Context
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
|
@ -3,12 +3,11 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import com.stevesoltys.seedvault.backend.BackendManager
|
||||
import com.stevesoltys.seedvault.getRandomByteArray
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
|
@ -3,9 +3,9 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import com.stevesoltys.seedvault.transport.backup.Padding.getPadTo
|
||||
import com.stevesoltys.seedvault.repo.Padding.getPadTo
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport.backup
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.ActivityInfo
|
||||
|
@ -17,6 +17,7 @@ import com.stevesoltys.seedvault.header.VERSION
|
|||
import com.stevesoltys.seedvault.metadata.BackupType
|
||||
import com.stevesoltys.seedvault.proto.Snapshot
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
import io.mockk.Runs
|
||||
import io.mockk.every
|
||||
import io.mockk.just
|
|
@ -3,11 +3,11 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.stevesoltys.seedvault.transport
|
||||
package com.stevesoltys.seedvault.repo
|
||||
|
||||
import com.stevesoltys.seedvault.backend.BackendManager
|
||||
import com.stevesoltys.seedvault.proto.snapshot
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import io.mockk.Runs
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.coVerify
|
|
@ -25,13 +25,13 @@ import com.stevesoltys.seedvault.proto.Snapshot
|
|||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.IN_PROGRESS
|
||||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.QUEUED
|
||||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.SUCCEEDED
|
||||
import com.stevesoltys.seedvault.transport.SnapshotManager
|
||||
import com.stevesoltys.seedvault.repo.SnapshotManager
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupReceiver
|
||||
import com.stevesoltys.seedvault.transport.backup.SnapshotCreator
|
||||
import com.stevesoltys.seedvault.transport.backup.hexFromProto
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.repo.SnapshotCreator
|
||||
import com.stevesoltys.seedvault.repo.hexFromProto
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.transport.restore.RestorableBackup
|
||||
import com.stevesoltys.seedvault.worker.ApkBackup
|
||||
import io.mockk.Runs
|
||||
|
|
|
@ -36,8 +36,8 @@ import com.stevesoltys.seedvault.restore.install.ApkInstallState.IN_PROGRESS
|
|||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.QUEUED
|
||||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.SUCCEEDED
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import com.stevesoltys.seedvault.transport.backup.hexFromProto
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import com.stevesoltys.seedvault.repo.hexFromProto
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import io.mockk.Runs
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.every
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.stevesoltys.seedvault.restore.install.ApkInstallState.IN_PROGRESS
|
|||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.QUEUED
|
||||
import com.stevesoltys.seedvault.restore.install.ApkInstallState.SUCCEEDED
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import io.mockk.Runs
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.every
|
||||
|
|
|
@ -22,18 +22,18 @@ import com.stevesoltys.seedvault.header.MAX_SEGMENT_CLEARTEXT_LENGTH
|
|||
import com.stevesoltys.seedvault.metadata.BackupType
|
||||
import com.stevesoltys.seedvault.metadata.MetadataReaderImpl
|
||||
import com.stevesoltys.seedvault.metadata.PackageMetadata
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.repo.SnapshotCreator
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupCoordinator
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupReceiver
|
||||
import com.stevesoltys.seedvault.transport.backup.FullBackup
|
||||
import com.stevesoltys.seedvault.transport.backup.InputFactory
|
||||
import com.stevesoltys.seedvault.transport.backup.KVBackup
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
import com.stevesoltys.seedvault.transport.backup.SnapshotCreator
|
||||
import com.stevesoltys.seedvault.transport.backup.TestKvDbManager
|
||||
import com.stevesoltys.seedvault.transport.restore.FullRestore
|
||||
import com.stevesoltys.seedvault.transport.restore.KVRestore
|
||||
import com.stevesoltys.seedvault.transport.restore.Loader
|
||||
import com.stevesoltys.seedvault.transport.restore.OutputFactory
|
||||
import com.stevesoltys.seedvault.transport.restore.RestorableBackup
|
||||
import com.stevesoltys.seedvault.transport.restore.RestoreCoordinator
|
||||
|
|
|
@ -30,9 +30,9 @@ import com.stevesoltys.seedvault.proto.SnapshotKt
|
|||
import com.stevesoltys.seedvault.proto.SnapshotKt.blob
|
||||
import com.stevesoltys.seedvault.proto.SnapshotKt.split
|
||||
import com.stevesoltys.seedvault.proto.snapshot
|
||||
import com.stevesoltys.seedvault.repo.BackupData
|
||||
import com.stevesoltys.seedvault.repo.hexFromProto
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupData
|
||||
import com.stevesoltys.seedvault.transport.backup.hexFromProto
|
||||
import com.stevesoltys.seedvault.worker.BASE_SPLIT
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
|
|
|
@ -17,6 +17,8 @@ import com.stevesoltys.seedvault.metadata.PackageMetadata
|
|||
import com.stevesoltys.seedvault.metadata.PackageState.NO_DATA
|
||||
import com.stevesoltys.seedvault.metadata.PackageState.QUOTA_EXCEEDED
|
||||
import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.SnapshotCreator
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
import com.stevesoltys.seedvault.worker.ApkBackup
|
||||
import io.mockk.Runs
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.app.backup.BackupTransport.TRANSPORT_ERROR
|
|||
import android.app.backup.BackupTransport.TRANSPORT_OK
|
||||
import android.app.backup.BackupTransport.TRANSPORT_PACKAGE_REJECTED
|
||||
import android.app.backup.BackupTransport.TRANSPORT_QUOTA_EXCEEDED
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
import io.mockk.Runs
|
||||
import io.mockk.coEvery
|
||||
|
|
|
@ -15,6 +15,7 @@ import android.app.backup.BackupTransport.TRANSPORT_OK
|
|||
import android.content.pm.PackageInfo
|
||||
import com.stevesoltys.seedvault.getRandomString
|
||||
import com.stevesoltys.seedvault.header.MAX_KEY_LENGTH_SIZE
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import io.mockk.CapturingSlot
|
||||
import io.mockk.Runs
|
||||
import io.mockk.coEvery
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.stevesoltys.seedvault.coAssertThrows
|
|||
import com.stevesoltys.seedvault.getRandomByteArray
|
||||
import com.stevesoltys.seedvault.header.MAX_SEGMENT_LENGTH
|
||||
import com.stevesoltys.seedvault.header.VERSION
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import io.mockk.CapturingSlot
|
||||
import io.mockk.Runs
|
||||
import io.mockk.coEvery
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.stevesoltys.seedvault.backend.BackendManager
|
|||
import com.stevesoltys.seedvault.coAssertThrows
|
||||
import com.stevesoltys.seedvault.getRandomByteArray
|
||||
import com.stevesoltys.seedvault.header.VERSION
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.transport.backup.KVDb
|
||||
import com.stevesoltys.seedvault.transport.backup.KvDbManager
|
||||
import io.mockk.Runs
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.stevesoltys.seedvault.getRandomByteArray
|
|||
import com.stevesoltys.seedvault.header.UnsupportedVersionException
|
||||
import com.stevesoltys.seedvault.header.VersionHeader
|
||||
import com.stevesoltys.seedvault.header.getADForKV
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.transport.backup.KVDb
|
||||
import com.stevesoltys.seedvault.transport.backup.KvDbManager
|
||||
import io.mockk.Runs
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.stevesoltys.seedvault.metadata.BackupType
|
|||
import com.stevesoltys.seedvault.metadata.MetadataReader
|
||||
import com.stevesoltys.seedvault.metadata.PackageMetadata
|
||||
import com.stevesoltys.seedvault.proto.copy
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
import io.mockk.Runs
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.stevesoltys.seedvault.crypto.KeyManagerTestImpl
|
|||
import com.stevesoltys.seedvault.encodeBase64
|
||||
import com.stevesoltys.seedvault.header.HeaderReaderImpl
|
||||
import com.stevesoltys.seedvault.metadata.MetadataReaderImpl
|
||||
import com.stevesoltys.seedvault.repo.Loader
|
||||
import com.stevesoltys.seedvault.toByteArrayFromHex
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import com.stevesoltys.seedvault.transport.backup.KvDbManager
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.stevesoltys.seedvault.metadata.PackageMetadata
|
|||
import com.stevesoltys.seedvault.metadata.PackageState.NOT_ALLOWED
|
||||
import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR
|
||||
import com.stevesoltys.seedvault.metadata.PackageState.WAS_STOPPED
|
||||
import com.stevesoltys.seedvault.transport.SnapshotManager
|
||||
import com.stevesoltys.seedvault.repo.SnapshotManager
|
||||
import com.stevesoltys.seedvault.transport.TransportTest
|
||||
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
|
|
|
@ -20,11 +20,11 @@ import com.stevesoltys.seedvault.getRandomString
|
|||
import com.stevesoltys.seedvault.proto.Snapshot
|
||||
import com.stevesoltys.seedvault.proto.SnapshotKt.app
|
||||
import com.stevesoltys.seedvault.proto.copy
|
||||
import com.stevesoltys.seedvault.transport.backup.AppBackupManager
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupData
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupReceiver
|
||||
import com.stevesoltys.seedvault.repo.AppBackupManager
|
||||
import com.stevesoltys.seedvault.repo.BackupData
|
||||
import com.stevesoltys.seedvault.repo.BackupReceiver
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupTest
|
||||
import com.stevesoltys.seedvault.transport.backup.SnapshotCreator
|
||||
import com.stevesoltys.seedvault.repo.SnapshotCreator
|
||||
import io.mockk.Runs
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.coVerify
|
||||
|
|
Loading…
Reference in a new issue