Bug 1142390 - Add a flag to identify if the CKPD is the very first AT+CKPD=200 for Bluetooth HSP handling. r=shuang
authorJamin Liu <jaliu@mozilla.com>
Fri, 27 Mar 2015 19:00:41 +0800
changeset 266232 5dee4f3e13bbc728a3da91bab7426d0052696cab
parent 266231 412c50364a2b71498e952dafa2fcbcfd43b724da
child 266233 a7caa7d2b07a21e0a57260e73cc829f1b694fe87
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs1142390
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1142390 - Add a flag to identify if the CKPD is the very first AT+CKPD=200 for Bluetooth HSP handling. r=shuang
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -223,16 +223,17 @@ BluetoothHfpManager::Cleanup()
   mSignal = 0;
 
   mController = nullptr;
 }
 
 void
 BluetoothHfpManager::Reset()
 {
+  mFirstCKPD = false;
   // Phone & Device CIND
   ResetCallArray();
   // Clear Sco state
   mAudioState = HFP_AUDIO_STATE_DISCONNECTED;
   Cleanup();
 }
 
 bool
@@ -1281,16 +1282,18 @@ BluetoothHfpManager::Disconnect(Bluetoot
                                      new DisconnectResultHandler(this));
 }
 
 void
 BluetoothHfpManager::OnConnect(const nsAString& aErrorStr)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
+  mFirstCKPD = true;
+
   /**
    * On the one hand, notify the controller that we've done for outbound
    * connections. On the other hand, we do nothing for inbound connections.
    */
   NS_ENSURE_TRUE_VOID(mController);
 
   mController->NotifyCompletion(aErrorStr);
   mController = nullptr;
@@ -1608,39 +1611,49 @@ BluetoothHfpManager::KeyPressedNotificat
   MOZ_ASSERT(NS_IsMainThread());
 
   bool hasActiveCall =
     (FindFirstCall(nsITelephonyService::CALL_STATE_CONNECTED) > 0);
 
   // Refer to AOSP HeadsetStateMachine.processKeyPressed
   if (FindFirstCall(nsITelephonyService::CALL_STATE_INCOMING)
       && !hasActiveCall) {
-    /**
+    /*
      * Bluetooth HSP spec 4.2.2
      * There is an incoming call, notify Dialer to pick up the phone call
      * and SCO will be established after we get the CallStateChanged event
      * indicating the call is answered successfully.
      */
     NotifyDialer(NS_LITERAL_STRING("ATA"));
   } else if (hasActiveCall) {
     if (!IsScoConnected()) {
-      /**
+      /*
        * Bluetooth HSP spec 4.3
        * If there's no SCO, set up a SCO link.
        */
       ConnectSco();
-    } else {
-      /**
+    } else if (mFirstCKPD) {
+      /*
+       * Bluetooth HSP spec 4.2 & 4.3
+       * The SCO link connection may be set up prior to receiving the AT+CKPD=200
+       * command from the HS.
+       *
+       * Once FxOS initiates a SCO connection before receiving the
+       * AT+CKPD=200, we should ignore this key press.
+       */
+     } else {
+      /*
        * Bluetooth HSP spec 4.5
        * There are two ways to release SCO: sending CHUP to dialer or closing
        * SCO socket directly. We notify dialer only if there is at least one
        * active call.
        */
       NotifyDialer(NS_LITERAL_STRING("CHUP"));
     }
+    mFirstCKPD = false;
   } else {
     // BLDN
     mDialingRequestProcessed = false;
 
     NotifyDialer(NS_LITERAL_STRING("BLDN"));
 
     MessageLoop::current()->PostDelayedTask(FROM_HERE,
                                             new RespondToBLDNTask(),
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h
@@ -204,16 +204,17 @@ private:
   BluetoothHandsfreeNetworkState mService;
   BluetoothHandsfreeServiceType mRoam;
   int mSignal;
 
   int mCurrentVgs;
   int mCurrentVgm;
   bool mReceiveVgsFlag;
   bool mDialingRequestProcessed;
+  bool mFirstCKPD;
   PhoneType mPhoneType;
   nsString mDeviceAddress;
   nsString mMsisdn;
   nsString mOperatorName;
 
   nsTArray<Call> mCurrentCallArray;
   nsAutoPtr<BluetoothRilListener> mListener;
   nsRefPtr<BluetoothProfileController> mController;