Merge 7234358fc68a760f562c211770502025e16862d9 on remote branch
Change-Id: Ie0fea3731b340e6fb75b6d69178b854d61aea83a
diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
index 491a0bb..fa5a525 100644
--- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -2208,6 +2208,37 @@
mNativeInterface.phoneStateChange(mDevice, updateCallState);
mIsCallIndDelay = true;
}
+
+ /* The device is blacklisted for sending incoming call setup
+ * indicator after SCO disconnection and sending active call end
+ * indicator. While the incoming call setup indicator is in queue,
+ * waiting call moved to active state. Send call setup update first
+ * and remove it from queue. Create SCO since SCO might be in
+ * disconnecting/disconnected state */
+ if (mIsBlacklistedDevice &&
+ callState.mNumActive == 1 &&
+ callState.mNumHeld == 0 &&
+ callState.mCallState == HeadsetHalConstants.CALL_STATE_IDLE &&
+ hasMessages(SEND_INCOMING_CALL_IND)) {
+
+ Log.w(TAG, "waiting call moved to active state while incoming call");
+ Log.w(TAG, "setup indicator is in queue. Send it first and create SCO");
+ //remove call setup indicator from queue.
+ removeMessages(SEND_INCOMING_CALL_IND);
+
+ HeadsetCallState incomingCallSetupState =
+ new HeadsetCallState(0, 0, HeadsetHalConstants.CALL_STATE_INCOMING,
+ mSystemInterface.getHeadsetPhoneState().getNumber(),
+ mSystemInterface.getHeadsetPhoneState().getType(),
+ "");
+ mNativeInterface.phoneStateChange(mDevice, incomingCallSetupState);
+
+ if (mDevice.equals(mHeadsetService.getActiveDevice())) {
+ Message m = obtainMessage(CONNECT_AUDIO);
+ m.obj = mDevice;
+ sendMessage(m);
+ }
+ }
}
mStateMachineCallState.mNumActive = callState.mNumActive;
mStateMachineCallState.mNumHeld = callState.mNumHeld;