Adds speakerphone extra to ACTION_DIAL (1/2).

If optional extra EXTRA_SPEAKERPHONE_ON is added
to an ACTION_DIAL intent, the speakerphone will turn
on automatically once the call is connected.

Bug: 6810980
Change-Id: I37ac7737e3b85fa3c8e2d5a87a5a1de157f2da08
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index 5e5f710..5753d18 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -278,8 +278,10 @@
      * @param contactInfo Information about the entity being called.
      * @param gatewayInfo Optional gateway information that can be used to route the call to the
      *         actual dialed handle via a gateway provider. May be null.
+     * @param speakerphoneOn Whether or not to turn the speakerphone on once the call connects.
      */
-    void placeOutgoingCall(Uri handle, ContactInfo contactInfo, GatewayInfo gatewayInfo) {
+    void placeOutgoingCall(Uri handle, ContactInfo contactInfo, GatewayInfo gatewayInfo,
+            boolean speakerphoneOn) {
         final Uri uriHandle = (gatewayInfo == null) ? handle : gatewayInfo.getGatewayHandle();
 
         if (gatewayInfo == null) {
@@ -291,6 +293,7 @@
 
         Call call = new Call(
                 uriHandle, gatewayInfo, false /* isIncoming */, false /* isConference */);
+        call.setStartWithSpeakerphoneOn(speakerphoneOn);
 
         // TODO(santoscordon): Move this to be a part of addCall()
         call.addListener(this);
@@ -505,6 +508,9 @@
         if (mPendingHandoffCalls.contains(call)) {
             completeHandoff(call, true);
         }
+        if (call.getStartWithSpeakerphoneOn()) {
+            setAudioRoute(CallAudioState.ROUTE_SPEAKER);
+        }
     }
 
     void markCallAsOnHold(Call call) {