summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-09-23 01:25:12 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-09-23 01:25:12 +0000
commitb0f5296ca08cdde52e630ab9c70c8b357994bcd1 (patch)
treed53854ef0dd57eb29446e8bd0f9d41f315a30822
parent0521c39886666c9aaec67b23df1cb97e6de8e18c (diff)
parente2cdcdb469a9e643fa6db75e7207815bccbf04f7 (diff)
downloadIwlan-android14-qpr1-release.tar.gz
Change-Id: I35cebb476eb3cbfb7f43a43f7c0f330e58dcd891
-rw-r--r--src/com/google/android/iwlan/ErrorPolicyManager.java18
-rw-r--r--test/com/google/android/iwlan/ErrorPolicyManagerTest.java47
2 files changed, 57 insertions, 8 deletions
diff --git a/src/com/google/android/iwlan/ErrorPolicyManager.java b/src/com/google/android/iwlan/ErrorPolicyManager.java
index 53a032c..d6b7c39 100644
--- a/src/com/google/android/iwlan/ErrorPolicyManager.java
+++ b/src/com/google/android/iwlan/ErrorPolicyManager.java
@@ -219,6 +219,16 @@ public class ErrorPolicyManager {
Log.d(LOG_TAG, "Doesn't match to the previous error" + iwlanError);
ErrorPolicy policy = findErrorPolicy(apn, iwlanError);
ErrorInfo errorInfo = new ErrorInfo(iwlanError, policy);
+ if (mLastErrorForApn.containsKey(apn)) {
+ ErrorInfo prevErrorInfo = mLastErrorForApn.get(apn);
+ IwlanError prevIwlanError = prevErrorInfo.getError();
+ // If prev and current error are both IKE_PROTOCOL_EXCEPTION, keep the retry index
+ // TODO: b/292312000 - Workaround for RetryIndex lost
+ if (iwlanError.getErrorType() == IwlanError.IKE_PROTOCOL_EXCEPTION
+ && prevIwlanError.getErrorType() == IwlanError.IKE_PROTOCOL_EXCEPTION) {
+ errorInfo.setCurrentRetryIndex(prevErrorInfo.getCurrentRetryIndex());
+ }
+ }
mLastErrorForApn.put(apn, errorInfo);
}
retryTime = mLastErrorForApn.get(apn).updateCurrentRetryTime();
@@ -1076,6 +1086,14 @@ public class ErrorPolicyManager {
mLastErrorTime = IwlanHelper.elapsedRealtime();
}
+ int getCurrentRetryIndex() {
+ return mCurrentRetryIndex;
+ }
+
+ void setCurrentRetryIndex(int currentRetryIndex) {
+ mCurrentRetryIndex = currentRetryIndex;
+ }
+
/**
* Updates the current retry index and returns the retry time at new index position and also
* updates mLastErrorTime to current time. returns -1 if the index is out of bounds
diff --git a/test/com/google/android/iwlan/ErrorPolicyManagerTest.java b/test/com/google/android/iwlan/ErrorPolicyManagerTest.java
index f9ec9fa..8732e42 100644
--- a/test/com/google/android/iwlan/ErrorPolicyManagerTest.java
+++ b/test/com/google/android/iwlan/ErrorPolicyManagerTest.java
@@ -244,18 +244,13 @@ public class ErrorPolicyManagerTest {
assertEquals(4, time);
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(8, time);
- time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
- assertEquals(16, time);
- time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
- assertEquals(86400, time);
// Validate the range error detail.
+ // TODO: b/292312000 - IKE Protocol Error Keep RetryIndex Workaround
+ // IKE Protocol Error will keep the RetryIndex. Although a new error with
+ // different error code reported, timer will not start at RetryIndex 0
iwlanError = buildIwlanIkeProtocolError(9030, new byte[] {0x00, 0x01});
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
- assertEquals(4, time);
- time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
- assertEquals(8, time);
- time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(16, time);
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(86400, time);
@@ -269,6 +264,18 @@ public class ErrorPolicyManagerTest {
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(86400, time);
+ // Fallback case IKE_INIT_TIMEOUT and retryArray is 1, 2, 2, 10, 20
+ // Should start at RetryIndex 0
+ iwlanError = new IwlanError(IwlanError.IKE_INIT_TIMEOUT);
+ time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
+ assertEquals(1, time);
+ time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
+ assertEquals(2, time);
+ time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
+ assertEquals(2, time);
+ time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
+ assertEquals(10, time);
+
// Fallback case GENERIC_PROTOCOL_ERROR_TYPE(44) and retryArray is 5, 10, -1 as in
// DEFAULT_CONFIG
iwlanError = buildIwlanIkeChildSaNotFoundError();
@@ -327,6 +334,14 @@ public class ErrorPolicyManagerTest {
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(80, time);
+ // TODO: b/292312000 - IKE Protocol Error Keep RetryIndex Workaround
+ // Use APM_ENABLE_EVENT to reset the RetryIndex
+ mErrorPolicyManager
+ .mHandler
+ .obtainMessage(IwlanEventListener.APM_ENABLE_EVENT)
+ .sendToTarget();
+ mTestLooper.dispatchAll();
+
iwlanError = buildIwlanIkeProtocolError(9002);
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(5, time);
@@ -341,6 +356,14 @@ public class ErrorPolicyManagerTest {
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(80, time);
+ // TODO: b/292312000 - IKE Protocol Error Keep RetryIndex Workaround
+ // Use APM_ENABLE_EVENT to reset the RetryIndex
+ mErrorPolicyManager
+ .mHandler
+ .obtainMessage(IwlanEventListener.APM_ENABLE_EVENT)
+ .sendToTarget();
+ mTestLooper.dispatchAll();
+
iwlanError = buildIwlanIkeInternalAddressFailure();
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(0, time);
@@ -401,6 +424,14 @@ public class ErrorPolicyManagerTest {
time = mErrorPolicyManager.reportIwlanError(apn, iwlanError);
assertEquals(86400, time);
+ // TODO: b/292312000 - IKE Protocol Error Keep RetryIndex Workaround
+ // Use APM_ENABLE_EVENT to reset the RetryIndex
+ mErrorPolicyManager
+ .mHandler
+ .obtainMessage(IwlanEventListener.APM_ENABLE_EVENT)
+ .sendToTarget();
+ mTestLooper.dispatchAll();
+
// IKE_PROTOCOL_ERROR_TYPE(44) and retryArray = 0 as it will fallback to
// IKE_PROTOCOL_ERROR_TYPE generic fallback first.
iwlanError = buildIwlanIkeChildSaNotFoundError();