From 7cb77f73470bb247186095a9493eab51442da752 Mon Sep 17 00:00:00 2001 From: lucaslin Date: Wed, 15 Dec 2021 15:19:32 +0800 Subject: Add constants of VpnManager events Bug: 191413541 Test: N/A Change-Id: I1db1419d701940ba74b59f61d510878f08e64c91 --- core/java/android/net/VpnManager.java | 135 ++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/core/java/android/net/VpnManager.java b/core/java/android/net/VpnManager.java index 5c2855307509..319382691925 100644 --- a/core/java/android/net/VpnManager.java +++ b/core/java/android/net/VpnManager.java @@ -96,6 +96,141 @@ public class VpnManager { */ public static final String NOTIFICATION_CHANNEL_VPN = "VPN"; + /** + * Action sent in the intent when an error occurred. + * + * @hide + */ + public static final String ACTION_VPN_MANAGER_ERROR = "android.net.action.VPN_MANAGER_ERROR"; + + /** + * An IKE protocol error. Codes are the codes from IkeProtocolException, RFC 7296. + * + * @hide + */ + public static final String CATEGORY_ERROR_IKE = "android.net.category.ERROR_IKE"; + + /** + * User deactivated the VPN, either by turning it off or selecting a different VPN provider. + * The error code is always 0. + * + * @hide + */ + public static final String CATEGORY_ERROR_USER_DEACTIVATED = + "android.net.category.ERROR_USER_DEACTIVATED"; + + /** + * Network error. Error codes are ERROR_CODE_NETWORK_*. + * + * @hide + */ + public static final String CATEGORY_ERROR_NETWORK = "android.net.category.ERROR_NETWORK"; + + /** + * The key of the session that experienced this error, as returned by + * startProvisionedVpnProfileSession. + * + * @hide + */ + public static final String EXTRA_SESSION_KEY = "android.net.extra.SESSION_KEY"; + + /** + * Extra for the Network object that was the underlying network at the time of the failure, or + * null if none. + * + * @hide + */ + public static final String EXTRA_UNDERLYING_NETWORK = "android.net.extra.UNDERLYING_NETWORK"; + + /** + * The NetworkCapabilities of the underlying network. + * + * @hide + */ + public static final String EXTRA_UNDERLYING_NETWORK_CAPABILITIES = + "android.net.extra.UNDERLYING_NETWORK_CAPABILITIES"; + + /** + * The LinkProperties of the underlying network. + * + * @hide + */ + public static final String EXTRA_UNDERLYING_LINK_PROPERTIES = + "android.net.extra.UNDERLYING_LINK_PROPERTIES"; + + /** + * A long timestamp with SystemClock.elapsedRealtime base for when the event happened. + * + * @hide + */ + public static final String EXTRA_TIMESTAMP = "android.net.extra.TIMESTAMP"; + + /** + * Extra for the error type. This is ERROR_NOT_RECOVERABLE or ERROR_RECOVERABLE. + * + * @hide + */ + public static final String EXTRA_ERROR_TYPE = "android.net.extra.ERROR_TYPE"; + + /** + * Extra for the error code. The value will be 0 for CATEGORY_ERROR_USER_DEACTIVATED, one of + * ERROR_CODE_NETWORK_* for ERROR_CATEGORY_NETWORK or one of values defined in + * IkeProtocolException#ErrorType for CATEGORY_ERROR_IKE. + * + * @hide + */ + public static final String EXTRA_ERROR_CODE = "android.net.extra.ERROR_CODE"; + + /** + * This error is fatal, e.g. the VPN was disabled or configuration error. The stack will not + * retry connection. + * + * @hide + */ + public static final int ERROR_NOT_RECOVERABLE = 1; + + /** + * The stack experienced an error but will retry with exponential backoff, e.g. network timeout. + * + * @hide + */ + public static final int ERROR_RECOVERABLE = 2; + + /** + * An error code to indicate that there was an UnknownHostException. + * + * @hide + */ + public static final int ERROR_CODE_NETWORK_UNKNOWN_HOST = 0; + + /** + * An error code to indicate that there is a SocketTimeoutException. + * + * @hide + */ + public static final int ERROR_CODE_NETWORK_TIMEOUT = 1; + + /** + * An error code to indicate that the connection is refused. + * + * @hide + */ + public static final int ERROR_CODE_NETWORK_CONNECT = 2; + + /** + * An error code to indicate the connection was reset. (e.g. SocketException) + * + * @hide + */ + public static final int ERROR_CODE_NETWORK_CONNECTION_RESET = 3; + + /** + * An error code to indicate that there is an IOException. + * + * @hide + */ + public static final int ERROR_CODE_NETWORK_IO = 4; + /** @hide */ @IntDef(value = {TYPE_VPN_NONE, TYPE_VPN_SERVICE, TYPE_VPN_PLATFORM, TYPE_VPN_LEGACY, TYPE_VPN_OEM}) -- cgit v1.2.3-59-g8ed1b