Merge changes from topic "telecom-cts-presubmit"
* changes:
Remove extra space
Add CtsTelecomTestCases to presubmit
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 75feeb6..02bd056 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -15,6 +15,14 @@
"exclude-annotation": "androidx.test.filters.FlakyTest"
}
]
+ },
+ {
+ "name": "CtsTelecomTestCases",
+ "options": [
+ {
+ "exclude-annotation": "androidx.test.filters.FlakyTest"
+ }
+ ]
}
]
}
diff --git a/src/com/android/server/telecom/CreateConnectionProcessor.java b/src/com/android/server/telecom/CreateConnectionProcessor.java
index bfd625f..a4b64a4 100644
--- a/src/com/android/server/telecom/CreateConnectionProcessor.java
+++ b/src/com/android/server/telecom/CreateConnectionProcessor.java
@@ -436,7 +436,10 @@
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);
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index 88b1c29..9421639 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -1721,6 +1721,32 @@
}
}
+ /**
+ * 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 {
diff --git a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
index 132d01a..4796ed2 100644
--- a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
@@ -1018,7 +1018,7 @@
@SmallTest
@Test
public void testHangupActiveCallWhenHeadsetMediaButtonLongPressDuringTwoCalls() {
- // GIVEN an ongoing call
+ // GIVEN an ongoing call
Call ongoingCall = addSpyCall();
doReturn(CallState.ACTIVE).when(ongoingCall).getState();