UserAgentMetadata


class UserAgentMetadata


Holds user-agent metadata information and uses to generate user-agent client hints.

This class is functionally equivalent to UADataValues.

Summary

Nested types

Class that holds brand name, major version and full version.

Builder used to create BrandVersion objects.

Builder used to create UserAgentMetadata objects.

Constants

const Int

Use this value for bitness to use the platform's default bitness value, which is an empty string for Android WebView.

const String!
FORM_FACTOR_AUTOMOTIVE = "Automotive"

Form factor option: Automotive, to be used with setFormFactors and getFormFactors.

const String!

Form factor option: Desktop, to be used with setFormFactors and getFormFactors.

const String!

Form factor option: EInk, to be used with setFormFactors and getFormFactors.

const String!

Form factor option: Mobile, to be used with setFormFactors and getFormFactors.

const String!

Form factor option: Tablet, to be used with setFormFactors and getFormFactors.

const String!

Form factor option: Watch, to be used with setFormFactors and getFormFactors.

const String!

Form factor option: XR, to be used with setFormFactors and getFormFactors.

Public functions

Boolean
equals(o: Any!)

Two UserAgentMetadata objects are equal only if all the metadata values are equal.

String?

Returns the value for the sec-ch-ua-arch client hint.

Int

Returns the value for the sec-ch-ua-bitness client hint.

(Mutable)List<UserAgentMetadata.BrandVersion!>

Returns the current list of user-agent brand versions which are used to populate user-agent client hints sec-ch-ua and sec-ch-ua-full-version-list.

(Mutable)List<String!>
@RequiresFeature(name = WebViewFeature.USER_AGENT_METADATA_FORM_FACTORS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
getFormFactors()

Returns the value for the sec-ch-ua-form-factors client hint.

String?

Returns the value for the sec-ch-ua-full-version client hint.

String?

Returns the value for the sec-ch-ua-model client hint.

String?

Returns the value for the sec-ch-ua-platform client hint.

String?

Returns the value for the sec-ch-ua-platform-version client hint.

Int
Boolean

Returns the value for the sec-ch-ua-mobile client hint.

Boolean

Returns the value for the sec-ch-ua-wow64 client hint.

Constants

BITNESS_DEFAULT

Added in 1.9.0
const val BITNESS_DEFAULT = 0: Int

Use this value for bitness to use the platform's default bitness value, which is an empty string for Android WebView.

FORM_FACTOR_AUTOMOTIVE

const val FORM_FACTOR_AUTOMOTIVE = "Automotive": String!

Form factor option: Automotive, to be used with setFormFactors and getFormFactors.

FORM_FACTOR_DESKTOP

const val FORM_FACTOR_DESKTOP = "Desktop": String!

Form factor option: Desktop, to be used with setFormFactors and getFormFactors.

FORM_FACTOR_EINK

const val FORM_FACTOR_EINK = "EInk": String!

Form factor option: EInk, to be used with setFormFactors and getFormFactors.

FORM_FACTOR_MOBILE

const val FORM_FACTOR_MOBILE = "Mobile": String!

Form factor option: Mobile, to be used with setFormFactors and getFormFactors.

FORM_FACTOR_TABLET

const val FORM_FACTOR_TABLET = "Tablet": String!

Form factor option: Tablet, to be used with setFormFactors and getFormFactors.

FORM_FACTOR_WATCH

const val FORM_FACTOR_WATCH = "Watch": String!

Form factor option: Watch, to be used with setFormFactors and getFormFactors.

FORM_FACTOR_XR

const val FORM_FACTOR_XR = "XR": String!

Form factor option: XR, to be used with setFormFactors and getFormFactors.

Public functions

equals

fun equals(o: Any!): Boolean

Two UserAgentMetadata objects are equal only if all the metadata values are equal.

getArchitecture

Added in 1.9.0
fun getArchitecture(): String?

Returns the value for the sec-ch-ua-arch client hint.

See also
setArchitecture

getBitness

Added in 1.9.0
fun getBitness(): Int

Returns the value for the sec-ch-ua-bitness client hint.

Returns
Int

An integer indicates the CPU bitness, the integer value will convert to string when generating the user-agent client hint, and BITNESS_DEFAULT means an empty string.

See also
setBitness

getBrandVersionList

Added in 1.9.0
fun getBrandVersionList(): (Mutable)List<UserAgentMetadata.BrandVersion!>

Returns the current list of user-agent brand versions which are used to populate user-agent client hints sec-ch-ua and sec-ch-ua-full-version-list. Each BrandVersion object holds the brand name, brand major version and brand full version.

getFormFactors

@RequiresFeature(name = WebViewFeature.USER_AGENT_METADATA_FORM_FACTORS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
fun getFormFactors(): (Mutable)List<String!>

Returns the value for the sec-ch-ua-form-factors client hint. Value should be one or more of FORM_FACTOR_DESKTOP, FORM_FACTOR_AUTOMOTIVE, FORM_FACTOR_MOBILE, FORM_FACTOR_TABLET, FORM_FACTOR_XR, FORM_FACTOR_EINK, FORM_FACTOR_WATCH. See the spec for more details.

Returns
(Mutable)List<String!>

A list of strings to indicate the form factors of the user-agent.

See also
setFormFactors

getFullVersion

Added in 1.9.0
fun getFullVersion(): String?

Returns the value for the sec-ch-ua-full-version client hint.

See also
setFullVersion

getModel

Added in 1.9.0
fun getModel(): String?

Returns the value for the sec-ch-ua-model client hint.

See also
setModel

getPlatform

Added in 1.9.0
fun getPlatform(): String?

Returns the value for the sec-ch-ua-platform client hint.

See also
setPlatform

getPlatformVersion

Added in 1.9.0
fun getPlatformVersion(): String?

Returns the value for the sec-ch-ua-platform-version client hint.

Returns
String?

Platform version string.

hashCode

fun hashCode(): Int

isMobile

Added in 1.9.0
fun isMobile(): Boolean

Returns the value for the sec-ch-ua-mobile client hint.

Returns
Boolean

A boolean indicates user-agent's device mobileness.

See also
setMobile

isWow64

Added in 1.9.0
fun isWow64(): Boolean

Returns the value for the sec-ch-ua-wow64 client hint.

Returns
Boolean

A boolean to indicate whether user-agent's binary is running in 32-bit mode on 64-bit Windows.

See also
setWow64