From 09e5d4d8f60e19c5abd877284a22206942d82c3c Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Tue, 21 Jul 2020 11:50:51 +0200 Subject: [PATCH] Start using release builds of GeckoView. --- app/build.gradle | 9 +++ .../org/mozilla/fenix/engine/GeckoProvider.kt | 68 +++++++++++++++++++ taskcluster/ci/build/kind.yml | 2 +- 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 app/src/geckoProduction/java/org/mozilla/fenix/engine/GeckoProvider.kt diff --git a/app/build.gradle b/app/build.gradle index 6418535f6..f3266ecac 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -171,6 +171,10 @@ android { setIgnore true } + if (flavors.contains("geckoproduction") && buildType.name != 'fennecProduction') { + setIgnore true + } + if ((buildType.name == 'fennecProduction' || buildType.name == 'fennecBeta') && flavors.contains("geckonightly")) { setIgnore true } @@ -228,6 +232,10 @@ android { geckoBeta { dimension "engine" } + + geckoProduction { + dimension "engine" + } } splits { @@ -436,6 +444,7 @@ apply plugin: "org.mozilla.telemetry.glean-gradle-plugin" dependencies { geckoNightlyImplementation Deps.mozilla_browser_engine_gecko_nightly geckoBetaImplementation Deps.mozilla_browser_engine_gecko_beta + geckoProductionImplementation Deps.mozilla_browser_engine_gecko_release implementation Deps.kotlin_stdlib implementation Deps.kotlin_coroutines diff --git a/app/src/geckoProduction/java/org/mozilla/fenix/engine/GeckoProvider.kt b/app/src/geckoProduction/java/org/mozilla/fenix/engine/GeckoProvider.kt new file mode 100644 index 000000000..17f9bcae0 --- /dev/null +++ b/app/src/geckoProduction/java/org/mozilla/fenix/engine/GeckoProvider.kt @@ -0,0 +1,68 @@ +/* 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/. */ + +import android.content.Context +import android.os.Bundle +import mozilla.components.browser.engine.gecko.autofill.GeckoLoginDelegateWrapper +import mozilla.components.browser.engine.gecko.glean.GeckoAdapter +import mozilla.components.concept.storage.LoginsStorage +import mozilla.components.lib.crash.handler.CrashHandlerService +import mozilla.components.service.sync.logins.GeckoLoginStorageDelegate +import org.mozilla.fenix.Config +import org.mozilla.fenix.ext.settings +import org.mozilla.fenix.utils.Settings +import org.mozilla.geckoview.GeckoRuntime +import org.mozilla.geckoview.GeckoRuntimeSettings + +object GeckoProvider { + var testConfig: Bundle? = null + private var runtime: GeckoRuntime? = null + + @Synchronized + fun getOrCreateRuntime( + context: Context, + storage: Lazy + ): GeckoRuntime { + if (runtime == null) { + runtime = createRuntime(context, storage) + } + + return runtime!! + } + + private fun createRuntime( + context: Context, + storage: Lazy + ): GeckoRuntime { + val builder = GeckoRuntimeSettings.Builder() + + testConfig?.let { + builder.extras(it) + .remoteDebuggingEnabled(true) + } + + val runtimeSettings = builder + .crashHandler(CrashHandlerService::class.java) + .telemetryDelegate(GeckoAdapter()) + .aboutConfigEnabled(Config.channel.isBeta) + .debugLogging(Config.channel.isDebug) + .build() + + if (!Settings.getInstance(context).shouldUseAutoSize) { + runtimeSettings.automaticFontSizeAdjustment = false + val fontSize = Settings.getInstance(context).fontSizeFactor + runtimeSettings.fontSizeFactor = fontSize + } + + val geckoRuntime = GeckoRuntime.create(context, runtimeSettings) + // As a quick fix for #8967 we are conflating "should autofill" with "should save logins" + val loginStorageDelegate = GeckoLoginStorageDelegate( + storage, + { context.settings().shouldPromptToSaveLogins } + ) + geckoRuntime.loginStorageDelegate = GeckoLoginDelegateWrapper(loginStorageDelegate) + + return geckoRuntime + } +} diff --git a/taskcluster/ci/build/kind.yml b/taskcluster/ci/build/kind.yml index 5f7a6fab5..c5235d2bf 100644 --- a/taskcluster/ci/build/kind.yml +++ b/taskcluster/ci/build/kind.yml @@ -172,7 +172,7 @@ jobs: include-shippable-secrets: true filter-incomplete-translations: true run: - geckoview-engine: geckoBeta + geckoview-engine: geckoProduction gradle-build-type: fennecProduction treeherder: symbol: productionFennec(B)