Skip to content

Commit

Permalink
FenixSearchEngineProvider: Use dummy location service in debug builds.
Browse files Browse the repository at this point in the history
Workaround for issue described in:
mozilla-mobile/android-components#5989

For debug builds it is unnecessary to use the actual location provider since those builds
do not have an API key configured. With that patch we replace the location provider with
a dummy implementation in debug builds.
  • Loading branch information
pocmo committed Feb 28, 2020
1 parent 0def456 commit 8fdc86b
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import mozilla.components.browser.search.provider.SearchEngineList
import mozilla.components.browser.search.provider.SearchEngineProvider
import mozilla.components.browser.search.provider.filter.SearchEngineFilter
import mozilla.components.browser.search.provider.localization.SearchLocalizationProvider
import mozilla.components.service.location.LocationService
import mozilla.components.service.location.MozillaLocationService
import mozilla.components.service.location.search.RegionSearchLocalizationProvider
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import java.util.Locale
Expand All @@ -29,16 +31,19 @@ import java.util.Locale
open class FenixSearchEngineProvider(
private val context: Context
) : SearchEngineProvider, CoroutineScope by CoroutineScope(Job() + Dispatchers.IO) {
private val locationService: LocationService = if (Config.channel.isDebug) {
LocationService.dummy()
} else {
MozillaLocationService(
context,
context.components.core.client,
BuildConfig.MLS_TOKEN
)
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
open val localizationProvider: SearchLocalizationProvider =
RegionSearchLocalizationProvider(
MozillaLocationService(
context,
context.components.core.client,
BuildConfig.MLS_TOKEN
)
)
RegionSearchLocalizationProvider(locationService)

open var baseSearchEngines = async {
AssetsSearchEngineProvider(localizationProvider).loadSearchEngines(context)
Expand Down

0 comments on commit 8fdc86b

Please sign in to comment.