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

Commit 39070d42 authored by Hall Liu's avatar Hall Liu
Browse files

Add CtsTelecomTestCases to presubmit

Run CTS in presubmit for Telecom.

Add methods to clean up stuck calls and get rid of a potential NPE in
starting a mock emergency call.

Fixes: 158798240
Test: presubmit
Change-Id: Ibd8aa4a8131d00118077f63bd49e2286ae013af5
parent f469a92c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -15,6 +15,14 @@
          "exclude-annotation": "androidx.test.filters.FlakyTest"
        }
      ]
    },
    {
      "name": "CtsTelecomTestCases",
      "options": [
        {
          "exclude-annotation": "androidx.test.filters.FlakyTest"
        }
      ]
    }
  ]
}
+4 −1
Original line number Diff line number Diff line
@@ -436,7 +436,10 @@ public class CreateConnectionProcessor implements CreateConnectionResponse {
                            mPhoneAccountRegistrar.getOutgoingPhoneAccountForSchemeOfCurrentUser(
                                    mCall.getHandle() == null
                                            ? null : mCall.getHandle().getScheme()));
                    if (!mAttemptRecords.contains(callAttemptRecord)) {
                    // If the target phone account is null, we'll run into a NPE during the retry
                    // process, so skip it now if it's null.
                    if (callAttemptRecord.targetPhoneAccount != null
                            && !mAttemptRecords.contains(callAttemptRecord)) {
                        Log.i(this, "Will try Connection Manager account %s for emergency",
                                callManager);
                        mAttemptRecords.add(callAttemptRecord);
+26 −0
Original line number Diff line number Diff line
@@ -1698,6 +1698,32 @@ 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.
         */
        @Override
        public void cleanupStuckCalls() {
            Log.startSession("TCI.cSC");
            try {
                synchronized (mLock) {
                    enforceShellOnly(Binder.getCallingUid(), "cleanupStuckCalls");
                    Binder.withCleanCallingIdentity(() -> {
                        for (Call call : mCallsManager.getCalls()) {
                            if (call.getState() == CallState.DISCONNECTED
                                    || call.getState() == CallState.DISCONNECTING) {
                                mCallsManager.markCallAsRemoved(call);
                            }
                        }
                    });
                }
            } finally {
                Log.endSession();
            }
        }

        @Override
        public void setTestDefaultCallRedirectionApp(String packageName) {
            try {