Correct issue with auto disconnect conference where no participants.
The conditional check was structured assuming that the number of
participants had to go from > 0 to 0. However in the case where a single
party conference gets treated as a standlone call, there will be no
participants at the start.
The previous unit test case didn't catch this because it assumed that we'd
go from 2 participants to 0.
Test: Add new unit test case for this scenario.
Fixes: 184701944
Change-Id: I2a498d80f5f6ee2bef6b21d1520678d21fa9c1a7
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index c9f762b..0be927a 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -1074,7 +1074,12 @@
// If the conference is empty and we're supposed to do a local disconnect, do so now.
if (mCarrierConfig.shouldLocalDisconnectEmptyConference()
- && oldParticipantCount > 0 && newParticipantCount == 0) {
+ // If we dropped from > 0 participants to zero
+ // OR if the conference had a single participant and is emulating a standalone
+ // call.
+ && (oldParticipantCount > 0 || !isMultiparty())
+ // AND the CEP says there is nobody left any more.
+ && newParticipantCount == 0) {
Log.i(this, "handleConferenceParticipantsUpdate: empty conference; "
+ "local disconnect.");
onDisconnect();
diff --git a/tests/src/com/android/services/telephony/ImsConferenceTest.java b/tests/src/com/android/services/telephony/ImsConferenceTest.java
index 7e6488d..3bc5ee8 100644
--- a/tests/src/com/android/services/telephony/ImsConferenceTest.java
+++ b/tests/src/com/android/services/telephony/ImsConferenceTest.java
@@ -577,6 +577,51 @@
}
/**
+ * Similar to {@link #testLocalDisconnectOnEmptyConference()}, except tests the case where the
+ * conference first drops to a single participant, triggering single party conference emulation.
+ * Ensure that we will still recognize this and disconnect the conference.
+ * @throws Exception
+ */
+ @Test
+ @SmallTest
+ public void testLocalDisconnectOnEmptySinglePartyConference() throws Exception {
+ when(mMockTelecomAccountRegistry.isUsingSimCallManager(any(PhoneAccountHandle.class)))
+ .thenReturn(false);
+
+ ImsConference imsConference = new ImsConference(mMockTelecomAccountRegistry,
+ mMockTelephonyConnectionServiceProxy, mConferenceHost,
+ null /* phoneAccountHandle */, () -> false /* featureFlagProxy */,
+ new ImsConference.CarrierConfiguration.Builder()
+ .setShouldLocalDisconnectEmptyConference(true)
+ .build());
+
+ ConferenceParticipant participant1 = new ConferenceParticipant(
+ Uri.parse("tel:6505551212"),
+ "A",
+ Uri.parse("sip:6505551212@testims.com"),
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
+ ConferenceParticipant participant2 = new ConferenceParticipant(
+ Uri.parse("tel:6505551213"),
+ "A",
+ Uri.parse("sip:6505551213@testims.com"),
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
+ imsConference.handleConferenceParticipantsUpdate(mConferenceHost,
+ Arrays.asList(participant1, participant2));
+ assertEquals(2, imsConference.getNumberOfParticipants());
+
+ // Drop to 1 participant which enters single party mode.
+ imsConference.handleConferenceParticipantsUpdate(mConferenceHost,
+ Arrays.asList(participant1));
+
+ // Drop to 0 participants; should have a hangup request.
+ imsConference.handleConferenceParticipantsUpdate(mConferenceHost, Collections.emptyList());
+ assertEquals(0, imsConference.getNumberOfParticipants());
+ verify(mConferenceHost.mMockCall).hangup();
+ }
+
+ /**
* Verifies that an ImsConference can handle SIP and TEL URIs for both the P-Associated-Uri and
* conference event package identities.
*/