[fenix] Move creation of GeckoRuntime to flavor-specific source set.
Since we are now able to build against GeckoView Nightly and GeckoView Beta, we should create the GeckoRuntime from a flavor-specific source set. Creating the runtime is not covered by the AC abstraction and so API changes in GeckoView Nightly can break the build and leaves us with no option to fix it from a shared code base. Separating the creation of GeckoRuntime allows us to adapt individually and also to configure the runtimes differently.pull/600/head
parent
2127d42c9d
commit
6ac2509131
@ -0,0 +1,46 @@
|
|||||||
|
/* 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.lib.crash.handler.CrashHandlerService
|
||||||
|
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): GeckoRuntime {
|
||||||
|
if (runtime == null) {
|
||||||
|
runtime = createRuntime(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
return runtime!!
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createRuntime(context: Context): GeckoRuntime {
|
||||||
|
val builder = GeckoRuntimeSettings.Builder()
|
||||||
|
|
||||||
|
testConfig?.let {
|
||||||
|
builder.extras(it)
|
||||||
|
.remoteDebuggingEnabled(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
val runtimeSettings = builder
|
||||||
|
.crashHandler(CrashHandlerService::class.java)
|
||||||
|
.useContentProcessHint(true)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
if (!Settings.getInstance(context).shouldUseAutoSize) {
|
||||||
|
runtimeSettings.automaticFontSizeAdjustment = false
|
||||||
|
val fontSize = Settings.getInstance(context).fontSizeFactor
|
||||||
|
runtimeSettings.fontSizeFactor = fontSize
|
||||||
|
}
|
||||||
|
|
||||||
|
return GeckoRuntime.create(context, runtimeSettings)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/* 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.lib.crash.handler.CrashHandlerService
|
||||||
|
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): GeckoRuntime {
|
||||||
|
if (runtime == null) {
|
||||||
|
runtime = createRuntime(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
return runtime!!
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createRuntime(context: Context): GeckoRuntime {
|
||||||
|
val builder = GeckoRuntimeSettings.Builder()
|
||||||
|
|
||||||
|
testConfig?.let {
|
||||||
|
builder.extras(it)
|
||||||
|
.remoteDebuggingEnabled(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
val runtimeSettings = builder
|
||||||
|
.crashHandler(CrashHandlerService::class.java)
|
||||||
|
.useContentProcessHint(true)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
if (!Settings.getInstance(context).shouldUseAutoSize) {
|
||||||
|
runtimeSettings.automaticFontSizeAdjustment = false
|
||||||
|
val fontSize = Settings.getInstance(context).fontSizeFactor
|
||||||
|
runtimeSettings.fontSizeFactor = fontSize
|
||||||
|
}
|
||||||
|
|
||||||
|
return GeckoRuntime.create(context, runtimeSettings)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue