diff --git a/Android.bp b/Android.bp index ba382399..951547cd 100644 --- a/Android.bp +++ b/Android.bp @@ -32,6 +32,8 @@ android_app { "androidx.lifecycle_lifecycle-livedata-ktx", "androidx-constraintlayout_constraintlayout", "com.google.android.material_material", + "kotlinx-coroutines-android", + "kotlinx-coroutines-core", // storage backup lib "seedvault-lib-storage", // koin diff --git a/app/build.gradle b/app/build.gradle index d4134c83..d976a9fd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,12 +38,12 @@ android { abortOnError true } compileOptions { - targetCompatibility 1.8 - sourceCompatibility 1.8 + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() - languageVersion = "1.4" + jvmTarget = JavaVersion.VERSION_11.toString() + languageVersion = "1.6" } testOptions { unitTests.all { @@ -138,10 +138,11 @@ dependencies { // anything less than 'implementation' fails tests run with gradlew testImplementation rootProject.ext.aosp_libs testImplementation 'androidx.test.ext:junit:1.1.3' - testImplementation('org.robolectric:robolectric:4.3.1') { // 4.4 has issue with non-idle Looper + testImplementation('org.robolectric:robolectric:4.8.1') { // https://github.com/robolectric/robolectric/issues/5245 exclude group: "com.google.auto.service", module: "auto-service" } + testImplementation 'org.hamcrest:hamcrest:2.2' testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5_version" testImplementation "org.junit.jupiter:junit-jupiter-params:$junit5_version" testImplementation "io.mockk:mockk:$mockk_version" @@ -159,9 +160,6 @@ apply from: "${rootProject.rootDir}/gradle/ktlint.gradle" gradle.projectsEvaluated { tasks.withType(JavaCompile) { - if (JavaVersion.current() >= JavaVersion.VERSION_1_9) { - options.compilerArgs.addAll(['--release', '8']) - } options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar') } } diff --git a/app/libs/android.jar b/app/libs/android.jar index 48002e33..5e9d53d4 100644 Binary files a/app/libs/android.jar and b/app/libs/android.jar differ diff --git a/app/libs/libcore.jar b/app/libs/libcore.jar index 94d798d2..2c0049b7 100644 Binary files a/app/libs/libcore.jar and b/app/libs/libcore.jar differ diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt index cae5c319..29cb923c 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt @@ -106,7 +106,7 @@ internal class AppListRetriever( time = time, status = status ) - }.sortedBy { it.name.toLowerCase(locale) } + }.sortedBy { it.name.lowercase(locale) } } private fun getNotAllowedApps(): List { @@ -120,7 +120,7 @@ internal class AppListRetriever( time = 0, status = FAILED_NOT_ALLOWED ) - }.sortedBy { it.name.toLowerCase(locale) } + }.sortedBy { it.name.lowercase(locale) } } private fun getIcon(packageName: String): Drawable = when (packageName) { diff --git a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt index 97012e3d..f8805c78 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt @@ -133,14 +133,8 @@ internal class ApkBackupRestoreTest : TransportTest() { every { strictContext.cacheDir } returns tmpFile every { crypto.getNameForApk(salt, packageName, "") } returns name coEvery { storagePlugin.getInputStream(token, name) } returns inputStream - every { pm.getPackageArchiveInfo(capture(apkPath), any()) } returns packageInfo - every { - @Suppress("UNRESOLVED_REFERENCE") - pm.loadItemIcon( - packageInfo.applicationInfo, - packageInfo.applicationInfo - ) - } returns icon + every { pm.getPackageArchiveInfo(capture(apkPath), any()) } returns packageInfo + every { applicationInfo.loadIcon(pm) } returns icon every { pm.getApplicationLabel(packageInfo.applicationInfo) } returns appName every { splitCompatChecker.isCompatible(metadata.deviceName, listOf(splitName)) diff --git a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt index ad730402..6eb1e969 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt @@ -1,7 +1,6 @@ package com.stevesoltys.seedvault.restore.install import android.content.Context -import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo.FLAG_INSTALLED import android.content.pm.ApplicationInfo.FLAG_SYSTEM import android.content.pm.ApplicationInfo.FLAG_UPDATED_SYSTEM_APP @@ -112,7 +111,7 @@ internal class ApkRestoreTest : TransportTest() { every { strictContext.cacheDir } returns File(tmpDir.toString()) every { crypto.getNameForApk(salt, packageName, "") } returns name coEvery { storagePlugin.getInputStream(token, name) } returns apkInputStream - every { pm.getPackageArchiveInfo(any(), any()) } returns packageInfo + every { pm.getPackageArchiveInfo(any(), any()) } returns packageInfo every { storagePlugin.providerPackageName } returns storageProviderPackageName apkRestore.restore(backup).collectIndexed { i, value -> @@ -176,14 +175,8 @@ internal class ApkRestoreTest : TransportTest() { coEvery { legacyStoragePlugin.getApkInputStream(token, packageName, "") } returns apkInputStream - every { pm.getPackageArchiveInfo(any(), any()) } returns packageInfo - every { - @Suppress("UNRESOLVED_REFERENCE") - pm.loadItemIcon( - packageInfo.applicationInfo, - packageInfo.applicationInfo - ) - } returns icon + every { pm.getPackageArchiveInfo(any(), any()) } returns packageInfo + every { applicationInfo.loadIcon(pm) } returns icon every { pm.getApplicationLabel(packageInfo.applicationInfo) } returns appName coEvery { apkInstaller.install(match { it.size == 1 }, packageName, installerName, any()) @@ -200,13 +193,11 @@ internal class ApkRestoreTest : TransportTest() { runBlocking { val packageMetadata = this@ApkRestoreTest.packageMetadata.copy(system = true) packageMetadataMap[packageName] = packageMetadata - packageInfo.applicationInfo = mockk() val installedPackageInfo: PackageInfo = mockk() val willFail = Random.nextBoolean() val isSystemApp = Random.nextBoolean() cacheBaseApkAndGetInfo(tmpDir) - every { packageInfo.applicationInfo.loadIcon(pm) } returns icon every { storagePlugin.providerPackageName } returns storageProviderPackageName if (willFail) { @@ -214,7 +205,7 @@ internal class ApkRestoreTest : TransportTest() { pm.getPackageInfo(packageName, 0) } throws PackageManager.NameNotFoundException() } else { - installedPackageInfo.applicationInfo = ApplicationInfo().apply { + installedPackageInfo.applicationInfo = mockk { flags = if (!isSystemApp) FLAG_INSTALLED else FLAG_SYSTEM or FLAG_UPDATED_SYSTEM_APP } @@ -421,14 +412,8 @@ internal class ApkRestoreTest : TransportTest() { every { strictContext.cacheDir } returns File(tmpDir.toString()) every { crypto.getNameForApk(salt, packageName, "") } returns name coEvery { storagePlugin.getInputStream(token, name) } returns apkInputStream - every { pm.getPackageArchiveInfo(any(), any()) } returns packageInfo - every { - @Suppress("UNRESOLVED_REFERENCE") - pm.loadItemIcon( - packageInfo.applicationInfo, - packageInfo.applicationInfo - ) - } returns icon + every { pm.getPackageArchiveInfo(any(), any()) } returns packageInfo + every { applicationInfo.loadIcon(pm) } returns icon every { pm.getApplicationLabel(packageInfo.applicationInfo) } returns appName } diff --git a/app/src/test/java/com/stevesoltys/seedvault/transport/TransportTest.kt b/app/src/test/java/com/stevesoltys/seedvault/transport/TransportTest.kt index 2f4e0cd2..35e81b28 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/transport/TransportTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/transport/TransportTest.kt @@ -37,12 +37,13 @@ internal abstract class TransportTest { protected val sigInfo: SigningInfo = mockk() protected val token = Random.nextLong() + protected val applicationInfo = mockk { + flags = FLAG_ALLOW_BACKUP or FLAG_INSTALLED + } protected val packageInfo = PackageInfo().apply { packageName = "org.example" longVersionCode = Random.nextLong() - applicationInfo = ApplicationInfo().apply { - flags = FLAG_ALLOW_BACKUP or FLAG_INSTALLED - } + applicationInfo = this@TransportTest.applicationInfo signingInfo = sigInfo } protected val pmPackageInfo = PackageInfo().apply { diff --git a/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt b/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt index 9a58f3fb..d5facae7 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt @@ -5,7 +5,6 @@ import android.app.backup.BackupTransport.TRANSPORT_NOT_INITIALIZED import android.app.backup.BackupTransport.TRANSPORT_OK import android.app.backup.BackupTransport.TRANSPORT_PACKAGE_REJECTED import android.app.backup.BackupTransport.TRANSPORT_QUOTA_EXCEEDED -import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo.FLAG_STOPPED import android.content.pm.PackageInfo import android.net.Uri @@ -399,7 +398,9 @@ internal class BackupCoordinatorTest : BackupTest() { PackageInfo().apply { packageName = "org.example.2" // the second package does not get backed up, because it is stopped - applicationInfo = ApplicationInfo().apply { flags = FLAG_STOPPED } + applicationInfo = mockk { + flags = FLAG_STOPPED + } } ) val packageMetadata: PackageMetadata = mockk() diff --git a/build.gradle b/build.gradle index bb25f307..f35c1cc2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ buildscript { - // 1.3.21 Android 10 // 1.3.61 Android 11 // 1.4.30 Android 12 + // 1.6.10 Android 13 // Check: - // https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-12.0.0_r2/build.txt - ext.aosp_kotlin_version = '1.4.31' // 1.4.30 breaks Kotlin plugin in Android Studio - ext.kotlin_version = '1.4.31' + // https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-13.0.0_r3/build.txt + ext.aosp_kotlin_version = '1.6.10' // 1.6.10-release-923 in AOSP + ext.kotlin_version = '1.6.10' repositories { mavenCentral() @@ -15,15 +15,15 @@ buildscript { //noinspection DifferentKotlinGradleVersion classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.17" - classpath 'com.android.tools.build:gradle:7.0.2' + classpath 'com.android.tools.build:gradle:7.2.2' } } ext { - buildToolsVersion = '31.0.0' - compileSdkVersion = 31 + buildToolsVersion = '33.0.0' + compileSdkVersion = 33 minSdkVersion = 29 - targetSdkVersion = 31 + targetSdkVersion = 33 } apply from: 'gradle/dependencies.gradle' diff --git a/contactsbackup/build.gradle b/contactsbackup/build.gradle index c7999696..71121216 100644 --- a/contactsbackup/build.gradle +++ b/contactsbackup/build.gradle @@ -15,12 +15,12 @@ android { } compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = JavaVersion.VERSION_11.toString() } testOptions { diff --git a/contactsbackup/libs/com.android.vcard.jar b/contactsbackup/libs/com.android.vcard.jar index f677ef61..8060d849 100644 Binary files a/contactsbackup/libs/com.android.vcard.jar and b/contactsbackup/libs/com.android.vcard.jar differ diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 607af4e0..9a0ecb1b 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -1,7 +1,7 @@ ext { - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#2943 - ext.room_version = "2.3.0-beta02" - // https://android.googlesource.com/platform/external/protobuf/+/refs/tags/android-12.0.0_r2/java/pom.xml#7 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#3901 + ext.room_version = "2.4.0-alpha05" + // https://android.googlesource.com/platform/external/protobuf/+/refs/tags/android-13.0.0_r3/java/pom.xml#7 ext.protobuf_version = "3.9.1" junit4_version = "4.13.2" junit5_version = "5.5.2" // careful, upgrading this can change a Cipher's IV size in tests!? @@ -37,58 +37,58 @@ ext.kotlin_libs = [ ], coroutines: [ dependencies.create('org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm') { - // https://android.googlesource.com/platform/prebuilts/tools/+/refs/tags/android-12.0.0_r2/common/m2/Android.bp#273 - version { strictly '1.4.2' } + // https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-13.0.0_r3/CHANGES.md + version { strictly '1.5.2' } }, dependencies.create('org.jetbrains.kotlinx:kotlinx-coroutines-android') { - // https://android.googlesource.com/platform/prebuilts/tools/+/refs/tags/android-12.0.0_r2/common/m2/Android.bp#288 - version { strictly '1.3.0' } + // https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-13.0.0_r3/CHANGES.md + version { strictly '1.5.2' } }, ], ] ext.std_libs = [ androidx_core: [ - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#867 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#1761 dependencies.create('androidx.core:core') { - version { strictly '1.6.0' } // should be 1.6.0-beta03, but that is not even released, yet + version { strictly '1.9.0-alpha03' } }, - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#833 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#1727 dependencies.create('androidx.core:core-ktx') { - version { strictly '1.5.0-beta02' } + version { strictly '1.9.0-alpha03' } }, ], - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#1189 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#2159 androidx_fragment: dependencies.create('androidx.fragment:fragment-ktx') { - version { strictly '1.4.0-alpha01' } + version { strictly '1.4.0-alpha09' } }, - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#20 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#57 androidx_activity: dependencies.create('androidx.activity:activity-ktx') { - version { strictly '1.3.0-alpha03' } + version { strictly '1.4.0-alpha02' } }, - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#2695 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#3597 androidx_preference: dependencies.create('androidx.preference:preference') { - version { strictly '1.1.1' } // should be 1.2.0-alpha01, but that is not even released, yet + version { strictly '1.2.0-alpha01' } }, - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#1820 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#2754 androidx_lifecycle_viewmodel_ktx: dependencies.create('androidx.lifecycle:lifecycle-viewmodel-ktx') { - version { strictly '2.4.0-alpha01' } + version { strictly '2.4.0-alpha03' } // 2.4.0-alpha04 in AOSP but was never released }, - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#1618 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#2550 androidx_lifecycle_livedata_ktx: dependencies.create('androidx.lifecycle:lifecycle-livedata-ktx') { - version { strictly '2.4.0-alpha01' } + version { strictly '2.4.0-alpha03' } // 2.4.0-alpha04 in AOSP but was never released }, - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/extras/constraint-layout-x/Android.bp#39 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/extras/constraint-layout-x/Android.bp#39 androidx_constraintlayout: dependencies.create('androidx.constraintlayout:constraintlayout') { version { strictly '2.0.0-beta7' } }, - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/androidx/Android.bp#969 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#1865 androidx_documentfile: dependencies.create('androidx.documentfile:documentfile') { - version { strictly '1.1.0-alpha01' } + version { strictly '1.1.0-alpha01' } // 1.1.0-alpha02 in AOSP but not released yet }, - // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-12.0.0_r2/current/extras/material-design-x/Android.bp#6 + // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/extras/material-design-x/Android.bp#6 com_google_android_material: dependencies.create('com.google.android.material:material') { - version { strictly '1.4.0' } + version { strictly '1.6.0-alpha03' } // 1.6.0-alpha0301 in AOSP }, ] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 20d1c07e..6b46f328 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ -#Tue Aug 04 14:40:48 BRT 2020 +#Fri Aug 19 10:56:09 IST 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip -distributionSha256Sum=a8da5b02437a60819cad23e10fc7e9cf32bcb57029d9cb277e26eeff76ce014b +zipStoreBase=GRADLE_USER_HOME +distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302 diff --git a/storage/demo/build.gradle b/storage/demo/build.gradle index 6950ebc8..c99f2060 100644 --- a/storage/demo/build.gradle +++ b/storage/demo/build.gradle @@ -27,11 +27,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = JavaVersion.VERSION_11.toString() freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } lintOptions { diff --git a/storage/lib/Android.bp b/storage/lib/Android.bp index 88113b1d..afb15df2 100644 --- a/storage/lib/Android.bp +++ b/storage/lib/Android.bp @@ -22,6 +22,8 @@ android_library { "androidx.room_room-runtime", "androidx-constraintlayout_constraintlayout", "com.google.android.material_material", + "kotlinx-coroutines-android", + "kotlinx-coroutines-core", ], plugins: [ "androidx.room_room-compiler-plugin", diff --git a/storage/lib/build.gradle b/storage/lib/build.gradle index e9544b3d..ae711395 100644 --- a/storage/lib/build.gradle +++ b/storage/lib/build.gradle @@ -28,12 +28,12 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' - languageVersion = "1.4" + jvmTarget = JavaVersion.VERSION_11.toString() + languageVersion = "1.6" freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn' freeCompilerArgs += '-Xexplicit-api=strict' } diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/backup/Backup.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/backup/Backup.kt index 48c74c2e..14dd470f 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/backup/Backup.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/backup/Backup.kt @@ -111,11 +111,12 @@ internal class Backup( } Log.e(TAG, "Changed files backup took $duration") } finally { - backupObserver?.onBackupComplete(duration?.toLongMilliseconds()) + backupObserver?.onBackupComplete(duration?.inWholeMilliseconds) } } @Throws(IOException::class, GeneralSecurityException::class) + @OptIn(ExperimentalTime::class) private suspend fun backupFiles( filesResult: FileScannerResult, availableChunkIds: HashSet, diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/backup/ChunksCacheRepopulater.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/backup/ChunksCacheRepopulater.kt index 764e994f..0b38d48e 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/backup/ChunksCacheRepopulater.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/backup/ChunksCacheRepopulater.kt @@ -8,7 +8,7 @@ import org.calyxos.backup.storage.measure import org.calyxos.backup.storage.plugin.SnapshotRetriever import java.io.IOException import java.security.GeneralSecurityException -import java.util.concurrent.TimeUnit.MILLISECONDS +import kotlin.time.DurationUnit.MILLISECONDS import kotlin.time.ExperimentalTime import kotlin.time.toDuration diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/plugin/saf/SafStoragePlugin.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/plugin/saf/SafStoragePlugin.kt index 6c143315..090ad385 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/plugin/saf/SafStoragePlugin.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/plugin/saf/SafStoragePlugin.kt @@ -18,6 +18,7 @@ import org.calyxos.backup.storage.plugin.saf.DocumentFileExt.listFilesBlocking import java.io.IOException import java.io.InputStream import java.io.OutputStream +import kotlin.time.ExperimentalTime private val folderRegex = Regex("^[a-f0-9]{16}\\.sv$") private val chunkFolderRegex = Regex("[a-f0-9]{2}") @@ -89,6 +90,7 @@ public abstract class SafStoragePlugin( * Chunk folders will get cached in the given [chunkFolders] for faster access. */ @Throws(IOException::class) + @OptIn(ExperimentalTime::class) private suspend fun populateChunkFolders( folder: DocumentFile, chunkFolders: HashMap, @@ -126,6 +128,7 @@ public abstract class SafStoragePlugin( } @Throws(IOException::class) + @OptIn(ExperimentalTime::class) private fun createMissingChunkFolders( root: DocumentFile, chunkFolders: HashMap, diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/prune/Pruner.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/prune/Pruner.kt index 17350158..3e503e86 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/prune/Pruner.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/prune/Pruner.kt @@ -47,7 +47,7 @@ internal class Pruner( } } Log.i(TAG, "Pruning took $duration") - backupObserver?.onPruneComplete(duration.toLongMilliseconds()) + backupObserver?.onPruneComplete(duration.inWholeMilliseconds) } @Throws(IOException::class, GeneralSecurityException::class) diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt index 297c1d5c..b338ac6d 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt @@ -52,6 +52,7 @@ internal class Restore( MultiChunkRestore(context, storagePlugin, fileRestore, streamCrypto, streamKey) } + @OptIn(ExperimentalTime::class) fun getBackupSnapshots(): Flow = flow { val numSnapshots: Int val time = measure { @@ -138,7 +139,7 @@ internal class Restore( Log.e(TAG, "Restoring ${split.multiChunkFiles.size} multi chunks took $multiChunkDuration.") val totalDuration = smallFilesDuration + singleChunkDuration + multiChunkDuration - observer?.onRestoreComplete(totalDuration.toLongMilliseconds()) + observer?.onRestoreComplete(totalDuration.inWholeMilliseconds) Log.e(TAG, "Restored $restoredFiles/$filesTotal files.") } diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/scanner/FileScanner.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/scanner/FileScanner.kt index bbce61c4..02d9cbdb 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/scanner/FileScanner.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/scanner/FileScanner.kt @@ -11,6 +11,7 @@ import org.calyxos.backup.storage.content.DocFile import org.calyxos.backup.storage.content.MediaFile import org.calyxos.backup.storage.db.UriStore import org.calyxos.backup.storage.measure +import kotlin.time.ExperimentalTime internal class FileScannerResult( val smallFiles: List, @@ -30,6 +31,7 @@ internal class FileScanner( private const val FILES_LARGE = "large" } + @OptIn(ExperimentalTime::class) fun getFiles(): FileScannerResult { // scan both APIs val mediaFiles = ArrayList()