Merge "Revert "Improve the code of handleSessionLost()"" am: f4d9a092f6 am: ed511881d7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2112764 Change-Id: I45ca3c0084edd2457c1eab59925249a5d3979720 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -3159,13 +3159,8 @@ public class Vpn {
|
|||||||
cancelHandleNetworkLostTimeout();
|
cancelHandleNetworkLostTimeout();
|
||||||
|
|
||||||
synchronized (Vpn.this) {
|
synchronized (Vpn.this) {
|
||||||
String category = "";
|
|
||||||
int errorClass = 0;
|
|
||||||
int errorCode = 0;
|
|
||||||
if (exception instanceof IkeProtocolException) {
|
if (exception instanceof IkeProtocolException) {
|
||||||
final IkeProtocolException ikeException = (IkeProtocolException) exception;
|
final IkeProtocolException ikeException = (IkeProtocolException) exception;
|
||||||
category = VpnManager.CATEGORY_EVENT_IKE_ERROR;
|
|
||||||
errorCode = ikeException.getErrorType();
|
|
||||||
|
|
||||||
switch (ikeException.getErrorType()) {
|
switch (ikeException.getErrorType()) {
|
||||||
case IkeProtocolException.ERROR_TYPE_NO_PROPOSAL_CHOSEN: // Fallthrough
|
case IkeProtocolException.ERROR_TYPE_NO_PROPOSAL_CHOSEN: // Fallthrough
|
||||||
@@ -3175,38 +3170,12 @@ public class Vpn {
|
|||||||
case IkeProtocolException.ERROR_TYPE_FAILED_CP_REQUIRED: // Fallthrough
|
case IkeProtocolException.ERROR_TYPE_FAILED_CP_REQUIRED: // Fallthrough
|
||||||
case IkeProtocolException.ERROR_TYPE_TS_UNACCEPTABLE:
|
case IkeProtocolException.ERROR_TYPE_TS_UNACCEPTABLE:
|
||||||
// All the above failures are configuration errors, and are terminal
|
// All the above failures are configuration errors, and are terminal
|
||||||
errorClass = VpnManager.ERROR_CLASS_NOT_RECOVERABLE;
|
|
||||||
break;
|
|
||||||
// All other cases possibly recoverable.
|
|
||||||
default:
|
|
||||||
// All the above failures are configuration errors, and are terminal
|
|
||||||
errorClass = VpnManager.ERROR_CLASS_RECOVERABLE;
|
|
||||||
}
|
|
||||||
} else if (exception instanceof IllegalArgumentException) {
|
|
||||||
// Failed to build IKE/ChildSessionParams; fatal profile configuration error
|
|
||||||
markFailedAndDisconnect(exception);
|
|
||||||
return;
|
|
||||||
} else if (exception instanceof IkeNetworkLostException) {
|
|
||||||
category = VpnManager.CATEGORY_EVENT_NETWORK_ERROR;
|
|
||||||
errorClass = VpnManager.ERROR_CLASS_RECOVERABLE;
|
|
||||||
errorCode = VpnManager.ERROR_CODE_NETWORK_LOST;
|
|
||||||
} else if (exception instanceof IkeNonProtocolException) {
|
|
||||||
category = VpnManager.CATEGORY_EVENT_NETWORK_ERROR;
|
|
||||||
errorClass = VpnManager.ERROR_CLASS_RECOVERABLE;
|
|
||||||
if (exception.getCause() instanceof UnknownHostException) {
|
|
||||||
errorCode = VpnManager.ERROR_CODE_NETWORK_UNKNOWN_HOST;
|
|
||||||
} else if (exception.getCause() instanceof IkeTimeoutException) {
|
|
||||||
errorCode = VpnManager.ERROR_CODE_NETWORK_PROTOCOL_TIMEOUT;
|
|
||||||
} else if (exception.getCause() instanceof IOException) {
|
|
||||||
errorCode = VpnManager.ERROR_CODE_NETWORK_IO;
|
|
||||||
}
|
|
||||||
} else if (exception != null) {
|
|
||||||
Log.wtf(TAG, "onSessionLost: exception = " + exception);
|
|
||||||
}
|
|
||||||
// TODO(b/230548427): Remove SDK check once VPN related stuff are
|
// TODO(b/230548427): Remove SDK check once VPN related stuff are
|
||||||
// decoupled from ConnectivityServiceTest.
|
// decoupled from ConnectivityServiceTest.
|
||||||
if (SdkLevel.isAtLeastT()) {
|
if (SdkLevel.isAtLeastT()) {
|
||||||
sendEventToVpnManagerApp(category, errorClass, errorCode,
|
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_IKE_ERROR,
|
||||||
|
VpnManager.ERROR_CLASS_NOT_RECOVERABLE,
|
||||||
|
ikeException.getErrorType(),
|
||||||
getPackage(), mSessionKey, makeVpnProfileStateLocked(),
|
getPackage(), mSessionKey, makeVpnProfileStateLocked(),
|
||||||
mActiveNetwork,
|
mActiveNetwork,
|
||||||
getRedactedNetworkCapabilitiesOfUnderlyingNetwork(
|
getRedactedNetworkCapabilitiesOfUnderlyingNetwork(
|
||||||
@@ -3214,11 +3183,89 @@ public class Vpn {
|
|||||||
getRedactedLinkPropertiesOfUnderlyingNetwork(
|
getRedactedLinkPropertiesOfUnderlyingNetwork(
|
||||||
mUnderlyingLinkProperties));
|
mUnderlyingLinkProperties));
|
||||||
}
|
}
|
||||||
if (errorClass == VpnManager.ERROR_CLASS_NOT_RECOVERABLE) {
|
|
||||||
markFailedAndDisconnect(exception);
|
markFailedAndDisconnect(exception);
|
||||||
return;
|
return;
|
||||||
} else if (errorClass == VpnManager.ERROR_CLASS_RECOVERABLE) {
|
// All other cases possibly recoverable.
|
||||||
// Retry a new IKE session.
|
default:
|
||||||
|
// All the above failures are configuration errors, and are terminal
|
||||||
|
// TODO(b/230548427): Remove SDK check once VPN related stuff are
|
||||||
|
// decoupled from ConnectivityServiceTest.
|
||||||
|
if (SdkLevel.isAtLeastT()) {
|
||||||
|
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_IKE_ERROR,
|
||||||
|
VpnManager.ERROR_CLASS_RECOVERABLE,
|
||||||
|
ikeException.getErrorType(),
|
||||||
|
getPackage(), mSessionKey, makeVpnProfileStateLocked(),
|
||||||
|
mActiveNetwork,
|
||||||
|
getRedactedNetworkCapabilitiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingNetworkCapabilities),
|
||||||
|
getRedactedLinkPropertiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingLinkProperties));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (exception instanceof IllegalArgumentException) {
|
||||||
|
// Failed to build IKE/ChildSessionParams; fatal profile configuration error
|
||||||
|
markFailedAndDisconnect(exception);
|
||||||
|
return;
|
||||||
|
} else if (exception instanceof IkeNetworkLostException) {
|
||||||
|
// TODO(b/230548427): Remove SDK check once VPN related stuff are
|
||||||
|
// decoupled from ConnectivityServiceTest.
|
||||||
|
if (SdkLevel.isAtLeastT()) {
|
||||||
|
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_NETWORK_ERROR,
|
||||||
|
VpnManager.ERROR_CLASS_RECOVERABLE,
|
||||||
|
VpnManager.ERROR_CODE_NETWORK_LOST,
|
||||||
|
getPackage(), mSessionKey, makeVpnProfileStateLocked(),
|
||||||
|
mActiveNetwork,
|
||||||
|
getRedactedNetworkCapabilitiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingNetworkCapabilities),
|
||||||
|
getRedactedLinkPropertiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingLinkProperties));
|
||||||
|
}
|
||||||
|
} else if (exception instanceof IkeNonProtocolException) {
|
||||||
|
if (exception.getCause() instanceof UnknownHostException) {
|
||||||
|
// TODO(b/230548427): Remove SDK check once VPN related stuff are
|
||||||
|
// decoupled from ConnectivityServiceTest.
|
||||||
|
if (SdkLevel.isAtLeastT()) {
|
||||||
|
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_NETWORK_ERROR,
|
||||||
|
VpnManager.ERROR_CLASS_RECOVERABLE,
|
||||||
|
VpnManager.ERROR_CODE_NETWORK_UNKNOWN_HOST,
|
||||||
|
getPackage(), mSessionKey, makeVpnProfileStateLocked(),
|
||||||
|
mActiveNetwork,
|
||||||
|
getRedactedNetworkCapabilitiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingNetworkCapabilities),
|
||||||
|
getRedactedLinkPropertiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingLinkProperties));
|
||||||
|
}
|
||||||
|
} else if (exception.getCause() instanceof IkeTimeoutException) {
|
||||||
|
// TODO(b/230548427): Remove SDK check once VPN related stuff are
|
||||||
|
// decoupled from ConnectivityServiceTest.
|
||||||
|
if (SdkLevel.isAtLeastT()) {
|
||||||
|
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_NETWORK_ERROR,
|
||||||
|
VpnManager.ERROR_CLASS_RECOVERABLE,
|
||||||
|
VpnManager.ERROR_CODE_NETWORK_PROTOCOL_TIMEOUT,
|
||||||
|
getPackage(), mSessionKey, makeVpnProfileStateLocked(),
|
||||||
|
mActiveNetwork,
|
||||||
|
getRedactedNetworkCapabilitiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingNetworkCapabilities),
|
||||||
|
getRedactedLinkPropertiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingLinkProperties));
|
||||||
|
}
|
||||||
|
} else if (exception.getCause() instanceof IOException) {
|
||||||
|
// TODO(b/230548427): Remove SDK check once VPN related stuff are
|
||||||
|
// decoupled from ConnectivityServiceTest.
|
||||||
|
if (SdkLevel.isAtLeastT()) {
|
||||||
|
sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_NETWORK_ERROR,
|
||||||
|
VpnManager.ERROR_CLASS_RECOVERABLE,
|
||||||
|
VpnManager.ERROR_CODE_NETWORK_IO,
|
||||||
|
getPackage(), mSessionKey, makeVpnProfileStateLocked(),
|
||||||
|
mActiveNetwork,
|
||||||
|
getRedactedNetworkCapabilitiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingNetworkCapabilities),
|
||||||
|
getRedactedLinkPropertiesOfUnderlyingNetwork(
|
||||||
|
mUnderlyingLinkProperties));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (exception != null) {
|
||||||
|
Log.wtf(TAG, "onSessionLost: exception = " + exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user