Class IPProtectionController
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceEmbedder-provided hooks for authentication.static classA country available in the proxy serverlist.static interfaceDelegate for receiving IP protection state notifications.static classHolds the result of an enrollment attempt.static interfaceEmbedder-provided hooks for Google Play Integrity authentication.static classException type for IP proxy errors.static classHolds the current IP proxy state and any associated error.static @interfaceThe possible states of the IP protection service.static classHolds information about the current IP proxy usage. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe user has opted out from using VPN.static final intThe service is ready to be activated.static final intThe user is signed out but eligible.static final intThe user is not eligible or still not signed in.static final intThe service has not been initialized yet. -
Method Summary
Modifier and TypeMethodDescriptionactivate()Activates the IP proxy by user action, in a non-private context, using the recommended location.Activates the IP proxy.Deactivates the IP proxy.enroll()Triggers enrollment via the active auth provider.Gets theIPProtectionController.AuthProviderfor this instance.Requests the list of countries available in the proxy serverlist.Gets theIPProtectionController.Delegatefor this instance.Gets theIPProtectionController.GpiProviderfor this instance.Gets the current IP proxy state.Gets the current IP protection service state.init()Initializes the IP protection service.notifySignInStateChanged(boolean signedIn) Notifies the IP protection service of a sign-in state change.Requests a refresh of the proxy usage information.voidSets theIPProtectionController.AuthProviderused to supply authentication tokens.voidsetDelegate(IPProtectionController.Delegate delegate) Sets theIPProtectionController.Delegatefor this instance.voidSets theIPProtectionController.GpiProviderused to handle Google Play Integrity warm-up and token requests.uninit()Uninitializes the IP protection service, resetting the controller to its initial state.
-
Field Details
-
SERVICE_STATE_UNINITIALIZED
public static final int SERVICE_STATE_UNINITIALIZEDThe service has not been initialized yet.- See Also:
-
SERVICE_STATE_UNAVAILABLE
public static final int SERVICE_STATE_UNAVAILABLEThe user is not eligible or still not signed in.- See Also:
-
SERVICE_STATE_UNAUTHENTICATED
public static final int SERVICE_STATE_UNAUTHENTICATEDThe user is signed out but eligible.- See Also:
-
SERVICE_STATE_OPTED_OUT
public static final int SERVICE_STATE_OPTED_OUTThe user has opted out from using VPN.- See Also:
-
SERVICE_STATE_READY
public static final int SERVICE_STATE_READYThe service is ready to be activated.- See Also:
-
-
Method Details
-
init
Initializes the IP protection service.- Returns:
- A
GeckoResultthat resolves when initialization completes.
-
setDelegate
Sets theIPProtectionController.Delegatefor this instance.- Parameters:
delegate- TheIPProtectionController.Delegateinstance.
-
getDelegate
Gets theIPProtectionController.Delegatefor this instance.- Returns:
- The
IPProtectionController.Delegateinstance.
-
setAuthProvider
Sets theIPProtectionController.AuthProviderused to supply authentication tokens. Passnullto clear the provider.The provider governs token retrieval only. Sign-in state must be signalled separately via
notifySignInStateChanged(boolean).Requires
init()to have been called; otherwise the JS-side listeners that consume the provider have not yet been registered.- Parameters:
provider- TheIPProtectionController.AuthProvider, ornullto clear.
-
getAuthProvider
Gets theIPProtectionController.AuthProviderfor this instance.- Returns:
- The
IPProtectionController.AuthProviderinstance, ornullif none is set.
-
setGpiProvider
Sets theIPProtectionController.GpiProviderused to handle Google Play Integrity warm-up and token requests. Passnullto clear the provider.- Parameters:
provider- TheIPProtectionController.GpiProvider, ornullto clear.
-
getGpiProvider
Gets theIPProtectionController.GpiProviderfor this instance.- Returns:
- The
IPProtectionController.GpiProviderinstance, ornullif none is set.
-
notifySignInStateChanged
Notifies the IP protection service of a sign-in state change. The service recomputes its state and may transition in or out ofSERVICE_STATE_UNAUTHENTICATED.Announcing a signed-in user requires an
IPProtectionController.AuthProviderto be set viasetAuthProvider(AuthProvider)beforehand, since the service immediately queries tokens through the provider. Announcing a signed-out user does not require a provider. If the precondition is violated, the returnedGeckoResultis rejected withIllegalStateException.Requires
init()to have been called; otherwise the JS-side listeners that consume the event have not yet been registered.- Parameters:
signedIn- Whether the embedding app currently has a signed-in user.- Returns:
- A
GeckoResultthat resolves once the JS side has acknowledged the event, or rejects withIllegalStateExceptionifsignedInis true and noIPProtectionController.AuthProviderhas been set.
-
uninit
Uninitializes the IP protection service, resetting the controller to its initial state.- Returns:
- A
GeckoResultthat resolves when uninitialization completes.
-
getServiceState
Gets the current IP protection service state.- Returns:
- A
GeckoResultthat resolves to one of theIPProtectionController.ServiceStateconstants.
-
getCountryList
Requests the list of countries available in the proxy serverlist. The list is delivered asynchronously viaIPProtectionController.Delegate.onCountryListChanged(List), which is also invoked whenever the underlying serverlist changes.- Returns:
- A
GeckoResultthat resolves once the request has been processed.
-
getProxyState
Gets the current IP proxy state.- Returns:
- A
GeckoResultthat resolves to aIPProtectionController.ProxyState.
-
activate
Activates the IP proxy by user action, in a non-private context, using the recommended location.- Returns:
- A
GeckoResultthat resolves when activated, or rejects with anIPProtectionController.IPProxyExceptiondescribing the failure.
-
activate
@HandlerThread @NonNull public GeckoResult<Void> activate(boolean userAction, boolean inPrivateBrowsing, @Nullable String country) Activates the IP proxy.If the proxy is already active, calling this again with a different
countryswitches the active connection to a server in that country without tearing down the proxy.- Parameters:
userAction- Whether activation was triggered by an explicit user action, as opposed to a system action.inPrivateBrowsing- Whether activation was triggered from a private browsing context.country- The ISO 3166-1 alpha-2 code of the country to route through, ornullto use the recommended location.- Returns:
- A
GeckoResultthat resolves when activated, or rejects with anIPProtectionController.IPProxyExceptiondescribing the failure.
-
enroll
Triggers enrollment via the active auth provider.- Returns:
- A
GeckoResultthat resolves to anIPProtectionController.EnrollResultdescribing whether the user is now enrolled and entitled, and the error string if not.
-
deactivate
Deactivates the IP proxy.- Returns:
- A
GeckoResultthat resolves when deactivated, or rejects with anIPProtectionController.IPProxyExceptionif an unexpected error occurs.
-
refreshUsage
Requests a refresh of the proxy usage information. The updated usage will be delivered asynchronously viaIPProtectionController.Delegate.onUsageChanged(UsageInfo).- Returns:
- A
GeckoResultthat resolves when the refresh request has been processed, or rejects with anIPProtectionController.IPProxyExceptionif an unexpected error occurs.
-