diff options
author | Sewook Seo <sewookseo@google.com> | 2023-04-13 11:42:28 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-13 11:42:28 +0000 |
commit | dc9da112083c33f28c7bcb1a10e99bd3d48ea24b (patch) | |
tree | 3db58d67047c190635971b52555d2305b85752ab | |
parent | 4bd819e2bd32e66c8922a5d5ad7779d2a0127f2e (diff) | |
parent | b220c166a74909e44a84f92dce5ec2e63cf77442 (diff) | |
download | Telephony-dc9da112083c33f28c7bcb1a10e99bd3d48ea24b.tar.gz |
[QNS] Fixes on QnsCallStatusTracker am: b220c166a7
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Telephony/+/22561882
Change-Id: I2a786360f297068f7442c62ac739a67e56f07e9a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
4 files changed, 89 insertions, 11 deletions
diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java index 098820a..f77da91 100644 --- a/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java +++ b/services/QualifiedNetworksService/src/com/android/telephony/qns/AccessNetworkEvaluator.java @@ -1426,7 +1426,7 @@ class AccessNetworkEvaluator { return true; } else { if (mNetCapability == NetworkCapabilities.NET_CAPABILITY_IMS - && mCallType == QnsConstants.CALL_TYPE_IDLE) { + && mCallStatusTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)) { // Telephony will make new connection with preferred AccessNetwork log("handover is not allowed. but need to move to target Transport."); return true; diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsCallStatusTracker.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsCallStatusTracker.java index f8b335a..cc1f194 100644 --- a/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsCallStatusTracker.java +++ b/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsCallStatusTracker.java @@ -817,14 +817,18 @@ public class QnsCallStatusTracker { } } //2. Notify a new ongoing call type - if (hasEmergencyCall() && mLastEmergencyCallType != QnsConstants.CALL_TYPE_EMERGENCY) { - mLastEmergencyCallType = QnsConstants.CALL_TYPE_EMERGENCY; - if (!isDataNetworkConnected(NetworkCapabilities.NET_CAPABILITY_EIMS) - && isDataNetworkConnected(NetworkCapabilities.NET_CAPABILITY_IMS)) { - notifyCallType(NetworkCapabilities.NET_CAPABILITY_IMS, mLastEmergencyCallType); - mEmergencyOverIms = true; - } else { - notifyCallType(NetworkCapabilities.NET_CAPABILITY_EIMS, mLastEmergencyCallType); + if (hasEmergencyCall()) { + if (mLastEmergencyCallType != QnsConstants.CALL_TYPE_EMERGENCY) { + mLastEmergencyCallType = QnsConstants.CALL_TYPE_EMERGENCY; + if (!isDataNetworkConnected(NetworkCapabilities.NET_CAPABILITY_EIMS) + && isDataNetworkConnected(NetworkCapabilities.NET_CAPABILITY_IMS)) { + notifyCallType(NetworkCapabilities.NET_CAPABILITY_IMS, + mLastEmergencyCallType); + mEmergencyOverIms = true; + } else { + notifyCallType(NetworkCapabilities.NET_CAPABILITY_EIMS, + mLastEmergencyCallType); + } } } else if (hasVideoCall()) { if (mLastNormalCallType != QnsConstants.CALL_TYPE_VIDEO) { @@ -865,6 +869,21 @@ public class QnsCallStatusTracker { return mCallStates.size() == 0; } + boolean isCallIdle(int netCapability) { + int callNum = mCallStates.size(); + if (callNum == 0) { + return true; + } + if (netCapability == NetworkCapabilities.NET_CAPABILITY_IMS) { + return (mLastNormalCallType == QnsConstants.CALL_TYPE_IDLE) + && (mLastEmergencyCallType != QnsConstants.CALL_TYPE_IDLE + && !mEmergencyOverIms); + } else if (netCapability == NetworkCapabilities.NET_CAPABILITY_EIMS) { + return mLastEmergencyCallType == QnsConstants.CALL_TYPE_IDLE || mEmergencyOverIms; + } + return false; + } + boolean hasEmergencyCall() { for (CallState cs : mCallStates) { if (cs.getImsCallServiceType() == ImsCallProfile.SERVICE_TYPE_EMERGENCY 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 7530767..9c59fd7 100644 --- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AccessNetworkEvaluatorTest.java +++ b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/AccessNetworkEvaluatorTest.java @@ -289,6 +289,8 @@ public class AccessNetworkEvaluatorTest extends QnsTest { when(mDataConnectionStatusTracker.isActiveState()).thenReturn(true); when(mDataConnectionStatusTracker.getLastTransportType()) .thenReturn(AccessNetworkConstants.TRANSPORT_TYPE_WLAN); + when(mMockQnsCallStatusTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)) + .thenReturn(true); List<Integer> accessNetworks = new ArrayList<>(); accessNetworks.add(AccessNetworkConstants.AccessNetworkType.IWLAN); QnsTelephonyListener.QnsTelephonyInfo info = @@ -349,6 +351,8 @@ public class AccessNetworkEvaluatorTest extends QnsTest { when(mDataConnectionStatusTracker.isActiveState()).thenReturn(true); when(mDataConnectionStatusTracker.getLastTransportType()) .thenReturn(AccessNetworkConstants.TRANSPORT_TYPE_WLAN); + when(mMockQnsCallStatusTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)) + .thenReturn(true); List<Integer> accessNetworks = new ArrayList<>(); accessNetworks.add(AccessNetworkConstants.AccessNetworkType.IWLAN); QnsTelephonyListener.QnsTelephonyInfo info = @@ -382,14 +386,20 @@ public class AccessNetworkEvaluatorTest extends QnsTest { mAne.onQnsTelephonyInfoChanged(infoIms); mAne.updateLastNotifiedQualifiedNetwork(accessNetworks); mAne.onSetCallType(QnsConstants.CALL_TYPE_VOICE); + when(mMockQnsCallStatusTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)) + .thenReturn(false); assertTrue(mAne.needHandoverPolicyCheck()); assertFalse(mAne.moveTransportTypeAllowed()); mAne.updateLastNotifiedQualifiedNetwork(accessNetworks); mAne.onSetCallType(QnsConstants.CALL_TYPE_IDLE); + when(mMockQnsCallStatusTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)) + .thenReturn(true); assertTrue(mAne.needHandoverPolicyCheck()); assertTrue(mAne.moveTransportTypeAllowed()); mAne.updateLastNotifiedQualifiedNetwork(accessNetworks); mAne.onSetCallType(QnsConstants.CALL_TYPE_EMERGENCY); + when(mMockQnsCallStatusTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)) + .thenReturn(false); assertTrue(mAne.needHandoverPolicyCheck()); assertFalse(mAne.moveTransportTypeAllowed()); } diff --git a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsCallStatusTrackerTest.java b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsCallStatusTrackerTest.java index 5d7f405..a9247f0 100644 --- a/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsCallStatusTrackerTest.java +++ b/services/QualifiedNetworksService/tests/src/com/android/telephony/qns/QnsCallStatusTrackerTest.java @@ -157,6 +157,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_VOICE, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); // Test2: mTestCallStateList.clear(); @@ -176,7 +178,9 @@ public class QnsCallStatusTrackerTest extends QnsTest { result = (QnsAsyncResult) msg.obj; assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_IDLE, (int) result.mResult); - assertTrue(mCallTracker.isCallIdle()); // for IMS calls only + assertTrue(mCallTracker.isCallIdle()); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); } @Test @@ -193,6 +197,9 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_VOICE, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_MMS)); mTestCallStateList.clear(); mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) @@ -208,7 +215,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_DISCONNECTING) .setImsCallType(ImsCallProfile.CALL_TYPE_VOICE) .setImsCallServiceType(ImsCallProfile.SERVICE_TYPE_NORMAL).build()); - mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) + mTestCallStateList.add( + new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) .setImsCallType(ImsCallProfile.CALL_TYPE_VOICE) .setImsCallServiceType(ImsCallProfile.SERVICE_TYPE_EMERGENCY).build()); mCallTracker.updateCallState(mTestCallStateList); @@ -219,6 +227,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_EMERGENCY, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); mTestCallStateList.clear(); mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) @@ -232,6 +242,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_IDLE, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); mTestCallStateList.clear(); mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ALERTING) @@ -251,6 +263,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_VOICE, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); } @Test @@ -268,6 +282,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_VOICE, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); // for IMS calls only + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); mTestCallStateList.clear(); mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) @@ -283,6 +299,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_VIDEO, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); // for IMS calls only + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); mTestCallStateList.clear(); mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) @@ -295,6 +313,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { msg = mTestLooperListener.nextMessage(); assertNull(msg); assertFalse(mCallTracker.isCallIdle()); // for IMS calls only + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); mTestCallStateList.clear(); mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_HOLDING) @@ -308,6 +328,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_VOICE, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); mTestCallStateList.clear(); mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) @@ -346,12 +368,16 @@ public class QnsCallStatusTrackerTest extends QnsTest { assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_IDLE, (int) result.mResult); assertFalse(mCallTracker.isCallIdle()); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); mTestCallStateList.clear(); mCallTracker.updateCallState(mTestCallStateList); msg = mTestLooperListener.nextMessage(); assertNull(msg); assertTrue(mCallTracker.isCallIdle()); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); } @Test @@ -433,6 +459,8 @@ public class QnsCallStatusTrackerTest extends QnsTest { QnsAsyncResult result = (QnsAsyncResult) msg.obj; assertNotNull(result.mResult); assertEquals(QnsConstants.CALL_TYPE_EMERGENCY, (int) result.mResult); + assertFalse(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_IMS)); + assertTrue(mCallTracker.isCallIdle(NetworkCapabilities.NET_CAPABILITY_EIMS)); // Test2: mTestCallStateList.clear(); @@ -444,6 +472,27 @@ public class QnsCallStatusTrackerTest extends QnsTest { // Should not notify if call type is not changed assertNull(msg); + mTestCallStateList.clear(); + mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) + .setImsCallType(ImsCallProfile.CALL_TYPE_VOICE) + .setImsCallServiceType(ImsCallProfile.SERVICE_TYPE_EMERGENCY).build()); + mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_WAITING) + .setImsCallType(ImsCallProfile.CALL_TYPE_VOICE) + .setImsCallServiceType(ImsCallProfile.SERVICE_TYPE_NORMAL).build()); + mCallTracker.updateCallState(mTestCallStateList); + msg = mTestLooperListener.nextMessage(); + // Should not notify if call type is not changed + assertNull(msg); + + mTestCallStateList.clear(); + mTestCallStateList.add(new CallState.Builder(PreciseCallState.PRECISE_CALL_STATE_ACTIVE) + .setImsCallType(ImsCallProfile.CALL_TYPE_VOICE) + .setImsCallServiceType(ImsCallProfile.SERVICE_TYPE_EMERGENCY).build()); + mCallTracker.updateCallState(mTestCallStateList); + msg = mTestLooperListener.nextMessage(); + // Should not notify if call type is not changed + assertNull(msg); + // Test3: imsDataStatus = new PreciseDataConnectionState.Builder() |