Clean up libraries, move to where they are included

This commit is contained in:
Torsten Grote 2024-09-23 09:30:43 -03:00
parent 1aa5c68d0a
commit 1e5a4deedf
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
19 changed files with 48 additions and 73 deletions

View file

@ -37,12 +37,13 @@ android_app {
"com.google.android.material_material", "com.google.android.material_material",
"kotlinx-coroutines-android", "kotlinx-coroutines-android",
"kotlinx-coroutines-core", "kotlinx-coroutines-core",
"seedvault-lib-kotlin-logging-jvm",
// app backup related libs // app backup related libs
"seedvault-lib-protobuf-kotlin-lite", "seedvault-lib-protobuf-kotlin-lite",
"seedvault-lib-kotlin-logging-jvm",
"seedvault-logback-android", "seedvault-logback-android",
"seedvault-lib-chunker", "seedvault-lib-chunker",
"seedvault-lib-zstd-jni", "seedvault-lib-zstd-jni",
"okio-lib",
// our own gradle module libs // our own gradle module libs
"seedvault-lib-core", "seedvault-lib-core",
"seedvault-lib-storage", "seedvault-lib-storage",
@ -51,9 +52,6 @@ android_app {
"seedvault-lib-koin-android", "seedvault-lib-koin-android",
// bip39 // bip39
"seedvault-lib-kotlin-bip39", "seedvault-lib-kotlin-bip39",
// WebDAV
"seedvault-lib-dav4jvm",
"seedvault-lib-okhttp",
], ],
use_embedded_native_libs: true, use_embedded_native_libs: true,
manifest: "app/src/main/AndroidManifest.xml", manifest: "app/src/main/AndroidManifest.xml",

View file

@ -185,8 +185,6 @@ dependencies {
implementation(fileTree("${rootProject.rootDir}/libs").include("kotlin-bip39-jvm-1.0.8.jar")) implementation(fileTree("${rootProject.rootDir}/libs").include("kotlin-bip39-jvm-1.0.8.jar"))
implementation(fileTree("${rootProject.rootDir}/libs").include("logback-android-3.0.0.aar")) implementation(fileTree("${rootProject.rootDir}/libs").include("logback-android-3.0.0.aar"))
implementation(fileTree("${rootProject.rootDir}/libs/dav4jvm").include("*.jar"))
/** /**
* Test Dependencies (do not concern the AOSP build) * Test Dependencies (do not concern the AOSP build)
*/ */

View file

@ -1,38 +0,0 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend
import at.bitfire.dav4jvm.exception.HttpException
import org.calyxos.seedvault.core.backends.AppBackupFileType
import org.calyxos.seedvault.core.backends.Backend
import org.calyxos.seedvault.core.backends.FileHandle
import org.calyxos.seedvault.core.backends.LegacyAppBackupFile
import java.io.IOException
suspend fun Backend.getAvailableBackupFileHandles(): List<FileHandle> {
// v1 get all restore set tokens in root folder that have a metadata file
// v2 get all snapshots in all repository folders
return ArrayList<FileHandle>().apply {
list(
null,
AppBackupFileType.Snapshot::class,
LegacyAppBackupFile.Metadata::class,
) { fileInfo ->
add(fileInfo.fileHandle)
}
}
}
fun Exception.isOutOfSpace(): Boolean {
return when (this) {
is IOException -> message?.contains("No space left on device") == true ||
(cause as? HttpException)?.code == 507
is HttpException -> code == 507
else -> false
}
}

View file

@ -15,7 +15,6 @@ import android.util.Log
import androidx.annotation.WorkerThread import androidx.annotation.WorkerThread
import com.stevesoltys.seedvault.R import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.backend.BackendManager import com.stevesoltys.seedvault.backend.BackendManager
import com.stevesoltys.seedvault.backend.getAvailableBackupFileHandles
import com.stevesoltys.seedvault.isMassStorage import com.stevesoltys.seedvault.isMassStorage
import com.stevesoltys.seedvault.settings.FlashDrive import com.stevesoltys.seedvault.settings.FlashDrive
import com.stevesoltys.seedvault.settings.SettingsManager import com.stevesoltys.seedvault.settings.SettingsManager

View file

@ -6,15 +6,14 @@
package com.stevesoltys.seedvault.backend.webdav package com.stevesoltys.seedvault.backend.webdav
import android.content.Context import android.content.Context
import android.net.Uri
import android.util.Log import android.util.Log
import androidx.annotation.WorkerThread import androidx.annotation.WorkerThread
import com.stevesoltys.seedvault.R import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.backend.BackendManager import com.stevesoltys.seedvault.backend.BackendManager
import com.stevesoltys.seedvault.backend.getAvailableBackupFileHandles
import com.stevesoltys.seedvault.settings.SettingsManager import com.stevesoltys.seedvault.settings.SettingsManager
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.asStateFlow
import okhttp3.HttpUrl.Companion.toHttpUrl
import org.calyxos.seedvault.core.backends.Backend import org.calyxos.seedvault.core.backends.Backend
import org.calyxos.seedvault.core.backends.BackendFactory import org.calyxos.seedvault.core.backends.BackendFactory
import org.calyxos.seedvault.core.backends.webdav.WebDavConfig import org.calyxos.seedvault.core.backends.webdav.WebDavConfig
@ -43,7 +42,7 @@ internal class WebDavHandler(
companion object { companion object {
fun createWebDavProperties(context: Context, config: WebDavConfig): WebDavProperties { fun createWebDavProperties(context: Context, config: WebDavConfig): WebDavProperties {
val host = config.url.toHttpUrl().host val host = Uri.parse(config.url).host
return WebDavProperties( return WebDavProperties(
config = config, config = config,
name = context.getString(R.string.storage_webdav_name, host), name = context.getString(R.string.storage_webdav_name, host),

View file

@ -22,7 +22,6 @@ import android.util.Log
import androidx.annotation.WorkerThread import androidx.annotation.WorkerThread
import com.stevesoltys.seedvault.Clock import com.stevesoltys.seedvault.Clock
import com.stevesoltys.seedvault.backend.BackendManager import com.stevesoltys.seedvault.backend.BackendManager
import com.stevesoltys.seedvault.backend.isOutOfSpace
import com.stevesoltys.seedvault.metadata.BackupType import com.stevesoltys.seedvault.metadata.BackupType
import com.stevesoltys.seedvault.metadata.MetadataManager import com.stevesoltys.seedvault.metadata.MetadataManager
import com.stevesoltys.seedvault.metadata.PackageState import com.stevesoltys.seedvault.metadata.PackageState
@ -32,6 +31,7 @@ import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR
import com.stevesoltys.seedvault.repo.AppBackupManager import com.stevesoltys.seedvault.repo.AppBackupManager
import com.stevesoltys.seedvault.settings.SettingsManager import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
import org.calyxos.seedvault.core.backends.isOutOfSpace
import java.io.IOException import java.io.IOException
import java.util.concurrent.TimeUnit.DAYS import java.util.concurrent.TimeUnit.DAYS
import java.util.concurrent.TimeUnit.HOURS import java.util.concurrent.TimeUnit.HOURS

View file

@ -13,11 +13,11 @@ import android.app.backup.BackupTransport.TRANSPORT_QUOTA_EXCEEDED
import android.content.pm.PackageInfo import android.content.pm.PackageInfo
import android.os.ParcelFileDescriptor import android.os.ParcelFileDescriptor
import android.util.Log import android.util.Log
import com.stevesoltys.seedvault.backend.isOutOfSpace
import com.stevesoltys.seedvault.repo.BackupData import com.stevesoltys.seedvault.repo.BackupData
import com.stevesoltys.seedvault.repo.BackupReceiver import com.stevesoltys.seedvault.repo.BackupReceiver
import com.stevesoltys.seedvault.settings.SettingsManager import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
import org.calyxos.seedvault.core.backends.isOutOfSpace
import java.io.Closeable import java.io.Closeable
import java.io.EOFException import java.io.EOFException
import java.io.IOException import java.io.IOException

View file

@ -19,7 +19,6 @@ import android.util.Log
import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER
import com.stevesoltys.seedvault.R import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.backend.BackendManager import com.stevesoltys.seedvault.backend.BackendManager
import com.stevesoltys.seedvault.backend.getAvailableBackupFileHandles
import com.stevesoltys.seedvault.crypto.Crypto import com.stevesoltys.seedvault.crypto.Crypto
import com.stevesoltys.seedvault.header.UnsupportedVersionException import com.stevesoltys.seedvault.header.UnsupportedVersionException
import com.stevesoltys.seedvault.metadata.BackupType import com.stevesoltys.seedvault.metadata.BackupType

View file

@ -8,16 +8,16 @@ package com.stevesoltys.seedvault.worker
import android.content.Context import android.content.Context
import android.content.pm.PackageInfo import android.content.pm.PackageInfo
import android.util.Log import android.util.Log
import com.stevesoltys.seedvault.backend.isOutOfSpace
import com.stevesoltys.seedvault.metadata.MetadataManager import com.stevesoltys.seedvault.metadata.MetadataManager
import com.stevesoltys.seedvault.metadata.PackageState.NOT_ALLOWED import com.stevesoltys.seedvault.metadata.PackageState.NOT_ALLOWED
import com.stevesoltys.seedvault.metadata.PackageState.WAS_STOPPED import com.stevesoltys.seedvault.metadata.PackageState.WAS_STOPPED
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.repo.SnapshotManager import com.stevesoltys.seedvault.repo.SnapshotManager
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.transport.backup.PackageService import com.stevesoltys.seedvault.transport.backup.PackageService
import com.stevesoltys.seedvault.transport.backup.isStopped import com.stevesoltys.seedvault.transport.backup.isStopped
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
import com.stevesoltys.seedvault.ui.notification.getAppName import com.stevesoltys.seedvault.ui.notification.getAppName
import org.calyxos.seedvault.core.backends.isOutOfSpace
import java.io.IOException import java.io.IOException
internal class ApkBackupManager( internal class ApkBackupManager(

View file

@ -14,11 +14,13 @@ android_library {
"src/main/java/org/calyxos/seedvault/core/backends/BackendTest.kt", "src/main/java/org/calyxos/seedvault/core/backends/BackendTest.kt",
], ],
static_libs: [ static_libs: [
"seedvault-lib-tink-android",
"androidx.core_core-ktx", "androidx.core_core-ktx",
"androidx.documentfile_documentfile", "androidx.documentfile_documentfile",
"kotlinx-coroutines-android", "kotlinx-coroutines-android",
"kotlinx-coroutines-core", "kotlinx-coroutines-core",
// Crypto
"seedvault-lib-tink-android",
// Logging
"seedvault-lib-kotlin-logging-jvm", "seedvault-lib-kotlin-logging-jvm",
"seedvault-lib-slf4j-api", "seedvault-lib-slf4j-api",
// WebDAV // WebDAV
@ -34,9 +36,3 @@ android_library {
"-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.RequiresOptIn",
], ],
} }
java_import {
name: "seedvault-lib-tink-android",
jars: ["libs/tink-android-1.15.0.jar"],
sdk_version: "current",
}

View file

@ -42,7 +42,7 @@ dependencies {
implementation(libs.androidx.documentfile) implementation(libs.androidx.documentfile)
implementation(libs.androidx.core.ktx) implementation(libs.androidx.core.ktx)
implementation(libs.google.tink.android) implementation(libs.google.tink.android)
implementation(fileTree("${rootProject.rootDir}/libs/dav4jvm").include("*.jar")) implementation(fileTree("$projectDir/libs/dav4jvm").include("*.jar"))
implementation(libs.squareup.okio) implementation(libs.squareup.okio)
implementation(libs.kotlin.logging) implementation(libs.kotlin.logging)
implementation(libs.slf4j.api) implementation(libs.slf4j.api)

22
core/libs/Android.bp Normal file
View file

@ -0,0 +1,22 @@
//
// SPDX-FileCopyrightText: 2024 The Calyx Institute
// SPDX-License-Identifier: Apache-2.0
//
java_import {
name: "seedvault-lib-tink-android",
jars: ["tink-android-1.15.0.jar"],
sdk_version: "current",
}
java_import {
name: "seedvault-lib-kotlin-logging-jvm",
jars: ["kotlin-logging-jvm-6.0.3.jar"],
sdk_version: "current",
}
java_import {
name: "seedvault-lib-slf4j-api",
jars: ["slf4j-api-2.0.16.jar"],
sdk_version: "current",
}

View file

@ -51,4 +51,18 @@ public interface Backend {
* @return null if no package name could be found * @return null if no package name could be found
*/ */
public val providerPackageName: String? public val providerPackageName: String?
public suspend fun getAvailableBackupFileHandles(): List<FileHandle> {
// v1 get all restore set tokens in root folder that have a metadata file
// v2 get all snapshots in all repository folders
return ArrayList<FileHandle>().apply {
list(
null,
AppBackupFileType.Snapshot::class,
LegacyAppBackupFile.Metadata::class,
) { fileInfo ->
add(fileInfo.fileHandle)
}
}
}
} }

View file

@ -33,15 +33,3 @@ java_import {
jars: ["seedvault-chunker-0.1.jar"], jars: ["seedvault-chunker-0.1.jar"],
sdk_version: "current", sdk_version: "current",
} }
java_import {
name: "seedvault-lib-kotlin-logging-jvm",
jars: ["kotlin-logging-jvm-6.0.3.jar"],
sdk_version: "current",
}
java_import {
name: "seedvault-lib-slf4j-api",
jars: ["slf4j-api-2.0.16.jar"],
sdk_version: "current",
}