diff options
author | sangyun <sangyun@google.com> | 2023-03-13 08:37:52 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-13 08:37:52 +0000 |
commit | 298e2dd5cef7ad5237762cab35e7742d14201ba4 (patch) | |
tree | 5b3b933ab819eae3756948962122d837d1134eb5 | |
parent | e17c6f01a92b8251090b9e98f714805137b18f86 (diff) | |
parent | 91bd6a427da8d68f5faf80a2dae6610a7ddeb016 (diff) | |
download | Telephony-298e2dd5cef7ad5237762cab35e7742d14201ba4.tar.gz |
[QNS] Stop monitoring thresholds for EIMS when data disconnected. am: 91bd6a427d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Telephony/+/21937740
Change-Id: I3f3ba0a870d4d4e92802f441241ac19a8ce1a2d8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2 files changed, 84 insertions, 5 deletions
diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java index ae1a32d..46405b7 100644 --- a/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java +++ b/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java @@ -63,6 +63,10 @@ class AccessNetworkEvaluator { private static final int EVENT_SIP_DIALOG_SESSION_STATE_CHANGED = EVENT_BASE + 12; private static final int EVALUATE_SPECIFIC_REASON_NONE = 0; private static final int EVALUATE_SPECIFIC_REASON_IWLAN_DISABLE = 1; + private static final int EVALUATE_SPECIFIC_REASON_DATA_DISCONNECTED = 2; + private static final int EVALUATE_SPECIFIC_REASON_DATA_FAILED = 3; + private static final int EVALUATE_SPECIFIC_REASON_DATA_CONNECTED = 4; + protected final int mSlotIndex; protected final Context mContext; private final String mLogTag; @@ -708,32 +712,50 @@ class AccessNetworkEvaluator { DataConnectionStatusTracker.DataConnectionChangedInfo info) { log("onDataConnectionStateChanged info:" + info); boolean needEvaluate = false; + int evaluateSpecificReason = EVALUATE_SPECIFIC_REASON_NONE; switch (info.getEvent()) { case DataConnectionStatusTracker.EVENT_DATA_CONNECTION_DISCONNECTED: + evaluateSpecificReason = EVALUATE_SPECIFIC_REASON_DATA_DISCONNECTED; if (mNetCapability == NetworkCapabilities.NET_CAPABILITY_EIMS) { // If FWK guided emergency's transport type during data connected state, notify // the transport type when the data connection is disconnected. notifyCachedTransportTypeForEmergency(); + // When cellular is not available, CellularQualityMonitor will stop listening to + // TelephonyCallback. Thresholds for Emergency apn may not be reset as ANE for + // emergency only evaluates while data is connected. CellularQualityMonitor will + // not listen to TelephonyCallback again until the set of threshold values + // changed. Resetting thresholds for emergency after the emergency connection + // disconnects. + unregisterThresholdToQualityMonitor(); } else { needEvaluate = true; initLastNotifiedQualifiedNetwork(); } break; case DataConnectionStatusTracker.EVENT_DATA_CONNECTION_CONNECTED: + evaluateSpecificReason = EVALUATE_SPECIFIC_REASON_DATA_CONNECTED; mHandler.post(() -> onDataConnectionConnected(info.getTransportType())); break; case DataConnectionStatusTracker.EVENT_DATA_CONNECTION_FAILED: + evaluateSpecificReason = EVALUATE_SPECIFIC_REASON_DATA_FAILED; if (mNetCapability == NetworkCapabilities.NET_CAPABILITY_EIMS) { // If FWK guided emergency's transport type during data connecting state, notify // the transport type when the data connection is failed. notifyCachedTransportTypeForEmergency(); + // When cellular is not available, CellularQualityMonitor will stop listening to + // TelephonyCallback. Thresholds for Emergency apn may not be reset as ANE for + // emergency only evaluates while data is connected. CellularQualityMonitor will + // not listen to TelephonyCallback again until the set of threshold values + // changed. Resetting thresholds for emergency after the emergency connection + // disconnects. + unregisterThresholdToQualityMonitor(); } else { needEvaluate = true; } break; } if (needEvaluate) { - evaluate(); + evaluate(evaluateSpecificReason); } } @@ -1173,10 +1195,11 @@ class AccessNetworkEvaluator { return; } log("evaluate reason:" + evaluateSpecificReasonToString(specificReason)); - if (mNetCapability == NetworkCapabilities.NET_CAPABILITY_EIMS - && !mDataConnectionStatusTracker.isActiveState()) { - log("QNS only handles HO of EMERGENCY data connection"); - return; + if (mNetCapability == NetworkCapabilities.NET_CAPABILITY_EIMS) { + if (!mDataConnectionStatusTracker.isActiveState()) { + log("QNS only handles HO of EMERGENCY data connection"); + return; + } } /* Check handover policy */ @@ -1875,6 +1898,12 @@ class AccessNetworkEvaluator { return "EVALUATE_SPECIFIC_REASON_NONE"; } else if (specificReason == EVALUATE_SPECIFIC_REASON_IWLAN_DISABLE) { return "EVALUATE_SPECIFIC_REASON_IWLAN_DISABLE"; + } else if (specificReason == EVALUATE_SPECIFIC_REASON_DATA_DISCONNECTED) { + return "EVALUATE_SPECIFIC_REASON_DATA_DISCONNECTED"; + } else if (specificReason == EVALUATE_SPECIFIC_REASON_DATA_FAILED) { + return "EVALUATE_SPECIFIC_REASON_DATA_FAILED"; + } else if (specificReason == EVALUATE_SPECIFIC_REASON_DATA_CONNECTED) { + return "EVALUATE_SPECIFIC_REASON_DATA_CONNECTED"; } return "UNKNOWN"; } diff --git a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AccessNetworkEvaluatorTest.java b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AccessNetworkEvaluatorTest.java index 8d3883e..9ab4d2e 100644 --- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AccessNetworkEvaluatorTest.java +++ b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AccessNetworkEvaluatorTest.java @@ -63,6 +63,7 @@ import org.mockito.MockitoAnnotations; import org.mockito.stubbing.Answer; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; @@ -71,6 +72,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.stream.IntStream; @RunWith(JUnit4.class) public class AccessNetworkEvaluatorTest extends QnsTest { @@ -1734,4 +1736,52 @@ public class AccessNetworkEvaluatorTest extends QnsTest { assertEquals( QnsConstants.CALL_TYPE_VIDEO, matchedAnsp.get(0).getPreCondition().getCallType()); } + + @Test + public void testDataConnectionDisconnectedOnSos_ResettingThresholds() { + AccessNetworkEvaluator aneSos = + new AccessNetworkEvaluator( + mQnsComponents[mSlotIndex], + NetworkCapabilities.NET_CAPABILITY_EIMS, + mRestrictManager, + mDataConnectionStatusTracker, + mSlotIndex); + aneSos.registerForQualifiedNetworksChanged(mHandler, QUALIFIED_NETWORKS_CHANGED); + waitForLastHandlerAction(aneSos.mHandler); + + aneSos.onDataConnectionStateChanged( + new DataConnectionStatusTracker.DataConnectionChangedInfo( + DataConnectionStatusTracker.EVENT_DATA_CONNECTION_DISCONNECTED, + DataConnectionStatusTracker.STATE_INACTIVE, + AccessNetworkConstants.TRANSPORT_TYPE_INVALID)); + waitForLastHandlerAction(aneSos.mHandler); + + aneSos.onDataConnectionStateChanged( + new DataConnectionStatusTracker.DataConnectionChangedInfo( + DataConnectionStatusTracker.EVENT_DATA_CONNECTION_FAILED, + DataConnectionStatusTracker.STATE_INACTIVE, + AccessNetworkConstants.TRANSPORT_TYPE_INVALID)); + waitForLastHandlerAction(aneSos.mHandler); + + verify(mMockWifiQm, times(2)).updateThresholdsForNetCapability( + NetworkCapabilities.NET_CAPABILITY_EIMS, mSlotIndex, null); + } + + @Test + public void testEvaluateSpecificReasonToString() throws Exception { + Method method = AccessNetworkEvaluator.class.getDeclaredMethod( + "evaluateSpecificReasonToString", int.class); + method.setAccessible(true); + + IntStream.rangeClosed(0, 4).forEach(i -> { + try { + assertTrue(((String) method.invoke(mAne, i)).startsWith( + "EVALUATE_SPECIFIC_REASON_")); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } } |