# VpnProfileState

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# VpnProfileState

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/VpnProfileState "View this page in Java")  

```
class VpnProfileState : Parcelable
```

|---|------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                             ||
| ↳ | [android.net.VpnProfileState](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#) |

Describe the state of VPN.

## Summary

|                                                                                                                                  Constants                                                                                                                                  ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATE_CONNECTED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_CONNECTED:kotlin.Int) The VPN was established successfully.                            |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATE_CONNECTING](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_CONNECTING:kotlin.Int) The VPN is attempting to connect, potentially after a failure. |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATE_DISCONNECTED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_DISCONNECTED:kotlin.Int) The VPN has not been started, or some other VPN is active. |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATE_FAILED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_FAILED:kotlin.Int) A non-recoverable error has occurred, and will not be retried.         |

| Inherited constants ||
|---|---|
| From class[Parcelable](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#) |----------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int) <br /> Descriptor bit used with[describeContents()](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#describeContents()): indicates that the Parcelable object's flattened representation includes a file descriptor. <br />                                                                                                                                                                                                        | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int) <br /> Flag for use with[writeToParcel](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#writeToParcel(android.os.Parcel,%20kotlin.Int)): the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". Some implementations may want to release resources at this point. <br /> | ||

|                                                                                                                                                                                                                                                                                   Public constructors                                                                                                                                                                                                                                                                                    ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [VpnProfileState](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#VpnProfileState(kotlin.Int,%20kotlin.String,%20kotlin.Boolean,%20kotlin.Boolean))`(`state:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `sessionKey:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`, `alwaysOn:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`, `lockdown:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` <br /> |

|                                                                                                                                                                                                                    Public methods                                                                                                                                                                                                                     ||
|------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [describeContents](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#describeContents())`()` Implement the Parcelable interface                                                                                                                                                                                                          |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` Indicates whether some other object is "equal to" this one.                                                                                                     |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?  | [getSessionId](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#getSessionId())`()` Retrieves the Session Key                                                                                                                                                                                                                           |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getState](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#getState())`()` Returns the state of the Platform VPN                                                                                                                                                                                                                       |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [hashCode](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#hashCode())`()` <br />                                                                                                                                                                                                                                                      |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isAlwaysOn](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#isAlwaysOn())`()` Returns the always-on status of the PlatformVpnProfile.                                                                                                                                                                                                 |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isLockdownEnabled](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#isLockdownEnabled())`()` Returns the lockdown mode status of the PlatformVpnProfile.                                                                                                                                                                               |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)   | [toString](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#toString())`()` <br />                                                                                                                                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [writeToParcel](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#writeToParcel(android.os.Parcel,%20kotlin.Int))`(`out:` `[Parcel](https://developer.android.com/reference/kotlin/android/os/Parcel.html#)`, `flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Implement the Parcelable interface |

|                                                                                                                                                                      Properties                                                                                                                                                                       ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| static[Parcelable.Creator](https://developer.android.com/reference/kotlin/android/os/Parcelable.Creator.html#)\<[VpnProfileState](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#)!\> | [CREATOR](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#CREATOR:android.os.Parcelable.Creator) <br /> |

## Constants

### STATE_CONNECTED

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val STATE_CONNECTED: Int
```

The VPN was established successfully.  

    Value: 2

### STATE_CONNECTING

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val STATE_CONNECTING: Int
```

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

    Value: 1

### STATE_DISCONNECTED

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
VpnProfileState(
    state: Int, 
    sessionKey: String?, 
    alwaysOn: Boolean, 
    lockdown: Boolean)
```

|                                                                                                                                                                                                                                                                                                                                                        Parameters                                                                                                                                                                                                                                                                                                                                                         ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `state`      | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.net.VpnProfileState#STATE_CONNECTED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_CONNECTED:kotlin.Int),[android.net.VpnProfileState#STATE_CONNECTING](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_CONNECTING:kotlin.Int),[android.net.VpnProfileState#STATE_DISCONNECTED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_DISCONNECTED:kotlin.Int), or[android.net.VpnProfileState#STATE_FAILED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_FAILED:kotlin.Int) |
| `sessionKey` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?:This value may be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

## Public methods

### describeContents

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun describeContents(): Int
```

Implement the Parcelable interface

|                                                                                                                                                                               Return                                                                                                                                                                               ||
|----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | 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](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int) |

### equals

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this object is the same as the obj argument;`false`otherwise. |

### getSessionId

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | the unique key for the platform VPN session, or null if it is not running. |

### getState

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | Value is[android.net.VpnProfileState#STATE_CONNECTED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_CONNECTED:kotlin.Int),[android.net.VpnProfileState#STATE_CONNECTING](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_CONNECTING:kotlin.Int),[android.net.VpnProfileState#STATE_DISCONNECTED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_DISCONNECTED:kotlin.Int), or[android.net.VpnProfileState#STATE_FAILED](https://developer.android.com/reference/kotlin/android/net/VpnProfileState#STATE_FAILED:kotlin.Int) |

### hashCode

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun hashCode(): Int
```

|                                                     Return                                                     ||
|----------------------------------------------------------------------------|------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a hash code value for this object. |

### isAlwaysOn

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun toString(): String
```

|                                                          Return                                                          ||
|----------------------------------------------------------------------------------|----------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |

### writeToParcel

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Additional flags about how the object should be written. May be 0 or[PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int). Value is either`0`or a combination of[android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int), and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
| `out`   | [Parcel](https://developer.android.com/reference/kotlin/android/os/Parcel.html#):This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

## Properties

### CREATOR

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val CREATOR: Parcelable.Creator<VpnProfileState!>
```