Added in API level 33

VpnProfileState


class VpnProfileState : Parcelable
kotlin.Any
   ↳ android.net.VpnProfileState

Describe the state of VPN.

Summary

Constants
static Int

The VPN was established successfully.

static Int

The VPN is attempting to connect, potentially after a failure.

static Int

The VPN has not been started, or some other VPN is active.

static Int

A non-recoverable error has occurred, and will not be retried.

Inherited constants
Public constructors
VpnProfileState(state: Int, sessionKey: String?, alwaysOn: Boolean, lockdown: Boolean)

Public methods
Int

Implement the Parcelable interface

Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

String?

Retrieves the Session Key

Int

Returns the state of the Platform VPN

Int

Boolean

Returns the always-on status of the PlatformVpnProfile.

Boolean

Returns the lockdown mode status of the PlatformVpnProfile.

String

Unit
writeToParcel(out: Parcel, flags: Int)

Implement the Parcelable interface

Properties
static Parcelable.Creator<VpnProfileState!>

Constants

STATE_CONNECTED

Added in API level 33
static val STATE_CONNECTED: Int

The VPN was established successfully.

Value: 2

STATE_CONNECTING

Added in API level 33
static val STATE_CONNECTING: Int

The VPN is attempting to connect, potentially after a failure.

Value: 1

STATE_DISCONNECTED

Added in API level 33
static val STATE_DISCONNECTED: Int

The VPN has not been started, or some other VPN is active.

Value: 0

STATE_FAILED

Added in API level 33
static val STATE_FAILED: Int

A non-recoverable error has occurred, and will not be retried.

Value: 3

Public constructors

VpnProfileState

Added in API level 33
VpnProfileState(
    state: Int,
    sessionKey: String?,
    alwaysOn: Boolean,
    lockdown: Boolean)
Parameters
state Int: Value is android.net.VpnProfileState#STATE_CONNECTED, android.net.VpnProfileState#STATE_CONNECTING, android.net.VpnProfileState#STATE_DISCONNECTED, or android.net.VpnProfileState#STATE_FAILED
sessionKey String?: This value may be null.

Public methods

describeContents

Added in API level 33
fun describeContents(): Int

Implement the Parcelable interface

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 33
fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getSessionId

Added in API level 33
fun getSessionId(): String?

Retrieves the Session Key

The session key is an ephemeral key uniquely identifying the session for a Platform VPN. The lifetime of this key is tied to the lifetime of the VPN session. In other words, reprovisioning of the VPN profile, restarting of the device, or manually restarting the platform VPN session will result in a new VPN session, and a new key.

Return
String? the unique key for the platform VPN session, or null if it is not running.

getState

Added in API level 33
fun getState(): Int

Returns the state of the Platform VPN

This state represents the internal connection state of the VPN. This state may diverge from the VPN Network's state during error and recovery handling.

Return
Int Value is android.net.VpnProfileState#STATE_CONNECTED, android.net.VpnProfileState#STATE_CONNECTING, android.net.VpnProfileState#STATE_DISCONNECTED, or android.net.VpnProfileState#STATE_FAILED

hashCode

Added in API level 33
fun hashCode(): Int
Return
Int a hash code value for this object.

isAlwaysOn

Added in API level 33
fun isAlwaysOn(): Boolean

Returns the always-on status of the PlatformVpnProfile.

If the PlatformVpnProfile is set to be running in always-on mode, the system will ensure that the profile is always started, and restarting it when necessary (e.g. after reboot).

Always-on can be set by an appropriately privileged user via the Settings VPN menus, or by the Device Policy Manager app programmatically. See DevicePolicyManager#setAlwaysOnVpnPackage(ComponentName, String, boolean, Set)

isLockdownEnabled

Added in API level 33
fun isLockdownEnabled(): Boolean

Returns the lockdown mode status of the PlatformVpnProfile.

In lockdown mode, the system will ensure that apps are not allowed to bypass the VPN, including during startup or failure of the VPN.

Lockdown mode can be set by an appropriately privileged user via the Settings VPN menus, or by the Device Policy Manager app programmatically. See DevicePolicyManager#setAlwaysOnVpnPackage(ComponentName, String, boolean, Set)

toString

Added in API level 33
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 33
fun writeToParcel(
    out: Parcel,
    flags: Int
): Unit

Implement the Parcelable interface

Parameters
dest The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES
out Parcel: This value cannot be null.

Properties

CREATOR

Added in API level 33
static val CREATOR: Parcelable.Creator<VpnProfileState!>