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

Commit 756b66cf authored by Dhanalakshmi Siddani's avatar Dhanalakshmi Siddani Committed by Steve Kondik
Browse files

Audio: SetForceUse config check in AudioService

 - Audio is routed to headset when BT is turned off while audio is
   played on speaker
 - Mediarouter does not have setForce device information when app forces
   audio to speaker. So while disconnecting BT, MediaRouter is routing
   audio to headset instead of speaker.
 - Added check for setforce config in AudioService.

 CRs-Fixed: 578316

Change-Id: Ie929f407bfa12eacd29cf36031024a4a6a979b63
parent 32079aba
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
@@ -2038,10 +2038,19 @@ public class AudioService extends IAudioService.Stub {
    /** @see AudioManager#setBluetoothA2dpOn(boolean) */
    /** @see AudioManager#setBluetoothA2dpOn(boolean) */
    public void setBluetoothA2dpOn(boolean on) {
    public void setBluetoothA2dpOn(boolean on) {
        synchronized (mBluetoothA2dpEnabledLock) {
        synchronized (mBluetoothA2dpEnabledLock) {
           int config = AudioSystem.FORCE_NONE;
           mBluetoothA2dpEnabled = on;
           mBluetoothA2dpEnabled = on;
           config = AudioSystem.getForceUse(AudioSystem.FOR_MEDIA);
           if((config == AudioSystem.FORCE_BT_A2DP) && (!mBluetoothA2dpEnabled)) {
               config = AudioSystem.FORCE_NO_BT_A2DP;
           } else if(mBluetoothA2dpEnabled) {
               config = AudioSystem.FORCE_NONE;
           }
           Log.d(TAG, "BTEnabled "+mBluetoothA2dpEnabled+" config "+config);

            sendMsg(mAudioHandler, MSG_SET_FORCE_BT_A2DP_USE, SENDMSG_QUEUE,
            sendMsg(mAudioHandler, MSG_SET_FORCE_BT_A2DP_USE, SENDMSG_QUEUE,
                    AudioSystem.FOR_MEDIA,
                    AudioSystem.FOR_MEDIA,
                    mBluetoothA2dpEnabled ? AudioSystem.FORCE_NONE : AudioSystem.FORCE_NO_BT_A2DP,
                    config,
                    null, 0);
                    null, 0);
        }
        }
    }
    }