Class GeckoRuntimeSettings.Builder
- Enclosing class:
- GeckoRuntimeSettings
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaboutConfigEnabled
(boolean flag) Sets whether or not about:config should be enabled.allowInsecureConnections
(int level) Sets whether and where insecure (non-HTTPS) connections are allowed.Set the custom Gecko process arguments.automaticFontSizeAdjustment
(boolean enabled) Set whether or not font sizes in web content should be automatically scaled according to the device's current system font scale setting.configFilePath
(String configFilePath) Path to configuration file from which GeckoView will read configuration options such as Gecko process arguments, environment variables, and preferences.consoleOutput
(boolean enabled) Set whether or not web console messages should go to logcat.crashHandler
(Class<? extends Service> handler) When set, the specifiedService
will be started by anIntent
with actionGeckoRuntime.ACTION_CRASHED
when a crash is encountered.debugLogging
(boolean enable) Enables GeckoView and Gecko Logging.disableShip
(boolean value) Sets whether Session History in Parent (SHIP) should be disabled or not.displayDensityOverride
(float density) Set the display density override.displayDpiOverride
(int dpi) Set the display DPI override.doubleTapZoomingEnabled
(boolean flag) Set whether double tap zooming should be enabled.enterpriseRootsEnabled
(boolean enabled) Enable the Enterprise Roots feature.experimentDelegate
(ExperimentDelegate delegate) Set theExperimentDelegate
instance on this runtime, if any.extensionsProcessCrashThreshold
(Integer crashThreshold) Set the crash threshold within the timeframe before spawning is disabled for the remote extensions process.extensionsProcessCrashTimeframe
(Long timeframeMs) Set the crash threshold timeframe before spawning is disabled for the remote extensions process.extensionsProcessEnabled
(boolean flag) Set whether Extensions Process support should be enabled.extensionsWebAPIEnabled
(boolean flag) Sets whether the Add-on Manager web API (`mozAddonManager`) is enabled.Set the custom Gecko intent extras.fissionEnabled
(boolean enabled) Set whether Fission should be enabled or not.fontInflation
(boolean enabled) Set whether or not font inflation for non mobile-friendly pages should be enabled.fontSizeFactor
(float fontSizeFactor) Set a font size factor that will operate as a global text zoom.forceUserScalableEnabled
(boolean flag) Sets whether or not pinch-zooming should be enabled whenuser-scalable=no
is set on the viewport.glMsaaLevel
(int level) Sets the WebGL MSAA level.globalPrivacyControlEnabled
(boolean enabled) Set whether Global Privacy Control should be enabled.inputAutoZoomEnabled
(boolean flag) Set whether auto-zoom to editable fields should be enabled.javaScriptEnabled
(boolean flag) Set whether JavaScript support should be enabled.largeKeepaliveFactor
(int factor) Set the factor by which to increase the keepalive timeout when the NS_HTTP_LARGE_KEEPALIVE flag is used for a connection.Set the locale.loginAutofillEnabled
(boolean enabled) Set whether login forms should be filled automatically if only one viable candidate is provided viaonLoginFetch
.protected GeckoRuntimeSettings
newSettings
(GeckoRuntimeSettings settings) Create a default or copy settings object.pauseForDebugger
(boolean enabled) Set whether there should be a pause during startup.preferredColorScheme
(int scheme) Sets the preferred color scheme override for web content.remoteDebuggingEnabled
(boolean enabled) Set whether remote debugging support should be enabled.screenSizeOverride
(int width, int height) Set the screen size override.translationsOfferPopup
(boolean enabled) Set whether a candidate page should automatically offer a translation via a popup.trustedRecursiveResolverMode
(int mode) Sets whether and how DNS-over-HTTPS (Trusted Recursive Resolver) is configured.Set the DNS-over-HTTPS server URI.useMaxScreenDepth
(boolean enable) Set whether the to report the full bit depth of the device.webFontsEnabled
(boolean flag) Set whether support for web fonts should be enabled.webManifest
(boolean enabled) Set whether web manifest support is enabled.Methods inherited from class org.mozilla.geckoview.RuntimeSettings.Builder
build, getSettings
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
newSettings
Description copied from class:RuntimeSettings.Builder
Create a default or copy settings object.- Specified by:
newSettings
in classRuntimeSettings.Builder<GeckoRuntimeSettings>
- Parameters:
settings
- Settings object to copy, null for default settings.- Returns:
- The constructed settings object.
-
arguments
Set the custom Gecko process arguments.- Parameters:
args
- The Gecko process arguments.- Returns:
- This Builder instance.
-
extras
Set the custom Gecko intent extras.- Parameters:
extras
- The Gecko intent extras.- Returns:
- This Builder instance.
-
configFilePath
Path to configuration file from which GeckoView will read configuration options such as Gecko process arguments, environment variables, and preferences.Note: this feature is only available for
, on older devices this will be silently ignored.Build.VERSION.SDK_INT
> 21- Parameters:
configFilePath
- Configuration file path to read from, ornull
to use default location/data/local/tmp/$PACKAGE-geckoview-config.yaml
.- Returns:
- This Builder instance.
-
extensionsProcessEnabled
Set whether Extensions Process support should be enabled.- Parameters:
flag
- A flag determining whether Extensions Process support should be enabled. Default is false.- Returns:
- This Builder instance.
-
extensionsProcessCrashThreshold
@NonNull public GeckoRuntimeSettings.Builder extensionsProcessCrashThreshold(@NonNull Integer crashThreshold) Set the crash threshold within the timeframe before spawning is disabled for the remote extensions process.- Parameters:
crashThreshold
- The crash threshold within the timeframe before spawning is disabled.- Returns:
- This Builder instance.
-
extensionsProcessCrashTimeframe
@NonNull public GeckoRuntimeSettings.Builder extensionsProcessCrashTimeframe(@NonNull Long timeframeMs) Set the crash threshold timeframe before spawning is disabled for the remote extensions process. Crashes that are older than the current time minus timeframeMs will not be counted towards meeting the threshold.- Parameters:
timeframeMs
- The timeframe for the crash threshold in milliseconds. Any crashes older than the current time minus the timeframeMs are not counted.- Returns:
- This Builder instance.
-
javaScriptEnabled
Set whether JavaScript support should be enabled.- Parameters:
flag
- A flag determining whether JavaScript should be enabled. Default is true.- Returns:
- This Builder instance.
-
globalPrivacyControlEnabled
Set whether Global Privacy Control should be enabled. GPC is a mechanism for people to tell websites to respect their privacy rights. Once turned on, it sends a signal to the websites users visit telling them that the user doesn't want to be tracked and doesn't want their data to be sold.- Parameters:
enabled
- A flag determining whether Global Privacy Control should be enabled.- Returns:
- The builder instance.
-
remoteDebuggingEnabled
Set whether remote debugging support should be enabled.- Parameters:
enabled
- True if remote debugging should be enabled.- Returns:
- This Builder instance.
-
webFontsEnabled
Set whether support for web fonts should be enabled.- Parameters:
flag
- A flag determining whether web fonts should be enabled. Default is true.- Returns:
- This Builder instance.
-
pauseForDebugger
Set whether there should be a pause during startup. This is useful if you need to wait for a debugger to attach.- Parameters:
enabled
- A flag determining whether there will be a pause early in startup. Defaults to false.- Returns:
- This Builder.
-
useMaxScreenDepth
Set whether the to report the full bit depth of the device.By default, 24 bits are reported for high memory devices and 16 bits for low memory devices. If set to true, the device's maximum bit depth is reported. On most modern devices this will be 32 bit screen depth.
- Parameters:
enable
- A flag determining whether maximum screen depth should be used.- Returns:
- This Builder.
-
webManifest
Set whether web manifest support is enabled.This controls if Gecko actually downloads, or "obtains", web manifests and processes them. Without setting this pref, trying to obtain a manifest throws.
- Parameters:
enabled
- A flag determining whether Web Manifest processing support is enabled.- Returns:
- The builder instance.
-
consoleOutput
Set whether or not web console messages should go to logcat.Note: If enabled, Gecko performance may be negatively impacted if content makes heavy use of the console API.
- Parameters:
enabled
- A flag determining whether or not web console messages should be printed to logcat.- Returns:
- The builder instance.
-
automaticFontSizeAdjustment
Set whether or not font sizes in web content should be automatically scaled according to the device's current system font scale setting.- Parameters:
enabled
- A flag determining whether or not font sizes should be scaled automatically to match the device's system font scale.- Returns:
- The builder instance.
-
fontSizeFactor
Set a font size factor that will operate as a global text zoom. All font sizes will be multiplied by this factor.The default factor is 1.0.
This setting cannot be modified if
automatic font size adjustment
has already been enabled.- Parameters:
fontSizeFactor
- The factor to be used for scaling all text. Setting a value of 0 disables both this feature andfont inflation
.- Returns:
- The builder instance.
-
enterpriseRootsEnabled
Enable the Enterprise Roots feature.When Enabled, GeckoView will fetch the third-party root certificates added to the Android OS CA store and will use them internally.
- Parameters:
enabled
- whether to enable this feature or not- Returns:
- The builder instance
-
fontInflation
Set whether or not font inflation for non mobile-friendly pages should be enabled. The default value of this setting isfalse
.When enabled, font sizes will be increased on all pages that are lacking a <meta> viewport tag and have been loaded in a session using
GeckoSessionSettings.VIEWPORT_MODE_MOBILE
. To improve readability, the font inflation logic will attempt to increase font sizes for the main text content of the page only.The magnitude of font inflation applied depends on the
font size factor
currently in use.This setting cannot be modified if
automatic font size adjustment
has already been enabled.- Parameters:
enabled
- A flag determining whether or not font inflation should be enabled.- Returns:
- The builder instance.
-
displayDensityOverride
Set the display density override.- Parameters:
density
- The display density value to use for overriding the system default.- Returns:
- The builder instance.
-
displayDpiOverride
Set the display DPI override.- Parameters:
dpi
- The display DPI value to use for overriding the system default.- Returns:
- The builder instance.
-
screenSizeOverride
Set the screen size override.- Parameters:
width
- The screen width value to use for overriding the system default.height
- The screen height value to use for overriding the system default.- Returns:
- The builder instance.
-
loginAutofillEnabled
Set whether login forms should be filled automatically if only one viable candidate is provided viaonLoginFetch
.- Parameters:
enabled
- A flag determining whether login autofill should be enabled.- Returns:
- The builder instance.
-
fissionEnabled
Set whether Fission should be enabled or not. This must be set before startup. Note: Session History in Parent (SHIP) will be enabled as well if Fission is enabled.- Parameters:
enabled
- A flag determining whether fission should be enabled.- Returns:
- The builder instance.
-
translationsOfferPopup
Set whether a candidate page should automatically offer a translation via a popup.- Parameters:
enabled
- A flag determining whether the translations offer popup should be enabled.- Returns:
- The builder instance.
-
disableShip
Sets whether Session History in Parent (SHIP) should be disabled or not.- Parameters:
value
- A flag determining whether SHIP should be disabled or not.- Returns:
- The builder instance.
-
crashHandler
@NonNull public GeckoRuntimeSettings.Builder crashHandler(@Nullable Class<? extends Service> handler) When set, the specifiedService
will be started by anIntent
with actionGeckoRuntime.ACTION_CRASHED
when a crash is encountered. Crash details can be found in the Intent extras, such asGeckoRuntime.EXTRA_MINIDUMP_PATH
.
The crash handler Service must be declared to run in a different process from theGeckoRuntime
. Additionally, the handler will be run as a foreground service, so the normal rules about activating a foreground service apply.
In practice, you have one of three options once the crash handler is started:- Call
Service.startForeground(int, android.app.Notification)
. You can then take as much time as necessary to report the crash. - Start an activity. Unless you also call
Service.startForeground(int, android.app.Notification)
this should be in a different process from the crash handler, since Android will kill the crash handler process as part of the background execution limitations. - Schedule work via
JobScheduler
. This will allow you to do substantial work in the background without execution limits.
You can useCrashReporter
to send the report to Mozilla, which provides Mozilla with data needed to fix the crash. Be aware that the minidump may contain personally identifiable information (PII). Consult Mozilla's privacy policy for information on how this data will be handled.- Parameters:
handler
- The class for the crash handler Service.- Returns:
- This builder instance.
- See Also:
- Call
-
locales
Set the locale.- Parameters:
requestedLocales
- List of locale codes in Gecko format ("en" or "en-US").- Returns:
- The builder instance.
-
contentBlocking
-
preferredColorScheme
Sets the preferred color scheme override for web content.- Parameters:
scheme
- The preferred color scheme. Must be one of theCOLOR_SCHEME_*
constants.- Returns:
- This Builder instance.
-
inputAutoZoomEnabled
Set whether auto-zoom to editable fields should be enabled.- Parameters:
flag
- True if auto-zoom should be enabled, false otherwise.- Returns:
- This Builder instance.
-
doubleTapZoomingEnabled
Set whether double tap zooming should be enabled.- Parameters:
flag
- True if double tap zooming should be enabled, false otherwise.- Returns:
- This Builder instance.
-
glMsaaLevel
Sets the WebGL MSAA level.- Parameters:
level
- number of MSAA samples, 0 if MSAA should be disabled.- Returns:
- This Builder instance.
-
experimentDelegate
@AnyThread @NonNull public GeckoRuntimeSettings.Builder experimentDelegate(@Nullable ExperimentDelegate delegate) Set theExperimentDelegate
instance on this runtime, if any. This delegate is used to send and receive experiment information from Nimbus.- Parameters:
delegate
- TheExperimentDelegate
sending and retrieving experiment information.- Returns:
- The builder instance.
-
debugLogging
Enables GeckoView and Gecko Logging. Logging is on by default. Does not control all logging in Gecko. Logging done in Java code must be stripped out at build time.- Parameters:
enable
- True if logging is enabled.- Returns:
- This Builder instance.
-
aboutConfigEnabled
Sets whether or not about:config should be enabled. This is a page that allows users to directly modify Gecko preferences. Modification of some preferences may cause the app to break in unpredictable ways -- crashes, performance issues, security vulnerabilities, etc.- Parameters:
flag
- True if about:config should be enabled, false otherwise.- Returns:
- This Builder instance.
-
forceUserScalableEnabled
Sets whether or not pinch-zooming should be enabled whenuser-scalable=no
is set on the viewport.- Parameters:
flag
- True if force user scalable zooming should be enabled, false otherwise.- Returns:
- This Builder instance.
-
allowInsecureConnections
Sets whether and where insecure (non-HTTPS) connections are allowed.- Parameters:
level
- One of theHttpsOnlyMode
constants.- Returns:
- This Builder instance.
-
extensionsWebAPIEnabled
Sets whether the Add-on Manager web API (`mozAddonManager`) is enabled.- Parameters:
flag
- True if the web API should be enabled, false otherwise.- Returns:
- This Builder instance.
-
trustedRecursiveResolverMode
Sets whether and how DNS-over-HTTPS (Trusted Recursive Resolver) is configured.- Parameters:
mode
- One of theTrustedRecursiveResolverMode
constants.- Returns:
- This Builder instance.
-
trustedRecursiveResolverUri
Set the DNS-over-HTTPS server URI.- Parameters:
uri
- URI of the DNS-over-HTTPS server.- Returns:
- This Builder instance.
-
largeKeepaliveFactor
Set the factor by which to increase the keepalive timeout when the NS_HTTP_LARGE_KEEPALIVE flag is used for a connection.- Parameters:
factor
- FACTOR by which to increase the keepalive timeout.- Returns:
- This Builder instance.
-