forked from mirrors/gecko-dev
Backout dd8cfe92844a9af9ff5b357ffb197d0d970f9f55 (Bug 1900928), r=lina,android-reviewers,jonalmeida, a=dmeehan
This was a hotfix that's no longer needed now that https://bugzilla.mozilla.org/show_bug.cgi?id=1900837 has been fixed. Differential Revision: https://phabricator.services.mozilla.com/D213847
This commit is contained in:
parent
b6def831dc
commit
53f7f2ef63
6 changed files with 59 additions and 17 deletions
|
|
@ -22,10 +22,16 @@ internal class FxSuggestIngestionWorker(
|
|||
private val logger = Logger("FxSuggestIngestionWorker")
|
||||
|
||||
override suspend fun doWork(): Result {
|
||||
// Disable periodic ingestion until we figure out
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1900837
|
||||
logger.info("Skipping ingesting new suggestions")
|
||||
return Result.success()
|
||||
logger.info("Ingesting new suggestions")
|
||||
val storage = GlobalFxSuggestDependencyProvider.requireStorage()
|
||||
val success = storage.ingest()
|
||||
return if (success) {
|
||||
logger.info("Successfully ingested new suggestions")
|
||||
Result.success()
|
||||
} else {
|
||||
logger.error("Failed to ingest new suggestions")
|
||||
Result.retry()
|
||||
}
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import org.junit.Assert.assertEquals
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
|
@ -44,9 +43,19 @@ class FxSuggestIngestionWorkerTest {
|
|||
|
||||
val result = worker.startWork().await()
|
||||
|
||||
// Ingestion is disabled until we figure out
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1900837
|
||||
verify(storage, never()).ingest(any())
|
||||
verify(storage).ingest(any())
|
||||
assertEquals(ListenableWorker.Result.success(), result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun workShouldRetry() = runTest {
|
||||
whenever(storage.ingest(any())).thenReturn(false)
|
||||
|
||||
val worker = TestListenableWorkerBuilder<FxSuggestIngestionWorker>(testContext).build()
|
||||
|
||||
val result = worker.startWork().await()
|
||||
|
||||
verify(storage).ingest(any())
|
||||
assertEquals(ListenableWorker.Result.retry(), result)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -380,16 +380,12 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
|
|||
// new search suggestions. The worker requires us to have called
|
||||
// `GlobalFxSuggestDependencyProvider.initialize`, which we did before
|
||||
// scheduling these tasks. When disabled we stop the periodic work.
|
||||
|
||||
// Disable periodic ingestion until we figure out
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1900837
|
||||
//
|
||||
// Note: we will still ingest once for a fresh DB because of
|
||||
// the `runStartupIngestion()` call below. This should be okay, the
|
||||
// performance issues only happen when reingesting after a successful
|
||||
// initial ingestion.
|
||||
if (settings().enableFxSuggest) {
|
||||
components.fxSuggest.ingestionScheduler.startPeriodicIngestion()
|
||||
} else {
|
||||
components.fxSuggest.ingestionScheduler.stopPeriodicIngestion()
|
||||
}
|
||||
}
|
||||
components.core.fileUploadsDirCleaner.cleanUploadsDirectory()
|
||||
}
|
||||
// Account manager initialization needs to happen on the main thread.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package org.mozilla.fenix.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.core.content.edit
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.EditTextPreference
|
||||
|
|
@ -15,6 +16,7 @@ import kotlinx.coroutines.flow.first
|
|||
import kotlinx.coroutines.launch
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.Config
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.debugsettings.data.DefaultDebugSettingsRepository
|
||||
import org.mozilla.fenix.ext.components
|
||||
|
|
@ -30,6 +32,7 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
|
|||
showToolbar(getString(R.string.preferences_debug_settings))
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
val debugSettingsRepository = DefaultDebugSettingsRepository(
|
||||
context = requireContext(),
|
||||
|
|
@ -80,6 +83,27 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
|
|||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
}
|
||||
|
||||
requirePreference<SwitchPreference>(R.string.pref_key_enable_fxsuggest).apply {
|
||||
isVisible = FeatureFlags.fxSuggest
|
||||
isChecked = context.settings().enableFxSuggest
|
||||
onPreferenceChangeListener = object : Preference.OnPreferenceChangeListener {
|
||||
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
||||
val newBooleanValue = newValue as? Boolean ?: return false
|
||||
val ingestionScheduler =
|
||||
requireContext().components.fxSuggest.ingestionScheduler
|
||||
if (newBooleanValue) {
|
||||
ingestionScheduler.startPeriodicIngestion()
|
||||
} else {
|
||||
ingestionScheduler.stopPeriodicIngestion()
|
||||
}
|
||||
requireContext().settings().preferences.edit {
|
||||
putBoolean(preference.key, newBooleanValue)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requirePreference<SwitchPreference>(R.string.pref_key_should_enable_felt_privacy).apply {
|
||||
isVisible = true
|
||||
isChecked = context.settings().feltPrivateBrowsingEnabled
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@
|
|||
<string name="preferences_debug_settings_compose_top_sites" translatable="false">Enable Compose Top Sites</string>
|
||||
<!-- Label for enabling the menu redesign -->
|
||||
<string name="preferences_debug_settings_menu_redesign" translatable="false">Enable Menu Redesign</string>
|
||||
<!-- Label for enabling Firefox Suggest -->
|
||||
<string name="preferences_debug_settings_fxsuggest" translatable="false">Enable Firefox Suggest</string>
|
||||
<!-- Label for enabling Toolbar Redesign incomplete portions -->
|
||||
<string name="preferences_debug_settings_toolbar_redesign" translatable="false">Enable Toolbar Redesign incomplete portions</string>
|
||||
<!-- Label for enabling Felt Privacy -->
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@
|
|||
android:key="@string/pref_key_toolbar_use_redesign_incomplete"
|
||||
android:title="@string/preferences_debug_settings_toolbar_redesign"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/pref_key_enable_fxsuggest"
|
||||
android:title="@string/preferences_debug_settings_fxsuggest"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreference
|
||||
android:key="@string/pref_key_should_enable_felt_privacy"
|
||||
app:iconSpaceReserved="false"
|
||||
|
|
|
|||
Loading…
Reference in a new issue