diff --git a/app/build.gradle b/app/build.gradle index 820f417b38..4ab1dff616 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -177,14 +177,6 @@ android { androidTest { resources.srcDirs += ['src/androidTest/resources'] } - beta { - java.srcDirs = ['src/migration/java'] - manifest.srcFile "src/migration/AndroidManifest.xml" - } - release { - java.srcDirs = ['src/migration/java'] - manifest.srcFile "src/migration/AndroidManifest.xml" - } } splits { @@ -530,7 +522,6 @@ dependencies { implementation Deps.mozilla_support_rustlog implementation Deps.mozilla_support_utils implementation Deps.mozilla_support_locale - implementation Deps.mozilla_support_migration implementation Deps.mozilla_ui_colors implementation Deps.mozilla_ui_icons diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index 7b0553a0c2..646548a2f0 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -1493,17 +1493,6 @@ column="1"/> - - - - diff --git a/app/sampledata/migration_items b/app/sampledata/migration_items deleted file mode 100644 index 0dd95cfbd4..0000000000 --- a/app/sampledata/migration_items +++ /dev/null @@ -1,5 +0,0 @@ -History -Bookmarks -Logins -Open Tabs -Settings \ No newline at end of file diff --git a/app/src/beta/AndroidManifest.xml b/app/src/beta/AndroidManifest.xml new file mode 100644 index 0000000000..82f7f6896d --- /dev/null +++ b/app/src/beta/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 31d601656f..45d11dfaa8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -233,13 +233,6 @@ - - - diff --git a/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt b/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt index 2facd3a828..d4273be48e 100644 --- a/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt @@ -100,8 +100,7 @@ class IntentReceiverActivity : Activity() { ) } - return listOf(components.intentProcessors.migrationIntentProcessor) + - components.intentProcessors.externalAppIntentProcessors + + return components.intentProcessors.externalAppIntentProcessors + components.intentProcessors.fennecPageShortcutIntentProcessor + components.intentProcessors.externalDeepLinkIntentProcessor + modeDependentProcessors + diff --git a/app/src/main/java/org/mozilla/fenix/components/Components.kt b/app/src/main/java/org/mozilla/fenix/components/Components.kt index c52c254270..3c2a6259a2 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Components.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Components.kt @@ -19,7 +19,6 @@ import mozilla.components.feature.addons.update.DefaultAddonUpdater import mozilla.components.feature.autofill.AutofillConfiguration import mozilla.components.lib.publicsuffixlist.PublicSuffixList import mozilla.components.support.base.worker.Frequency -import mozilla.components.support.migration.state.MigrationStore import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.Config import org.mozilla.fenix.HomeActivity @@ -99,7 +98,6 @@ class Components(private val context: Context) { useCases.searchUseCases, core.relationChecker, core.customTabsStore, - migrationStore, core.webAppManifestStorage ) } @@ -157,7 +155,6 @@ class Components(private val context: Context) { val analytics by lazyMonitored { Analytics(context) } val publicSuffixList by lazyMonitored { PublicSuffixList(context) } val clipboardHandler by lazyMonitored { ClipboardHandler(context) } - val migrationStore by lazyMonitored { MigrationStore() } val performance by lazyMonitored { PerformanceComponent() } val push by lazyMonitored { Push(context, analytics.crashReporter) } val wifiConnectionMonitor by lazyMonitored { WifiConnectionMonitor(context as Application) } diff --git a/app/src/main/java/org/mozilla/fenix/components/IntentProcessorType.kt b/app/src/main/java/org/mozilla/fenix/components/IntentProcessorType.kt index 4e37d7f4c9..1539c37559 100644 --- a/app/src/main/java/org/mozilla/fenix/components/IntentProcessorType.kt +++ b/app/src/main/java/org/mozilla/fenix/components/IntentProcessorType.kt @@ -8,10 +8,9 @@ import android.content.Intent import mozilla.components.feature.intent.processing.IntentProcessor import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity -import org.mozilla.fenix.migration.MigrationProgressActivity enum class IntentProcessorType { - EXTERNAL_APP, NEW_TAB, MIGRATION, EXTERNAL_DEEPLINK, OTHER; + EXTERNAL_APP, NEW_TAB, EXTERNAL_DEEPLINK, OTHER; /** * The destination activity based on this intent @@ -20,7 +19,6 @@ enum class IntentProcessorType { get() = when (this) { EXTERNAL_APP -> ExternalAppBrowserActivity::class.java.name NEW_TAB, EXTERNAL_DEEPLINK, OTHER -> HomeActivity::class.java.name - MIGRATION -> MigrationProgressActivity::class.java.name } /** @@ -29,7 +27,7 @@ enum class IntentProcessorType { fun shouldOpenToBrowser(intent: Intent): Boolean = when (this) { EXTERNAL_APP -> true NEW_TAB -> intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY == 0 - MIGRATION, EXTERNAL_DEEPLINK, OTHER -> false + EXTERNAL_DEEPLINK, OTHER -> false } } @@ -37,7 +35,6 @@ enum class IntentProcessorType { * Classifies the [IntentProcessorType] based on the [IntentProcessor] that handled the [Intent]. */ fun IntentProcessors.getType(processor: IntentProcessor?) = when { - migrationIntentProcessor == processor -> IntentProcessorType.MIGRATION externalAppIntentProcessors.contains(processor) || customTabIntentProcessor == processor || privateCustomTabIntentProcessor == processor -> IntentProcessorType.EXTERNAL_APP diff --git a/app/src/main/java/org/mozilla/fenix/components/IntentProcessors.kt b/app/src/main/java/org/mozilla/fenix/components/IntentProcessors.kt index 642ee2d420..8045035f67 100644 --- a/app/src/main/java/org/mozilla/fenix/components/IntentProcessors.kt +++ b/app/src/main/java/org/mozilla/fenix/components/IntentProcessors.kt @@ -17,8 +17,6 @@ import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.tabs.CustomTabsUseCases import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.service.digitalassetlinks.RelationChecker -import mozilla.components.support.migration.MigrationIntentProcessor -import mozilla.components.support.migration.state.MigrationStore import org.mozilla.fenix.customtabs.FennecWebAppIntentProcessor import org.mozilla.fenix.home.intent.FennecBookmarkShortcutsIntentProcessor import org.mozilla.fenix.intent.ExternalDeepLinkIntentProcessor @@ -37,7 +35,6 @@ class IntentProcessors( private val searchUseCases: SearchUseCases, private val relationChecker: RelationChecker, private val customTabsStore: CustomTabsServiceStore, - private val migrationStore: MigrationStore, private val manifestStorage: ManifestStorage ) { /** @@ -82,8 +79,4 @@ class IntentProcessors( val fennecPageShortcutIntentProcessor by lazyMonitored { FennecBookmarkShortcutsIntentProcessor(tabsUseCases.addTab) } - - val migrationIntentProcessor by lazyMonitored { - MigrationIntentProcessor(migrationStore) - } } diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index 6ffb70b39c..15e7bdfd0a 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -186,7 +186,6 @@ sealed class Event { } ) } - object FennecToFenixMigrated : Event() object AddonsOpenInSettings : Event() object StudiesSettings : Event() object VoiceSearchTapped : Event() diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index ba840dfdc6..5ea66cd6d3 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -981,7 +981,6 @@ private val Event.wrapper: EventWrapper<*>? is Event.InteractWithSearchURLArea -> null is Event.ClearedPrivateData -> null is Event.DismissedOnboarding -> null - is Event.FennecToFenixMigrated -> null is Event.AddonInstalled -> null is Event.SearchWidgetInstalled -> null is Event.SyncAuthFromSharedReuse, Event.SyncAuthFromSharedCopy -> null diff --git a/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt b/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt deleted file mode 100644 index 3b851d7cdb..0000000000 --- a/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* 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.migration - -import android.content.Intent -import android.os.Bundle -import android.view.View -import androidx.core.content.ContextCompat -import androidx.recyclerview.widget.LinearLayoutManager -import mozilla.components.support.base.log.logger.Logger -import mozilla.components.support.ktx.android.content.getColorFromAttr -import mozilla.components.support.migration.AbstractMigrationProgressActivity -import mozilla.components.support.migration.AbstractMigrationService -import mozilla.components.support.migration.MigrationResults -import mozilla.components.support.migration.state.MigrationAction -import mozilla.components.support.migration.state.MigrationProgress -import mozilla.components.support.migration.state.MigrationStore -import org.mozilla.fenix.HomeActivity -import org.mozilla.fenix.IntentReceiverActivity -import org.mozilla.fenix.R -import org.mozilla.fenix.databinding.ActivityMigrationBinding -import org.mozilla.fenix.ext.components - -class MigrationProgressActivity : AbstractMigrationProgressActivity() { - private val logger = Logger("MigrationProgressActivity") - private val statusAdapter = MigrationStatusAdapter() - override val store: MigrationStore by lazy { components.migrationStore } - - private lateinit var binding: ActivityMigrationBinding - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - binding = ActivityMigrationBinding.inflate(layoutInflater) - setContentView(binding.root) - - init() - } - - fun init() { - window.navigationBarColor = getColorFromAttr(R.attr.layer1) - - val appName = binding.migrationDescription.context.getString(R.string.app_name) - - binding.migrationDescription.apply { - text = context.getString(R.string.migration_description, appName) - } - - binding.migrationStatusList.apply { - val margin = resources.getDimensionPixelSize(R.dimen.migration_margin) - addItemDecoration(MigrationStatusItemDecoration(margin)) - layoutManager = LinearLayoutManager(this@MigrationProgressActivity) - adapter = statusAdapter - } - - binding.migrationWelcomeTitle.apply { - text = context.getString(R.string.migration_title, appName) - } - - binding.migrationButtonTextView.text = getString(R.string.migration_updating_app_button_text, appName) - } - - override fun onMigrationCompleted(results: MigrationResults) { - // Enable clicking the finish button - binding.migrationButton.apply { - setOnClickListener { - AbstractMigrationService.dismissNotification(context) - - finish() - overridePendingTransition(0, 0) - - store.dispatch(MigrationAction.Clear) - - // If we received a user-initiated intent, throw this back to the intent receiver. - if (intent.hasExtra(HomeActivity.OPEN_TO_BROWSER)) { - intent.setClassName(applicationContext, IntentReceiverActivity::class.java.name) - startActivity(intent) - } else { - // Fallback: Just launch the browser - logger.warn("Intent does not contain OPEN_TO_BROWSER extra, launching HomeActivity") - startActivity(Intent(this@MigrationProgressActivity, HomeActivity::class.java)) - } - } - } - binding.migrationButtonTextView.apply { - text = getString(R.string.migration_update_app_button, getString(R.string.app_name)) - setTextColor( - ContextCompat.getColor( - context, - R.color.fx_mobile_text_color_oncolor_primary - ) - ) - } - binding.migrationButton.setBackgroundResource(R.drawable.migration_button_background) - binding.migrationButtonProgressBar.visibility = View.INVISIBLE - // Keep the results list up-to-date. - statusAdapter.updateData(results) - } - - override fun onMigrationStateChanged(progress: MigrationProgress, results: MigrationResults) { - statusAdapter.updateData(results) - } -} diff --git a/app/src/main/java/org/mozilla/fenix/migration/MigrationStatusAdapter.kt b/app/src/main/java/org/mozilla/fenix/migration/MigrationStatusAdapter.kt deleted file mode 100644 index 0145fa1148..0000000000 --- a/app/src/main/java/org/mozilla/fenix/migration/MigrationStatusAdapter.kt +++ /dev/null @@ -1,109 +0,0 @@ -/* 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.migration - -import android.graphics.Rect -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.annotation.Px -import androidx.core.view.isInvisible -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter -import androidx.recyclerview.widget.RecyclerView -import mozilla.components.support.migration.Migration -import mozilla.components.support.migration.MigrationResults -import org.mozilla.fenix.R -import org.mozilla.fenix.databinding.MigrationListItemBinding - -internal data class MigrationItem( - val migration: Migration, - val status: Boolean = false -) - -// These are the only items we want to show migrating in the UI. -internal val whiteList = linkedMapOf( - Migration.Settings to R.string.settings_title, - Migration.History to R.string.preferences_sync_history, - Migration.Bookmarks to R.string.preferences_sync_bookmarks, - Migration.Logins to R.string.migration_text_passwords -) - -internal class MigrationStatusAdapter : - ListAdapter(DiffCallback) { - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.migration_list_item, parent, false) - - return ViewHolder(view) - } - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - holder.bind(getItem(position)) - } - - /** - * Filter the [results] to only include items in [whiteList] and update the adapter. - */ - fun updateData(results: MigrationResults) { - val itemList = whiteList.keys.map { - if (results.containsKey(it)) { - MigrationItem(it, results.getValue(it).success) - } else { - MigrationItem(it) - } - } - submitList(itemList) - } - - class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { - - private val context = view.context - private val binding = MigrationListItemBinding.bind(view) - private val title = binding.migrationItemName - private val status = binding.migrationStatusImage - - fun bind(item: MigrationItem) { - // Get the resource ID for the item. - val migrationText = whiteList[item.migration]?.let { - context.getString(it) - }.orEmpty() - title.text = migrationText - status.isInvisible = !item.status - status.contentDescription = context.getString(R.string.migration_icon_description) - } - } - - private object DiffCallback : DiffUtil.ItemCallback() { - - override fun areItemsTheSame(oldItem: MigrationItem, newItem: MigrationItem) = - oldItem.migration.javaClass.simpleName == newItem.migration.javaClass.simpleName - - override fun areContentsTheSame(oldItem: MigrationItem, newItem: MigrationItem) = - oldItem.migration.javaClass.simpleName == newItem.migration.javaClass.simpleName && - oldItem.status == newItem.status - } -} - -internal class MigrationStatusItemDecoration( - @Px private val spacing: Int -) : RecyclerView.ItemDecoration() { - - override fun getItemOffsets( - outRect: Rect, - view: View, - parent: RecyclerView, - state: RecyclerView.State - ) { - val position = parent.getChildViewHolder(view).bindingAdapterPosition - val itemCount = state.itemCount - - outRect.left = spacing - outRect.right = spacing - outRect.top = spacing - outRect.bottom = if (position == itemCount - 1) spacing else 0 - } -} diff --git a/app/src/main/java/org/mozilla/fenix/migration/MigrationTelemetryListener.kt b/app/src/main/java/org/mozilla/fenix/migration/MigrationTelemetryListener.kt deleted file mode 100644 index 3821091e21..0000000000 --- a/app/src/main/java/org/mozilla/fenix/migration/MigrationTelemetryListener.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* 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.migration - -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.collect -import mozilla.components.lib.state.ext.flowScoped -import mozilla.components.support.base.log.logger.Logger -import mozilla.components.support.migration.state.MigrationProgress -import mozilla.components.support.migration.state.MigrationStore -import org.mozilla.fenix.components.metrics.Event -import org.mozilla.fenix.components.metrics.MetricController - -class MigrationTelemetryListener( - private val metrics: MetricController, - private val store: MigrationStore, - private val logger: Logger = Logger("MigrationTelemetryListener") -) { - - @OptIn(ExperimentalCoroutinesApi::class) - fun start() { - // Observe for migration completed. - store.flowScoped { flow -> - flow.collect { state -> - logger.debug("Migration state: ${state.progress}") - if (state.progress == MigrationProgress.COMPLETED) { - metrics.track(Event.FennecToFenixMigrated) - } - } - } - } -} diff --git a/app/src/main/res/anim/placeholder_animation.xml b/app/src/main/res/anim/placeholder_animation.xml deleted file mode 100644 index 348af4210c..0000000000 --- a/app/src/main/res/anim/placeholder_animation.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/button_background_grey.xml b/app/src/main/res/drawable/button_background_grey.xml deleted file mode 100644 index ba19b8c9fd..0000000000 --- a/app/src/main/res/drawable/button_background_grey.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/drawable/migration_button_background.xml b/app/src/main/res/drawable/migration_button_background.xml deleted file mode 100644 index 99596c7102..0000000000 --- a/app/src/main/res/drawable/migration_button_background.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/layout/activity_migration.xml b/app/src/main/res/layout/activity_migration.xml deleted file mode 100644 index ef3a4abfdf..0000000000 --- a/app/src/main/res/layout/activity_migration.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/migration_list_item.xml b/app/src/main/res/layout/migration_list_item.xml deleted file mode 100644 index 5b17da21b8..0000000000 --- a/app/src/main/res/layout/migration_list_item.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index f60c44401c..0d251ff4bd 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -121,17 +121,6 @@ 12sp 48dp - - 20dp - 16dp - 48dp - 20sp - 14sp - 24dp - 8dp - 4dp - 44dp - 10dp 8dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f75ec348b6..dcf355f731 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1564,17 +1564,17 @@ Deleted %s - Welcome to an all-new %s + Welcome to an all-new %s - A completely redesigned browser awaits, with improved performance and features to help you do more online.\n\nPlease wait while we update %s with your + A completely redesigned browser awaits, with improved performance and features to help you do more online.\n\nPlease wait while we update %s with your - Updating %s… + Updating %s… - Start %s + Start %s - Migration completed + Migration completed - Passwords + Passwords To allow it: diff --git a/app/src/migration/AndroidManifest.xml b/app/src/migration/AndroidManifest.xml deleted file mode 100644 index a90db330d0..0000000000 --- a/app/src/migration/AndroidManifest.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/migration/java/org/mozilla/fenix/MigratingFenixApplication.kt b/app/src/migration/java/org/mozilla/fenix/MigratingFenixApplication.kt deleted file mode 100644 index 777bee33e1..0000000000 --- a/app/src/migration/java/org/mozilla/fenix/MigratingFenixApplication.kt +++ /dev/null @@ -1,93 +0,0 @@ -/* 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 android.content.Context -import mozilla.components.support.migration.FennecMigrator -import org.mozilla.fenix.session.PerformanceActivityLifecycleCallbacks -import org.mozilla.fenix.migration.MigrationTelemetryListener -import org.mozilla.fenix.perf.runBlockingIncrement - -/** - * An application class which knows how to migrate Fennec data. - */ -class MigratingFenixApplication : FenixApplication() { - init { - recordOnInit() // DO NOT MOVE ANYTHING ABOVE HERE: the timing of this measurement is critical. - - PerformanceActivityLifecycleCallbacks.isTransientActivityInMigrationVariant = { - if (it is MigrationDecisionActivity) true else false - } - } - - val fxaExpectChinaServers = Config.channel.isMozillaOnline - - val migrator by lazy { - FennecMigrator.Builder(this, this.components.analytics.crashReporter) - .migrateOpenTabs(this.components.useCases.tabsUseCases) - .migrateHistory(this.components.core.lazyHistoryStorage) - .migrateBookmarks( - this.components.core.lazyBookmarksStorage, - this.components.core.pinnedSiteStorage - ) - .migrateLogins(this.components.core.lazyPasswordsStorage) - .migrateFxa(lazy { this.components.backgroundServices.accountManager }, fxaExpectChinaServers) - .migrateAddons( - this.components.core.engine, - this.components.addonCollectionProvider, - this.components.addonUpdater - ) - .migrateTelemetryIdentifiers() - .build() - } - - val migrationPushSubscriber by lazy { - MigrationPushRenewer( - components.push.feature, - components.migrationStore - ) - } - - val migrationTelemetryListener by lazy { - MigrationTelemetryListener( - components.analytics.metrics, - components.migrationStore - ) - } - - override fun setupInMainProcessOnly() { - // These migrations need to run before regular initialization happens. - migrateBlocking() - - // Now that we have migrated from Fennec whether the user wants to enable telemetry we can - // initialize Glean - initializeGlean() - - // Fenix application initialization can happen now. - super.setupInMainProcessOnly() - - // The rest of the migrations can happen now. - migrationPushSubscriber.start() - migrationTelemetryListener.start() - migrator.startMigrationIfNeeded(components.migrationStore, MigrationService::class.java) - } - - private fun migrateBlocking() { - val migrator = FennecMigrator.Builder(this, this.components.analytics.crashReporter) - .migrateGecko() - // Telemetry may have been disabled in Fennec, so we need to migrate Settings first - // to correctly initialize telemetry. - .migrateSettings() - .build() - - runBlockingIncrement { - migrator.migrateAsync(components.migrationStore).await() - } - } -} - -fun Context.getMigratorFromApplication(): FennecMigrator { - return (applicationContext as MigratingFenixApplication).migrator -} diff --git a/app/src/migration/java/org/mozilla/fenix/MigrationDecisionActivity.kt b/app/src/migration/java/org/mozilla/fenix/MigrationDecisionActivity.kt deleted file mode 100644 index 807649d0d1..0000000000 --- a/app/src/migration/java/org/mozilla/fenix/MigrationDecisionActivity.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* 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 android.app.Activity -import android.content.Intent -import android.os.Bundle -import mozilla.components.support.migration.state.MigrationProgress -import org.mozilla.fenix.ext.components -import org.mozilla.fenix.migration.MigrationProgressActivity - -/** - * The purpose of this activity, when launched, is to decide whether we want to show the migration - * screen ([MigrationProgressActivity]) or launch the browser normally ([HomeActivity]). - */ -class MigrationDecisionActivity : Activity() { - private val store by lazy { components.migrationStore } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - val intent = if (intent != null) intent else Intent() - - val activity = when (store.state.progress) { - MigrationProgress.NONE, MigrationProgress.COMPLETED -> HomeActivity::class.java - MigrationProgress.MIGRATING -> MigrationProgressActivity::class.java - } - - intent.setClass(applicationContext, activity) - intent.putExtra(HomeActivity.OPEN_TO_BROWSER, false) - - startActivity(intent) - finish() - - // We are disabling animations here when switching activities because this results in a - // perceived faster launch. This activity will start immediately with a solid background - // and then we switch to the actual activity without an animation. This visually looks like - // a faster start than launching this activity invisibly and switching to the actual - // activity after that. - overridePendingTransition(0, R.anim.placeholder_animation) - } -} diff --git a/app/src/migration/java/org/mozilla/fenix/MigrationPushRenewer.kt b/app/src/migration/java/org/mozilla/fenix/MigrationPushRenewer.kt deleted file mode 100644 index 1d8e1650e2..0000000000 --- a/app/src/migration/java/org/mozilla/fenix/MigrationPushRenewer.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.collect -import mozilla.components.concept.push.PushProcessor -import mozilla.components.lib.state.ext.flowScoped -import mozilla.components.support.base.log.logger.Logger -import mozilla.components.support.migration.state.MigrationProgress -import mozilla.components.support.migration.state.MigrationStore - -/** - * Force-renews push subscription after migration was complete. - */ -class MigrationPushRenewer( - private val service: PushProcessor?, - private val store: MigrationStore -) { - - @OptIn(ExperimentalCoroutinesApi::class) - fun start() { - // Observe for migration completed. - store.flowScoped { flow -> - flow.collect { state -> - Logger("MigrationPushRenewer").debug("Migration state: ${state.progress}") - if (state.progress == MigrationProgress.COMPLETED) { - Logger("MigrationPushRenewer").debug("Renewing registration....") - - // This should force a recreation of firebase device token, re-registration with - // the autopush service, and subsequent update of the FxA device record with - // new push subscription information. - service?.renewRegistration() - } - } - } - } -} diff --git a/app/src/migration/java/org/mozilla/fenix/MigrationService.kt b/app/src/migration/java/org/mozilla/fenix/MigrationService.kt deleted file mode 100644 index 5c0a82fade..0000000000 --- a/app/src/migration/java/org/mozilla/fenix/MigrationService.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* 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.migration.AbstractMigrationService -import mozilla.components.support.migration.state.MigrationStore -import org.mozilla.fenix.ext.components - -/** - * Background service for running the migration from legacy Firefox for Android (Fennec). - */ -class MigrationService : AbstractMigrationService() { - override val migrator by lazy { getMigratorFromApplication() } - override val store: MigrationStore by lazy { components.migrationStore } - override val migrationDecisionActivity = MigrationDecisionActivity::class.java -} diff --git a/app/src/release/AndroidManifest.xml b/app/src/release/AndroidManifest.xml new file mode 100644 index 0000000000..77f0a4ae91 --- /dev/null +++ b/app/src/release/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + diff --git a/app/src/test/java/org/mozilla/fenix/IntentReceiverActivityTest.kt b/app/src/test/java/org/mozilla/fenix/IntentReceiverActivityTest.kt index a3361e7c75..ace2b28ab3 100644 --- a/app/src/test/java/org/mozilla/fenix/IntentReceiverActivityTest.kt +++ b/app/src/test/java/org/mozilla/fenix/IntentReceiverActivityTest.kt @@ -53,7 +53,6 @@ class IntentReceiverActivityTest { every { intentProcessors.privateCustomTabIntentProcessor } returns mockIntentProcessor() every { intentProcessors.externalAppIntentProcessors } returns emptyList() every { intentProcessors.fennecPageShortcutIntentProcessor } returns mockIntentProcessor() - every { intentProcessors.migrationIntentProcessor } returns mockIntentProcessor() every { intentProcessors.externalDeepLinkIntentProcessor } returns mockIntentProcessor() coEvery { intentProcessors.intentProcessor.process(any()) } returns true diff --git a/app/src/test/java/org/mozilla/fenix/migration/MigrationStatusAdapterTest.kt b/app/src/test/java/org/mozilla/fenix/migration/MigrationStatusAdapterTest.kt deleted file mode 100644 index 1dfe885390..0000000000 --- a/app/src/test/java/org/mozilla/fenix/migration/MigrationStatusAdapterTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* 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.migration - -import android.view.View -import android.widget.FrameLayout -import mozilla.components.support.migration.Migration -import mozilla.components.support.migration.MigrationRun -import mozilla.components.support.test.robolectric.testContext -import org.junit.Assert.assertEquals -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mozilla.fenix.databinding.MigrationListItemBinding -import org.mozilla.fenix.helpers.FenixRobolectricTestRunner - -@RunWith(FenixRobolectricTestRunner::class) -class MigrationStatusAdapterTest { - - private lateinit var adapter: MigrationStatusAdapter - - @Before - fun setup() { - adapter = MigrationStatusAdapter() - } - - @Test - fun `getItemCount should return the number of items in whitelist`() { - assertEquals(0, adapter.itemCount) - - adapter.updateData( - mapOf( - Migration.Addons to MigrationRun(0, success = true), - Migration.Settings to MigrationRun(0, success = true), - Migration.Bookmarks to MigrationRun(0, success = false) - ) - ) - assertEquals(4, adapter.itemCount) - } - - @Test - fun `creates and binds viewholder`() { - adapter.updateData( - mapOf( - Migration.History to MigrationRun(0, success = true) - ) - ) - - val holder1 = adapter.createViewHolder(FrameLayout(testContext), 0) - val holder2 = adapter.createViewHolder(FrameLayout(testContext), 0) - val binding1 = MigrationListItemBinding.bind(holder1.itemView) - val binding2 = MigrationListItemBinding.bind(holder2.itemView) - adapter.bindViewHolder(holder1, 0) - adapter.bindViewHolder(holder2, 1) - - assertEquals("Settings", binding1.migrationItemName.text) - assertEquals(View.INVISIBLE, binding1.migrationStatusImage.visibility) - - assertEquals("History", binding2.migrationItemName.text) - assertEquals(View.VISIBLE, binding2.migrationStatusImage.visibility) - assertEquals("Migration completed", binding2.migrationStatusImage.contentDescription) - } -} diff --git a/app/src/test/java/org/mozilla/fenix/migration/MigrationTelemetryListenerTest.kt b/app/src/test/java/org/mozilla/fenix/migration/MigrationTelemetryListenerTest.kt deleted file mode 100644 index c6ae331218..0000000000 --- a/app/src/test/java/org/mozilla/fenix/migration/MigrationTelemetryListenerTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* 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.migration - -import io.mockk.MockKAnnotations -import io.mockk.impl.annotations.MockK -import io.mockk.verify -import io.mockk.verifyOrder -import kotlinx.coroutines.test.TestCoroutineDispatcher -import kotlinx.coroutines.test.runBlockingTest -import mozilla.components.support.base.log.logger.Logger -import mozilla.components.support.migration.state.MigrationAction -import mozilla.components.support.migration.state.MigrationStore -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.rule.MainCoroutineRule -import org.junit.After -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.mozilla.fenix.components.metrics.Event -import org.mozilla.fenix.components.metrics.MetricController - -class MigrationTelemetryListenerTest { - - private val testDispatcher = TestCoroutineDispatcher() - - @get:Rule - val coroutinesTestRule = MainCoroutineRule(testDispatcher) - - @MockK(relaxed = true) private lateinit var metrics: MetricController - @MockK(relaxed = true) private lateinit var logger: Logger - private lateinit var store: MigrationStore - private lateinit var listener: MigrationTelemetryListener - - @Before - fun setup() { - MockKAnnotations.init(this) - store = MigrationStore() - listener = MigrationTelemetryListener( - metrics = metrics, - store = store, - logger = logger - ) - } - - @After - fun cleanUp() { - testDispatcher.cleanupTestCoroutines() - } - - @Test - fun `progress state is logged`() = testDispatcher.runBlockingTest { - listener.start() - store.dispatch(MigrationAction.Started).joinBlocking() - store.dispatch(MigrationAction.Completed).joinBlocking() - store.dispatch(MigrationAction.Clear).joinBlocking() - - verifyOrder { - logger.debug("Migration state: MIGRATING") - logger.debug("Migration state: COMPLETED") - logger.debug("Migration state: NONE") - } - } - - @Test - fun `metrics are logged when migration is completed`() = testDispatcher.runBlockingTest { - listener.start() - store.dispatch(MigrationAction.Completed).joinBlocking() - - verify { metrics.track(Event.FennecToFenixMigrated) } - } -} diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 40810fc601..cf5caee655 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -172,7 +172,6 @@ object Deps { 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_test_libstate = "org.mozilla.components:support-test-libstate:${Versions.mozilla_android_components}" - const val mozilla_support_migration = "org.mozilla.components:support-migration:${Versions.mozilla_android_components}" const val mozilla_support_locale = "org.mozilla.components:support-locale:${Versions.mozilla_android_components}" const val sentry = "io.sentry:sentry-android:${Versions.sentry}"