diff --git a/Android.bp b/Android.bp index d40d6ffa..7c7a9a95 100644 --- a/Android.bp +++ b/Android.bp @@ -31,7 +31,7 @@ android_app { "androidx.lifecycle_lifecycle-livedata-ktx", "androidx-constraintlayout_constraintlayout", "com.google.android.material_material", - "seedvault-lib-koin-core", + "seedvault-lib-koin-core", // did not manage to add this as transitive dependency "seedvault-lib-koin-android", "seedvault-lib-koin-androidx-viewmodel", "seedvault-lib-novacrypto-bip39", diff --git a/app/build.gradle b/app/build.gradle index f8894bd0..4f0f0f4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -113,14 +113,17 @@ def aospDeps = fileTree(include: [ 'libcore.jar' ], dir: 'libs') -// We try to keep the dependencies in sync with what AOSP ships as Seedvault is meant to be built -// with the AOSP build system and gradle builds are just for more pleasant development. -// If the dependencies below are updated please make sure to update the -// prebuilt libraries and Android.bp in the top `libs` folder to reflect that. -// You can copy these libraries from ~/.gradle/caches/modules-2 dependencies { compileOnly aospDeps + /** + * Dependencies in AOSP + * + * We try to keep the dependencies in sync with what AOSP ships as Seedvault is meant to be built + * with the AOSP build system and gradle builds are just for more pleasant development. + * Using the AOSP versions in gradle builds allows us to spot issues early on. + */ + //noinspection GradleDependency implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" @@ -153,18 +156,36 @@ dependencies { //noinspection GradleDependency implementation 'com.google.android.material:material:1.1.0-alpha05' - implementation 'io.github.novacrypto:BIP39:2019.01.27' - implementation 'org.koin:koin-androidx-viewmodel:2.0.1' - // - // Dependencies below do not concern the AOSP build - // + /** + * External Dependencies + * + * If the dependencies below are updated, + * please make sure to update the prebuilt libraries and the Android.bp files + * in the top-level `libs` folder to reflect that. + * You can copy these libraries from ~/.gradle/caches/modules-2 + */ + + def koin_version = '2.1.1' + implementation("org.koin:koin-android:$koin_version") { + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' + } + implementation("org.koin:koin-androidx-viewmodel:$koin_version") { + exclude group: 'org.koin', module: 'koin-androidx-scope' + exclude group: 'androidx.lifecycle' + } + + implementation 'io.github.novacrypto:BIP39:2019.01.27' + + /** + * Test Dependencies (do not concern the AOSP build) + */ lintChecks 'com.github.thirdegg:lint-rules:0.0.5-alpha' def junit_version = "5.5.2" // careful, upgrading this can change a Cipher's IV size in tests!? def mockk_version = "1.10.0" - testImplementation aospDeps // anything less fails tests run with gradlew + testImplementation aospDeps // anything less than 'implementation' fails tests run with gradlew testImplementation 'androidx.test.ext:junit:1.1.2' testImplementation('org.robolectric:robolectric:4.3.1') { // 4.4 has issue with non-idle Looper // https://github.com/robolectric/robolectric/issues/5245 diff --git a/app/src/main/java/com/stevesoltys/seedvault/UsbIntentReceiver.kt b/app/src/main/java/com/stevesoltys/seedvault/UsbIntentReceiver.kt index 5cd5e940..2350bc1e 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/UsbIntentReceiver.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/UsbIntentReceiver.kt @@ -18,7 +18,7 @@ import com.stevesoltys.seedvault.settings.FlashDrive import com.stevesoltys.seedvault.settings.SettingsManager import com.stevesoltys.seedvault.transport.requestBackup import com.stevesoltys.seedvault.ui.storage.AUTHORITY_STORAGE -import org.koin.core.context.GlobalContext.get +import org.koin.core.context.KoinContextHandler.get import java.util.concurrent.TimeUnit.HOURS private val TAG = UsbIntentReceiver::class.java.simpleName @@ -26,8 +26,8 @@ private val TAG = UsbIntentReceiver::class.java.simpleName class UsbIntentReceiver : UsbMonitor() { // using KoinComponent would crash robolectric tests :( - private val settingsManager: SettingsManager by lazy { get().koin.get() } - private val metadataManager: MetadataManager by lazy { get().koin.get() } + private val settingsManager: SettingsManager by lazy { get().get() } + private val metadataManager: MetadataManager by lazy { get().get() } override fun shouldMonitorStatus(context: Context, action: String, device: UsbDevice): Boolean { if (action != ACTION_USB_DEVICE_ATTACHED) return false diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreErrorBroadcastReceiver.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreErrorBroadcastReceiver.kt index 94beee12..1b5343fb 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreErrorBroadcastReceiver.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreErrorBroadcastReceiver.kt @@ -6,7 +6,7 @@ import android.content.Intent import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import androidx.core.net.toUri import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager -import org.koin.core.context.GlobalContext.get +import org.koin.core.context.KoinContextHandler.get internal const val ACTION_RESTORE_ERROR_UNINSTALL = "com.stevesoltys.seedvault.action.UNINSTALL" internal const val EXTRA_PACKAGE_NAME = "com.stevesoltys.seedvault.extra.PACKAGE_NAME" @@ -15,7 +15,7 @@ internal const val REQUEST_CODE_UNINSTALL = 4576841 class RestoreErrorBroadcastReceiver : BroadcastReceiver() { // using KoinComponent would crash robolectric tests :( - private val notificationManager: BackupNotificationManager by lazy { get().koin.get() } + private val notificationManager: BackupNotificationManager by lazy { get().get() } override fun onReceive(context: Context, intent: Intent) { if (intent.action != ACTION_RESTORE_ERROR_UNINSTALL) return diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/ConfigurableBackupTransportService.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/ConfigurableBackupTransportService.kt index 4812210c..9381179b 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/ConfigurableBackupTransportService.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/ConfigurableBackupTransportService.kt @@ -17,7 +17,7 @@ import com.stevesoltys.seedvault.transport.backup.PackageService import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.notification.NotificationBackupObserver import org.koin.core.KoinComponent -import org.koin.core.context.GlobalContext.get +import org.koin.core.context.KoinContextHandler.get import org.koin.core.inject private val TAG = ConfigurableBackupTransportService::class.java.simpleName @@ -56,17 +56,17 @@ class ConfigurableBackupTransportService : Service(), KoinComponent { @WorkerThread fun requestBackup(context: Context) { - val packageService: PackageService = get().koin.get() + val packageService: PackageService = get().get() val packages = packageService.eligiblePackages val appTotals = packageService.expectedAppTotals val observer = NotificationBackupObserver(context, packages.size, appTotals) val result = try { - val backupManager: IBackupManager = get().koin.get() + val backupManager: IBackupManager = get().get() backupManager.requestBackup(packages, observer, BackupMonitor(), 0) } catch (e: RemoteException) { Log.e(TAG, "Error during backup: ", e) - val nm: BackupNotificationManager = get().koin.get() + val nm: BackupNotificationManager = get().get() nm.onBackupError() } if (result == BackupManager.SUCCESS) { diff --git a/libs/koin-android-2.0.1.aar b/libs/koin-android-2.0.1.aar deleted file mode 100644 index cbfb51b7..00000000 Binary files a/libs/koin-android-2.0.1.aar and /dev/null differ diff --git a/libs/Android.bp b/libs/koin-android/Android.bp similarity index 65% rename from libs/Android.bp rename to libs/koin-android/Android.bp index d9117048..a57460ef 100644 --- a/libs/Android.bp +++ b/libs/koin-android/Android.bp @@ -1,18 +1,17 @@ -java_import { - name: "seedvault-lib-koin-core", - host_supported: true, - jars: ["koin-core-2.0.1.jar"], +android_library_import { + name: "seedvault-lib-koin-androidx-viewmodel", + aars: ["koin-androidx-viewmodel-2.1.1.aar"], sdk_version: "current", } android_library_import { name: "seedvault-lib-koin-android", - aars: ["koin-android-2.0.1.aar"], + aars: ["koin-android-2.1.1.aar"], sdk_version: "current", } -android_library_import { - name: "seedvault-lib-koin-androidx-viewmodel", - aars: ["koin-androidx-viewmodel-2.0.1.aar"], +java_import { + name: "seedvault-lib-koin-core", + jars: ["koin-core-2.1.1.jar"], sdk_version: "current", } diff --git a/libs/koin-android/koin-android-2.1.1.aar b/libs/koin-android/koin-android-2.1.1.aar new file mode 100644 index 00000000..9d27100d Binary files /dev/null and b/libs/koin-android/koin-android-2.1.1.aar differ diff --git a/libs/koin-android/koin-androidx-viewmodel-2.1.1.aar b/libs/koin-android/koin-androidx-viewmodel-2.1.1.aar new file mode 100644 index 00000000..fcd68769 Binary files /dev/null and b/libs/koin-android/koin-androidx-viewmodel-2.1.1.aar differ diff --git a/libs/koin-android/koin-core-2.1.1.jar b/libs/koin-android/koin-core-2.1.1.jar new file mode 100644 index 00000000..1e7ee569 Binary files /dev/null and b/libs/koin-android/koin-core-2.1.1.jar differ diff --git a/libs/koin-androidx-viewmodel-2.0.1.aar b/libs/koin-androidx-viewmodel-2.0.1.aar deleted file mode 100644 index cf995574..00000000 Binary files a/libs/koin-androidx-viewmodel-2.0.1.aar and /dev/null differ diff --git a/libs/koin-core-2.0.1.jar b/libs/koin-core-2.0.1.jar deleted file mode 100644 index ff60a617..00000000 Binary files a/libs/koin-core-2.0.1.jar and /dev/null differ