Restructure new outgoing call broadcast logic.
There was an error in the initial implementation which means that
redirection should have happened but it was not. This was not caught until
late when postsubmit staging builds ran the CTS tests.
I have added legacyProcessCall which is the original behavior with no
flags, and made processCall encapsulate the new flagged behavior. This
does dupe the code, but it makes it much clearer to read and provides a
simple path for removing the old code when we remove the flag.
Test: Re-ran Telecom CTS tests with isNewOutgoingCallBroadcastUnblocking
flag off.
Test: Re-ran Telecom CTS tests with isNewOutgoingCallBroadcastUnblocking
flag on.
Test: Re-ran NewOutoingCallIntentBroadcasterTests to verify there was no
behavioral regression
Fixes: 300724616
Change-Id: I9323a4c1e4257e34b50d64d3e59b7ab75432c809
diff --git a/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java b/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
index 2740ff5..5220ec0 100644
--- a/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
+++ b/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
@@ -357,14 +357,57 @@
public void processCall(Call call, CallDisposition disposition) {
mCall = call;
- if (disposition.callImmediately || mFeatureFlags.isNewOutgoingCallBroadcastUnblocking()) {
- boolean speakerphoneOn = mIntent.getBooleanExtra(
- TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
- int videoState = mIntent.getIntExtra(
- TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
- VideoProfile.STATE_AUDIO_ONLY);
- placeOutgoingCallImmediately(mCall, disposition.callingAddress, null,
- speakerphoneOn, videoState);
+
+ // If the new outgoing call broadast doesn't block, trigger the legacy process call
+ // behavior and exit out here.
+ if (!mFeatureFlags.isNewOutgoingCallBroadcastUnblocking()) {
+ legacyProcessCall(disposition);
+ return;
+ }
+ boolean callRedirectionWithService = false;
+ // Only try to do redirection if it was requested and we're not calling immediately.
+ // We can expect callImmediately to be true for emergency calls and voip calls.
+ if (disposition.requestRedirection && !disposition.callImmediately) {
+ CallRedirectionProcessor callRedirectionProcessor = new CallRedirectionProcessor(
+ mContext, mCallsManager, mCall, disposition.callingAddress,
+ mCallsManager.getPhoneAccountRegistrar(),
+ getGateWayInfoFromIntent(mIntent, mIntent.getData()),
+ mIntent.getBooleanExtra(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE,
+ false),
+ mIntent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
+ VideoProfile.STATE_AUDIO_ONLY));
+ /**
+ * If there is an available {@link android.telecom.CallRedirectionService}, use the
+ * {@link CallRedirectionProcessor} to perform call redirection instead of using
+ * broadcasting.
+ */
+ callRedirectionWithService = callRedirectionProcessor
+ .canMakeCallRedirectionWithServiceAsUser(mCall.getAssociatedUser());
+ if (callRedirectionWithService) {
+ callRedirectionProcessor.performCallRedirection(mCall.getAssociatedUser());
+ }
+ }
+
+ // If no redirection was kicked off, place the call now.
+ if (!callRedirectionWithService) {
+ callImmediately(disposition);
+ }
+
+ // Finally, send the non-blocking broadcast if we're supposed to (ie for any non-voip call).
+ if (disposition.sendBroadcast) {
+ UserHandle targetUser = mCall.getAssociatedUser();
+ broadcastIntent(mIntent, disposition.number, false /* receiverRequired */, targetUser);
+ }
+ }
+
+ /**
+ * The legacy non-flagged version of processing a call. Although there is some code duplication
+ * if makes the new flow cleaner to read.
+ * @param disposition
+ */
+ private void legacyProcessCall(CallDisposition disposition) {
+ if (disposition.callImmediately) {
+ callImmediately(disposition);
// Don't return but instead continue and send the ACTION_NEW_OUTGOING_CALL broadcast
// so that third parties can still inspect (but not intercept) the outgoing call. When
@@ -402,6 +445,20 @@
}
/**
+ * Place a call immediately.
+ * @param disposition The disposition; used for retrieving the address of the call.
+ */
+ private void callImmediately(CallDisposition disposition) {
+ boolean speakerphoneOn = mIntent.getBooleanExtra(
+ TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
+ int videoState = mIntent.getIntExtra(
+ TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
+ VideoProfile.STATE_AUDIO_ONLY);
+ placeOutgoingCallImmediately(mCall, disposition.callingAddress, null,
+ speakerphoneOn, videoState);
+ }
+
+ /**
* Sends a new outgoing call ordered broadcast so that third party apps can cancel the
* placement of the call or redirect it to a different number.
*