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

Commit 7da2044d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes If09eee19,Ib177f137 into main

* changes:
  audiodevicebroker: restart SCO audio when disconnected externally
  audioservice: more log for Bluetooth SCO audio
parents 668ae733 0d7f0a69
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -414,7 +414,8 @@ public class AudioDeviceBroker {
        }
        if (!mScoManagedByAudio) {
            boolean isBtScoRequested = isBluetoothScoRequested();
            if (isBtScoRequested && (!wasBtScoRequested || !isBluetoothScoActive())) {
            if (isBtScoRequested && (!wasBtScoRequested || !isBluetoothScoActive()
                    || !mBtHelper.isBluetoothScoRequestedInternally())) {
                if (!mBtHelper.startBluetoothSco(scoAudioMode, eventSource)) {
                    Log.w(TAG, "setCommunicationRouteForClient: failure to start BT SCO for uid: "
                            + uid);
@@ -1148,13 +1149,14 @@ public class AudioDeviceBroker {
    }

    /*package*/ void setBluetoothScoOn(boolean on, String eventSource) {
        if (AudioService.DEBUG_COMM_RTE) {
            Log.v(TAG, "setBluetoothScoOn: " + on + " " + eventSource);
        }
        synchronized (mBluetoothAudioStateLock) {
            boolean isBtScoRequested = isBluetoothScoRequested();
            Log.i(TAG, "setBluetoothScoOn: " + on + ", mBluetoothScoOn: "
                    + mBluetoothScoOn + ", isBtScoRequested: " + isBtScoRequested
                    + ", from: " + eventSource);
            mBluetoothScoOn = on;
            updateAudioHalBluetoothState();
            postUpdateCommunicationRouteClient(isBluetoothScoRequested(), eventSource);
            postUpdateCommunicationRouteClient(isBtScoRequested, eventSource);
        }
    }

+6 −1
Original line number Diff line number Diff line
@@ -378,7 +378,6 @@ public class BtHelper {
    /*package*/ synchronized void onReceiveBtEvent(Intent intent) {
        final String action = intent.getAction();

        Log.i(TAG, "onReceiveBtEvent action: " + action + " mScoAudioState: " + mScoAudioState);
        if (action.equals(BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED)) {
            BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE,
                    android.bluetooth.BluetoothDevice.class);
@@ -405,6 +404,7 @@ public class BtHelper {
    private void onScoAudioStateChanged(int state) {
        boolean broadcast = false;
        int scoAudioState = AudioManager.SCO_AUDIO_STATE_ERROR;
        Log.i(TAG, "onScoAudioStateChanged state: " + state + " mScoAudioState: " + mScoAudioState);
        if (mDeviceBroker.isScoManagedByAudio()) {
            switch (state) {
                case BluetoothHeadset.STATE_AUDIO_CONNECTED:
@@ -488,6 +488,11 @@ public class BtHelper {
                == BluetoothHeadset.STATE_AUDIO_CONNECTED;
    }

    /*package*/ synchronized boolean isBluetoothScoRequestedInternally() {
        return mScoAudioState == SCO_STATE_ACTIVE_INTERNAL
              || mScoAudioState == SCO_STATE_ACTIVATE_REQ;
    }

    // @GuardedBy("mDeviceBroker.mSetModeLock")
    @GuardedBy("AudioDeviceBroker.this.mDeviceStateLock")
    /*package*/ synchronized boolean startBluetoothSco(int scoAudioMode,