diff --git a/app/build.gradle b/app/build.gradle index 10d89221e..1723a7628 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -393,6 +393,9 @@ dependencies { implementation Deps.mozilla_support_rustlog implementation Deps.mozilla_support_utils + // We only care about support-migration in builds that will be overwriting Fennec. + fennecProductionImplementation Deps.mozilla_support_migration + implementation Deps.mozilla_ui_colors implementation Deps.mozilla_ui_icons implementation Deps.mozilla_ui_publicsuffixlist diff --git a/app/src/fennecProduction/AndroidManifest.xml b/app/src/fennecProduction/AndroidManifest.xml index ad6a74698..12ced483c 100644 --- a/app/src/fennecProduction/AndroidManifest.xml +++ b/app/src/fennecProduction/AndroidManifest.xml @@ -7,6 +7,11 @@ - https://issuetracker.google.com/issues/36905922 --> + xmlns:tools="http://schemas.android.com/tools" + android:sharedUserId="${sharedUserId}"> + + diff --git a/app/src/fennecProduction/java/org/mozilla/fenix/MigratingFenixApplication.kt b/app/src/fennecProduction/java/org/mozilla/fenix/MigratingFenixApplication.kt new file mode 100644 index 000000000..e2b3ddeb3 --- /dev/null +++ b/app/src/fennecProduction/java/org/mozilla/fenix/MigratingFenixApplication.kt @@ -0,0 +1,34 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix + +import mozilla.components.support.ktx.android.content.isMainProcess +import mozilla.components.support.migration.FennecMigrator + +/** + * An application class which knows how to migrate Fennec data. + */ +class MigratingFenixApplication : FenixApplication() { + override fun setupApplication() { + super.setupApplication() + + // Same check as is present in super.setupApplication: + if (!isMainProcess()) { + // If this is not the main process then do not continue with the migration here. + // Migration only needs to be done in our app's main process and should not be done in other processes like + // a GeckoView child process or the crash handling process. Most importantly we never want to end up in a + // situation where we create a GeckoRuntime from the Gecko child process. + return + } + + val migrator = FennecMigrator.Builder(this) + .migrateOpenTabs(this.components.core.sessionManager) + .migrateHistory(this.components.core.historyStorage) + .migrateBookmarks(this.components.core.bookmarksStorage) + .build() + + migrator.migrateAsync() + } +} diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 9f278abe9..216a32e6f 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -42,7 +42,7 @@ object Versions { // that we depend on directly for the fenix-megazord (and for it's // forUnitTest variant), and it's important that it be kept in // sync with the version used by android-components above. - const val mozilla_appservices = "0.41.0" + const val mozilla_appservices = "0.42.0" const val autodispose = "1.1.0" const val adjust = "4.11.4" @@ -153,6 +153,7 @@ object Deps { const val mozilla_support_rustlog = "org.mozilla.components:support-rustlog:${Versions.mozilla_android_components}" const val mozilla_support_utils = "org.mozilla.components:support-utils:${Versions.mozilla_android_components}" const val mozilla_support_test = "org.mozilla.components:support-test:${Versions.mozilla_android_components}" + const val mozilla_support_migration = "org.mozilla.components:support-migration:${Versions.mozilla_android_components}" const val sentry = "io.sentry:sentry-android:${Versions.sentry}" const val leakcanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakcanary}"