Confirm managed call when there are ongoing self-managed calls.

When the user places a managed call while there are ongoing self-managed
calls, the system will now display a dialog giving the user the option of
NOT placing the managed call, or placing the managed call and disconnecting
the ongoing self-managed call(s).

This is done by stopping the outgoing call during startOutgoingCall and
bringing up a dialog to confirm whether the user wants to place the call.
If they chose to place the call, ongoing self-mgds calls are disconnected,
the call is added, and the NewutgoingCallBroadcast is sent as usual.

If the user chooses not to start the call, the call is cancelled.

Test: Manual
Bug: 37828805
Change-Id: I8539b0601cf5f324d2fb204485ee0d9bbf03426d
diff --git a/src/com/android/server/telecom/TelecomBroadcastIntentProcessor.java b/src/com/android/server/telecom/TelecomBroadcastIntentProcessor.java
index 5df4451..a51ef73 100644
--- a/src/com/android/server/telecom/TelecomBroadcastIntentProcessor.java
+++ b/src/com/android/server/telecom/TelecomBroadcastIntentProcessor.java
@@ -21,6 +21,8 @@
 import android.os.UserHandle;
 import android.telecom.Log;
 
+import com.android.server.telecom.ui.ConfirmCallDialogActivity;
+
 public final class TelecomBroadcastIntentProcessor {
     /** The action used to send SMS response for the missed call notification. */
     public static final String ACTION_SEND_SMS_FROM_NOTIFICATION =
@@ -48,6 +50,20 @@
     public static final String ACTION_REJECT_FROM_NOTIFICATION =
             "com.android.server.telecom.ACTION_REJECT_FROM_NOTIFICATION";
 
+    /**
+     * The action used to proceed with a call being confirmed via
+     * {@link com.android.server.telecom.ui.ConfirmCallDialogActivity}.
+     */
+    public static final String ACTION_PROCEED_WITH_CALL =
+            "com.android.server.telecom.PROCEED_WITH_CALL";
+
+    /**
+     * The action used to cancel a call being confirmed via
+     * {@link com.android.server.telecom.ui.ConfirmCallDialogActivity}.
+     */
+    public static final String ACTION_CANCEL_CALL =
+            "com.android.server.telecom.CANCEL_CALL";
+
     public static final String EXTRA_USERHANDLE = "userhandle";
 
     private final Context mContext;
@@ -112,6 +128,7 @@
         } else if (ACTION_REJECT_FROM_NOTIFICATION.equals(action)) {
             Log.startSession("TBIP.aRFM");
             try {
+
                 // Reject the current ringing call.
                 Call incomingCall = mCallsManager.getIncomingCallNotifier().getIncomingCall();
                 if (incomingCall != null) {
@@ -120,6 +137,24 @@
             } finally {
                 Log.endSession();
             }
+        } else if (ACTION_PROCEED_WITH_CALL.equals(action)) {
+            Log.startSession("TBIP.aPWC");
+            try {
+                String callId = intent.getStringExtra(
+                        ConfirmCallDialogActivity.EXTRA_OUTGOING_CALL_ID);
+                mCallsManager.confirmPendingCall(callId);
+            } finally {
+                Log.endSession();
+            }
+        } else if (ACTION_CANCEL_CALL.equals(action)) {
+            Log.startSession("TBIP.aCC");
+            try {
+                String callId = intent.getStringExtra(
+                        ConfirmCallDialogActivity.EXTRA_OUTGOING_CALL_ID);
+                mCallsManager.cancelPendingCall(callId);
+            } finally {
+                Log.endSession();
+            }
         }
     }