Bug 993290 - Respond OK after receiving ATDxxx and improve readability on ProcessDialCall(). r=echou
authorJocelyn Liu <joliu@mozilla.com>
Thu, 17 Apr 2014 03:09:00 +0200
changeset 179534 1388fb71fc64afb67c3d4be449bfcc7dbdc97ae5
parent 179533 5453dbdd4897c0602e44677a0c8896978c3096f0
child 179535 3d749ffa6003a3a08e87c272652828b1bd167460
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersechou
bugs993290
milestone31.0a1
Bug 993290 - Respond OK after receiving ATDxxx and improve readability on ProcessDialCall(). r=echou
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -604,45 +604,43 @@ BluetoothHfpManager::ProcessAtChld(bthf_
   BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                       NS_ConvertUTF8toUTF16(message));
   SendResponse(BTHF_AT_RESPONSE_OK);
 }
 
 void BluetoothHfpManager::ProcessDialCall(char *aNumber)
 {
   nsAutoCString message(aNumber);
+
+  // There are three cases based on aNumber,
+  // 1) Empty value:    Redial, BLDN
+  // 2) >xxx:           Memory dial, ATD>xxx
+  // 3) xxx:            Normal dial, ATDxxx
+  // We need to respond OK/Error for dial requests for every case listed above,
+  // 1) and 2):         Respond in either RespondToBLDNTask or
+  //                    HandleCallStateChanged()
+  // 3):                Respond here
   if (message.IsEmpty()) {
-    // Redial: BLDN
     mDialingRequestProcessed = false;
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                         NS_LITERAL_STRING("BLDN"));
+    BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::POST_TASK_RESPOND_TO_BLDN);
+  } else if (message[0] == '>') {
+    mDialingRequestProcessed = false;
+    nsAutoCString newMsg("ATD");
+    newMsg += StringHead(message, message.Length() - 1);
+    BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
+                        NS_ConvertUTF8toUTF16(newMsg));
+    BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::POST_TASK_RESPOND_TO_BLDN);
   } else {
     nsAutoCString newMsg("ATD");
-
-    if (message[0] == '>') {
-      // Memory dial: ATD>xxx
-      mDialingRequestProcessed = false;
-      newMsg += message;
-    } else {
-      // Dial number: ATDxxx
-      int end = message.FindChar(';');
-      if (end < 0) {
-        BT_WARNING("Couldn't get the number to dial");
-        SendResponse(BTHF_AT_RESPONSE_OK);
-        return;
-      }
-      newMsg += nsDependentCSubstring(message, 0, end);
-    }
-
+    newMsg += StringHead(message, message.Length() - 1);
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                         NS_ConvertUTF8toUTF16(newMsg));
-  }
-
-  if (!mDialingRequestProcessed) {
-    BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::POST_TASK_RESPOND_TO_BLDN);
+    SendResponse(BTHF_AT_RESPONSE_OK);
   }
 }
 
 void
 BluetoothHfpManager::ProcessAtCnum()
 {
   if (!mMsisdn.IsEmpty()) {
     nsAutoCString message("+CNUM: ,\"");