Interface VpnBridge
Internal service-provider interface implemented by each platform port to
carry the com.codename1.vpn API onto the native VPN machinery: Apple's
NEVPNManager and NETunnelProviderManager, and Android's VpnManager
and VpnService.
Application code never touches this interface. It is obtained by the
com.codename1.vpn packages from com.codename1.ui.Display#getVpnBridge(),
and the base implementation returns null -- which is why the public API
degrades to a well-behaved NOT_SUPPORTED on ports that implement
nothing.
The same rules as com.codename1.call.spi.CallBridge apply: primitives,
strings and byte arrays only; asynchrony by caller-allocated requestId;
every operation answers exactly once; unsolicited events marshal to the
EDT themselves.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intReserved.static final intgetVpnCapabilities()bit:com.codename1.vpn.tunnelruns here.static final intgetVpnCapabilities()bit: an IKEv2 configuration can be installed.static final intgetVpnCapabilities()bit: an IPsec configuration can be installed.static final intgetVpnCapabilities()bit: on-demand rules are honoured.static final intgetVpnCapabilities()bit: per-application routing is offered. -
Method Summary
Modifier and TypeMethodDescriptionintTheCAPABILITY_*bit mask this port supports.intThe ordinal of the currentcom.codename1.vpn.VpnStatus.voidinstallProfile(int requestId, String profileWire) Installs or replaces the configuration described byprofileWire, acom.codename1.impl.vpn.VpnWirerecord.booleanWhether this port can run a packet tunnel this app implements.booleanWhether this port can install and control a VPN configuration.voidloadProfile(int requestId) Answers with the installed configuration as a wire record, or an empty string when none is installed.voidremoveProfile(int requestId) Removes the installed configuration.voidsetStatusListening(boolean listening) Starts or stops delivery of status changes tocom.codename1.vpn.profile.Vpn#deliverStatusChanged.voidstartCustomTunnel(int requestId, String setupWire) Brings up a tunnel the application implements.voidstartVpn(int requestId) Brings the tunnel up.voidstopCustomTunnel(int requestId) Takes down a tunnel started bystartCustomTunnel(int, String).voidstopVpn(int requestId) Takes the tunnel down.
-
Field Details
-
CAPABILITY_IKEV2
static final int CAPABILITY_IKEV2getVpnCapabilities()bit: an IKEv2 configuration can be installed.- See Also:
-
CAPABILITY_IPSEC
static final int CAPABILITY_IPSECgetVpnCapabilities()bit: an IPsec configuration can be installed.- See Also:
-
CAPABILITY_CUSTOM_TUNNEL
static final int CAPABILITY_CUSTOM_TUNNELgetVpnCapabilities()bit:com.codename1.vpn.tunnelruns here.The extension iOS runs a tunnel in is a target the BUILD generates, so it carries a translated VM exactly as the app target does. What it does not carry is anything else of the app's, which is why the setup travels as data. Android runs the tunnel in a bound
VpnServicethe port ships.- See Also:
-
CAPABILITY_ON_DEMAND
static final int CAPABILITY_ON_DEMANDgetVpnCapabilities()bit: on-demand rules are honoured.iOS sets this; Android does not, because its managed profile API has no equivalent and a bit that promised one would send apps down a path that quietly becomes an ordinary manually started tunnel.
- See Also:
-
CAPABILITY_ALWAYS_ON
static final int CAPABILITY_ALWAYS_ONReserved. No port sets this, and there is noalwaysOnonVpnProfileto pair it with: always-on VPN needs a supervised device and an MDM payload on iOS, and a Settings toggle or a device-owner API on Android. The constant is kept so the bit values below it do not shift if either platform ever opens it up.- See Also:
-
CAPABILITY_PER_APP
static final int CAPABILITY_PER_APPgetVpnCapabilities()bit: per-application routing is offered.- See Also:
-
-
Method Details
-
isVpnSupported
boolean isVpnSupported()Whether this port can install and control a VPN configuration.
Distinct from merely detecting one:
com.codename1.io.NetworkManageranswers "is a VPN up" on far more platforms than can install one. -
isCustomTunnelSupported
boolean isCustomTunnelSupported()Whether this port can run a packet tunnel this app implements. -
getVpnCapabilities
int getVpnCapabilities()TheCAPABILITY_*bit mask this port supports. -
getVpnStatus
int getVpnStatus()The ordinal of the currentcom.codename1.vpn.VpnStatus. -
installProfile
Installs or replaces the configuration described by
profileWire, acom.codename1.impl.vpn.VpnWirerecord.Both platforms show the user a prompt here, and both refuse silently if the app lacks the entitlement, so a port must answer
USER_DECLINEDorUNAUTHORIZEDrather than letting the request hang. -
removeProfile
void removeProfile(int requestId) Removes the installed configuration. -
loadProfile
void loadProfile(int requestId) Answers with the installed configuration as a wire record, or an empty string when none is installed. -
startVpn
void startVpn(int requestId) Brings the tunnel up. -
stopVpn
void stopVpn(int requestId) Takes the tunnel down. -
setStatusListening
void setStatusListening(boolean listening) Starts or stops delivery of status changes tocom.codename1.vpn.profile.Vpn#deliverStatusChanged. -
startCustomTunnel
Brings up a tunnel the application implements.
setupWireis acom.codename1.impl.vpn.TunnelWirerecord. The application'sVpnTunnelis reached throughTunnels.getRegistered()on a port that runs it in this process, and constructed afresh on one that runs it in another.Answers through
com.codename1.vpn.tunnel.Tunnels#deliverAck, once, including where the user declines the system's consent prompt. -
stopCustomTunnel
void stopCustomTunnel(int requestId) Takes down a tunnel started bystartCustomTunnel(int, String).
-