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

Commit fc8af42b authored by Ugo Yu's avatar Ugo Yu Committed by Eric Shih
Browse files

Reject SCO connection for HFP if HFPC is connected

- To prevent HFP and HFPC try to establish SCO at the same time.
- A property is added to enable this behavior

Bug: 284104022
Test: atest BluetoothInstrumentationTests
Change-Id: Ic6c02fcfa7b4a2d7072a4bd50f691675607e4404
(cherry picked from commit ba4f7cf654e7dd8678fb8da4365043b0746dd50c)
parent 5e12b233
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ public class HeadsetService extends ProfileService {

    private static final String DISABLE_INBAND_RINGING_PROPERTY =
            "persist.bluetooth.disableinbandringing";
    private static final String REJECT_SCO_IF_HFPC_CONNECTED_PROPERTY =
            "bluetooth.hfp.reject_sco_if_hfpc_connected";
    private static final ParcelUuid[] HEADSET_UUIDS = {BluetoothUuid.HSP, BluetoothUuid.HFP};
    private static final int[] CONNECTING_CONNECTED_STATES =
            {BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_CONNECTED};
@@ -2208,6 +2210,11 @@ public class HeadsetService extends ProfileService {
                        + " is not the current active device " + mActiveDevice);
                return BluetoothStatusCodes.ERROR_NOT_ACTIVE_DEVICE;
            }
            if (SystemProperties.getBoolean(REJECT_SCO_IF_HFPC_CONNECTED_PROPERTY, false)
                    && isHeadsetClientConnected()) {
                Log.w(TAG, "isScoAcceptable: rejected SCO since HFPC is connected!");
                return BluetoothStatusCodes.ERROR_AUDIO_ROUTE_BLOCKED;
            }
            if (mForceScoAudio) {
                return BluetoothStatusCodes.SUCCESS;
            }