Snap for 13235988 from f59f44663bc40a4868273400494fb870df3368ee to 25Q2-release

Change-Id: I0fa7acc9b7e1baf8dad0fac5ff52470efbee0ed7
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index d0fd201..5904689 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -305,6 +305,8 @@
                 return false;
             }
 
+            mAttributesLatch = new CountDownLatch(1);
+
             // Use completable future to establish a timeout, not intent to make these work outside
             // the main thread asynchronously
             // TODO: moving these RingerAttributes calculation out of Telecom lock to avoid blocking
@@ -314,7 +316,6 @@
 
             RingerAttributes attributes = null;
             try {
-                mAttributesLatch = new CountDownLatch(1);
                 attributes = ringerAttributesFuture.get(
                         RINGER_ATTRIBUTES_TIMEOUT, TimeUnit.MILLISECONDS);
             } catch (ExecutionException | InterruptedException | TimeoutException e) {
@@ -852,7 +853,9 @@
             call.setUserMissed(USER_MISSED_DND_MODE);
         }
 
-        mAttributesLatch.countDown();
+        if (mAttributesLatch != null) {
+            mAttributesLatch.countDown();
+        }
         return builder.setEndEarly(endEarly)
                 .setLetDialerHandleRinging(letDialerHandleRinging)
                 .setAcquireAudioFocus(shouldAcquireAudioFocus)
diff --git a/src/com/android/server/telecom/callsequencing/CallSequencingController.java b/src/com/android/server/telecom/callsequencing/CallSequencingController.java
index 098934c..d3a263b 100644
--- a/src/com/android/server/telecom/callsequencing/CallSequencingController.java
+++ b/src/com/android/server/telecom/callsequencing/CallSequencingController.java
@@ -292,7 +292,7 @@
                     // and the held call is a carrier call, then disconnect the held call. The
                     // idea is that if we have a held carrier call and the incoming call is a
                     // VOIP call, we don't want to force the carrier call to auto-disconnect).
-                    if (!heldCall.isSelfManaged() && call.isSelfManaged()) {
+                    if (isManagedCall(heldCall) && isVoipCall(call)) {
                         // Otherwise, fail the transaction.
                         return CompletableFuture.completedFuture(false);
                     } else {
@@ -343,8 +343,8 @@
                     // We don't want to allow VOIP apps to disconnect carrier calls. We are
                     // purposely completing the future with false so that the call isn't
                     // answered.
-                    if (isSequencingRequiredActiveAndCall && call.isSelfManaged()
-                            && !activeCall.isSelfManaged()) {
+                    if (isSequencingRequiredActiveAndCall && isVoipCall(call)
+                            && isManagedCall(activeCall)) {
                         Log.w(this, "holdActiveCallForNewCallWithSequencing: ignore "
                                 + "disconnecting carrier call for making VOIP call active");
                         return CompletableFuture.completedFuture(false);
@@ -707,7 +707,7 @@
     private CompletableFuture<Boolean> makeRoomForOutgoingCall(Call call) {
         // For the purely managed CS cases, check if there's a ringing call, in which case we will
         // disallow the outgoing call.
-        if (!call.isSelfManaged() && mCallsManager.hasManagedRingingOrSimulatedRingingCall()) {
+        if (isManagedCall(call) && mCallsManager.hasManagedRingingOrSimulatedRingingCall()) {
             showErrorDialogForOutgoingDuringRingingCall(call);
             return CompletableFuture.completedFuture(false);
         }
@@ -787,7 +787,7 @@
         // Self-Managed + Transactional calls require Telecom to manage calls in the same
         // PhoneAccount, whereas managed calls require the ConnectionService to manage calls in the
         // same PhoneAccount for legacy reasons (Telephony).
-        if (arePhoneAccountsSame(call, liveCall) && !call.isSelfManaged()) {
+        if (arePhoneAccountsSame(call, liveCall) && isManagedCall(call)) {
             Log.i(this, "makeRoomForOutgoingCall: allowing managed CS to handle "
                     + "calls from the same self-managed account");
             return CompletableFuture.completedFuture(true);
@@ -903,7 +903,7 @@
         CompletableFuture<Boolean> disconnectFuture = CompletableFuture.completedFuture(true);
         for (Call call: mCallsManager.getCalls()) {
             // Conditions for checking if call doesn't need to be disconnected immediately.
-            boolean isManaged = !call.isSelfManaged() && !call.isTransactionalCall();
+            boolean isManaged = isManagedCall(call);
             boolean callSupportsHold = call.can(Connection.CAPABILITY_SUPPORT_HOLD);
             boolean callSupportsHoldingEmergencyCall = shouldHoldForEmergencyCall(
                     call.getTargetPhoneAccount());
@@ -1084,7 +1084,7 @@
     public void maybeAddAnsweringCallDropsFg(Call activeCall, Call incomingCall) {
         // Don't set the extra when we have an incoming self-managed call that would potentially
         // disconnect the active managed call.
-        if (activeCall == null || (incomingCall.isSelfManaged() && !activeCall.isSelfManaged())) {
+        if (activeCall == null || (isVoipCall(incomingCall) && isManagedCall(activeCall))) {
             return;
         }
         // Check if the active call doesn't support hold. If it doesn't we should indicate to the
@@ -1147,4 +1147,18 @@
     public Handler getHandler() {
         return mHandler;
     }
+
+    private boolean isVoipCall(Call call) {
+        if (call == null) {
+            return false;
+        }
+        return call.isSelfManaged() || call.isTransactionalCall();
+    }
+
+    private boolean isManagedCall(Call call) {
+        if (call == null) {
+            return false;
+        }
+        return !call.isSelfManaged() && !call.isTransactionalCall();
+    }
 }
diff --git a/tests/src/com/android/server/telecom/tests/BasicCallTests.java b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
index fe39f70..ef2d1a8 100644
--- a/tests/src/com/android/server/telecom/tests/BasicCallTests.java
+++ b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
@@ -860,7 +860,7 @@
 
         mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT, 26, null);
         verify(mConnectionServiceFixtureA.getTestDouble(), timeout(TEST_TIMEOUT))
-                .sendCallEvent(eq(ids.mConnectionId), eq(TEST_EVENT), isNull(Bundle.class), any());
+                .sendCallEvent(eq(ids.mConnectionId), eq(TEST_EVENT), isNull(), any());
     }
 
     /**
diff --git a/tests/src/com/android/server/telecom/tests/CallerInfoLookupHelperTest.java b/tests/src/com/android/server/telecom/tests/CallerInfoLookupHelperTest.java
index 614ef71..645e2e4 100644
--- a/tests/src/com/android/server/telecom/tests/CallerInfoLookupHelperTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallerInfoLookupHelperTest.java
@@ -116,7 +116,7 @@
                 CallerInfoLookupHelper.OnQueryCompleteListener.class);
         mCallerInfoLookupHelper.startLookup(Uri.EMPTY, listener);
 
-        verify(listener).onCallerInfoQueryComplete(eq(Uri.EMPTY), isNull(CallerInfo.class));
+        verify(listener).onCallerInfoQueryComplete(eq(Uri.EMPTY), isNull());
         verifyProperCleanup();
     }
 
diff --git a/tests/src/com/android/server/telecom/tests/ContactsAsyncHelperTest.java b/tests/src/com/android/server/telecom/tests/ContactsAsyncHelperTest.java
index 6ed80ac..0536ddb 100644
--- a/tests/src/com/android/server/telecom/tests/ContactsAsyncHelperTest.java
+++ b/tests/src/com/android/server/telecom/tests/ContactsAsyncHelperTest.java
@@ -126,7 +126,7 @@
         cah.startObtainPhotoAsync(TOKEN, mContext, SAMPLE_CONTACT_PHOTO_URI, mListener, COOKIE);
 
         verify(mListener, timeout(TEST_TIMEOUT)).onImageLoadComplete(eq(TOKEN),
-                isNull(Drawable.class), isNull(Bitmap.class), eq(COOKIE));
+                isNull(), isNull(), eq(COOKIE));
     }
 
     @SmallTest
diff --git a/tests/src/com/android/server/telecom/tests/DefaultDialerCacheTest.java b/tests/src/com/android/server/telecom/tests/DefaultDialerCacheTest.java
index 3da9284..ecabf64 100644
--- a/tests/src/com/android/server/telecom/tests/DefaultDialerCacheTest.java
+++ b/tests/src/com/android/server/telecom/tests/DefaultDialerCacheTest.java
@@ -84,7 +84,7 @@
 
         verify(mContext, times(2)).registerReceiverAsUser(
                 packageReceiverCaptor.capture(), eq(UserHandle.ALL), any(IntentFilter.class),
-                isNull(String.class), isNull(Handler.class));
+                isNull(), isNull());
         // Receive the first receiver that was captured, the package change receiver.
         mPackageChangeReceiver = packageReceiverCaptor.getAllValues().get(0);
 
diff --git a/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java b/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
index 1776411..39836ee 100644
--- a/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
@@ -578,7 +578,7 @@
 
         CallerInfo ci = new CallerInfo();
         listenerCaptor.getValue().onCallerInfoQueryComplete(escapedHandle, ci);
-        verify(mockCallInfoFactory).makeCallInfo(eq(ci), isNull(PhoneAccountHandle.class),
+        verify(mockCallInfoFactory).makeCallInfo(eq(ci), isNull(),
                 eq(escapedHandle), eq(CALL_TIMESTAMP));
     }
 
diff --git a/tests/src/com/android/server/telecom/tests/NewOutgoingCallIntentBroadcasterTest.java b/tests/src/com/android/server/telecom/tests/NewOutgoingCallIntentBroadcasterTest.java
index e75ad97..1ea0ed1 100644
--- a/tests/src/com/android/server/telecom/tests/NewOutgoingCallIntentBroadcasterTest.java
+++ b/tests/src/com/android/server/telecom/tests/NewOutgoingCallIntentBroadcasterTest.java
@@ -385,7 +385,7 @@
         assertEquals(false, callDisposition.requestRedirection);
         assertEquals(DisconnectCause.NOT_DISCONNECTED, callDisposition.disconnectCause);
 
-        verify(mCallsManager).placeOutgoingCall(eq(mCall), eq(handle), isNull(GatewayInfo.class),
+        verify(mCallsManager).placeOutgoingCall(eq(mCall), eq(handle), isNull(),
                 eq(isSpeakerphoneOn), eq(videoState));
 
         Bundle expectedExtras = createNumberExtras(handle.getSchemeSpecificPart());
@@ -409,7 +409,7 @@
 
         result.receiver.onReceive(mContext, result.intent);
 
-        verify(mCallsManager).placeOutgoingCall(eq(mCall), eq(handle), isNull(GatewayInfo.class),
+        verify(mCallsManager).placeOutgoingCall(eq(mCall), eq(handle), isNull(),
                 eq(true), eq(VideoProfile.STATE_BIDIRECTIONAL));
     }
 
@@ -427,7 +427,7 @@
 
         Uri encHandle = Uri.fromParts(handle.getScheme(),
                 handle.getSchemeSpecificPart(), null);
-        verify(mCallsManager).placeOutgoingCall(eq(mCall), eq(encHandle), isNull(GatewayInfo.class),
+        verify(mCallsManager).placeOutgoingCall(eq(mCall), eq(encHandle), isNull(),
                 eq(true), eq(VideoProfile.STATE_BIDIRECTIONAL));
     }
 
@@ -448,7 +448,7 @@
         result.receiver.onReceive(mContext, result.intent);
 
         verify(mCallsManager).placeOutgoingCall(eq(mCall), eq(handle),
-                isNotNull(GatewayInfo.class), eq(true), eq(VideoProfile.STATE_BIDIRECTIONAL));
+                isNotNull(), eq(true), eq(VideoProfile.STATE_BIDIRECTIONAL));
     }
 
     @SmallTest
@@ -645,10 +645,10 @@
                 eq(AppOpsManager.OP_PROCESS_OUTGOING_CALLS),
                 any(Bundle.class),
                 receiverCaptor.capture(),
-                isNull(Handler.class),
+                isNull(),
                 eq(Activity.RESULT_OK),
                 eq(number),
-                isNull(Bundle.class));
+                isNull());
 
         Intent capturedIntent = intentCaptor.getValue();
         assertEquals(Intent.ACTION_NEW_OUTGOING_CALL, capturedIntent.getAction());
diff --git a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
index d002739..30a5a19 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
@@ -1990,7 +1990,7 @@
     @SmallTest
     @Test
     public void testGetVoicemailNumberWithNullAccountHandle() throws Exception {
-        when(mFakePhoneAccountRegistrar.getPhoneAccount(isNull(PhoneAccountHandle.class),
+        when(mFakePhoneAccountRegistrar.getPhoneAccount(isNull(),
                 eq(Binder.getCallingUserHandle())))
                 .thenReturn(makePhoneAccount(TEL_PA_HANDLE_CURRENT).build());
         int subId = 58374;