Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c094c155 authored by Thomas Stuart's avatar Thomas Stuart
Browse files

modify cleanupStuckCalls shell command

previously, the cleanupStuckCalls shell command would only disconnect and remove calls in the disconnecting or disconnected state. Now, Telecom will move ongoing calls to the disconnected state so every call is cleaned up. This is helpful in testing when a test fails before the call is set to disconnected.

Bug: 321204022
Test: modifying testing infra.
Change-Id: I97b3446fc4900cffab5bedba860f17c1c7596272
parent 033b5c9e
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import android.provider.BlockedNumberContract;
import android.provider.Settings;
import android.telecom.CallAttributes;
import android.telecom.CallException;
import android.telecom.DisconnectCause;
import android.telecom.Log;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
@@ -2301,14 +2302,10 @@ public class TelecomServiceImpl {
        }

        /**
         * A method intended for use in testing to clean up any calls that get stuck in the
         * {@link CallState#DISCONNECTED} or {@link CallState#DISCONNECTING} states. Stuck
         * calls
         * during CTS cause cascading failures, so if the CTS test detects such a state, it
         * should
         * call this method via a shell command to clean up before moving on to the next
         * test.
         * Also cleans up any pending futures related to
         * A method intended for use in testing to clean up any calls are ongoing. Stuck
         * calls during CTS cause cascading failures, so if the CTS test detects such a state, it
         * should call this method via a shell command to clean up before moving on to the next
         * test. Also cleans up any pending futures related to
         * {@link android.telecom.CallDiagnosticService}s.
         */
        @Override
@@ -2321,11 +2318,19 @@ public class TelecomServiceImpl {
                    try {
                        Set<UserHandle> userHandles = new HashSet<>();
                        for (Call call : mCallsManager.getCalls()) {
                            // Any call that is not in a disconnect* state should be moved to the
                            // disconnected state
                            if (!isDisconnectingOrDisconnected(call)) {
                                mCallsManager.markCallAsDisconnected(
                                        call,
                                        new DisconnectCause(DisconnectCause.OTHER,
                                                "cleaning up stuck calls"));
                            }
                            // ensure the call is immediately removed from CallsManager instead of
                            // using a Future to do the work.
                            call.cleanup();
                            if (call.getState() == CallState.DISCONNECTED
                                    || call.getState() == CallState.DISCONNECTING) {
                            // finally, officially remove the call from CallsManager tracking
                            mCallsManager.markCallAsRemoved(call);
                            }
                            userHandles.add(call.getAssociatedUser());
                        }
                        for (UserHandle userHandle : userHandles) {
@@ -2340,6 +2345,11 @@ public class TelecomServiceImpl {
            }
        }

        private boolean isDisconnectingOrDisconnected(Call call){
            return call.getState() == CallState.DISCONNECTED
                    || call.getState() == CallState.DISCONNECTING;
        }

        /**
         * A method intended for test to clean up orphan {@link PhoneAccount}. An orphan
         * {@link PhoneAccount} is a phone account belongs to an invalid {@link UserHandle}