Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a502268d authored by Ugo Yu's avatar Ugo Yu
Browse files

SCO: Don't set active device if a diconnect message is defered

- Fix a pin-pon scenario in HeadsetService.
- If a headset B is set as active deivce while headset A is connecting SCO,
  HeadsetService request headset A's state machine to do disconnect SCO.
- However, when state machine is at AudioConnecting state, DISCONNECT_AUDIO
  would be pending in defered meesage queue and will be handled in next state.
- Once headset A entered AndioOn state, it set it self to as active device again
  then start handling DISCONNECT_AUDIO.
- After headset A finally disconnect SCO, HeadsetService won't reconnect
  it and rout to headset B since active device is still headset A.
- Active deivce would be like A->B->A, and no device SCO stay connected.

Bug: 110642515
Test: Manual test, make a call and switch path A->speaker->B on phone UI

Change-Id: I7dde255c2ba9f04aec86b7fdd30e7bfadfdd5068
(cherry picked from commit aebfbb7e35ca4cafaa9167d74a37fdb9bc8f62bc)
parent 1be84338
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1201,7 +1201,8 @@ public class HeadsetStateMachine extends StateMachine {
            // Set active device to current active SCO device when the current active device
            // is different from mCurrentDevice. This is to accommodate active device state
            // mis-match between native and Java.
            if (!mDevice.equals(mHeadsetService.getActiveDevice())) {
            if (!mDevice.equals(mHeadsetService.getActiveDevice())
                    && !hasDeferredMessages(DISCONNECT_AUDIO)) {
                mHeadsetService.setActiveDevice(mDevice);
            }
            setAudioParameters();