diff options
author | Kuen Yuet Cheung <kuenyuet@google.com> | 2023-09-20 08:43:31 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-09-20 08:43:31 +0000 |
commit | 762c024c74fc5750f8967f20fe172bd93e155060 (patch) | |
tree | aa5309e2165c0f06cae8a079e5f80aa3b5f7f928 | |
parent | 4061fb593da24aef2e049e31623c13bcda1d6dff (diff) | |
parent | 14b5cc157e09f6aefb7b20e35dd29f833be5a79a (diff) | |
download | Iwlan-tmp_amf_298295554.tar.gz |
Merge "Keep the RetryIndex if the Error is IKE Protocol Exception" into main am: 14b5cc157etmp_amf_298295554
Original change: https://android-review.googlesource.com/c/platform/packages/services/Iwlan/+/2751970
Change-Id: I6c00b136e0706aea181d75041aad83f60fa977c0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | src/com/google/android/iwlan/ErrorPolicyManager.java | 18 | ||||
-rw-r--r-- | test/com/google/android/iwlan/ErrorPolicyManagerTest.java | 47 |
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(); |