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

Commit 2ab9cb81 authored by Yuyang Huang's avatar Yuyang Huang Committed by Gerrit Code Review
Browse files

Merge "simplify in band ringtone decision" into main

parents 57c43b09 ba6fd213
Loading
Loading
Loading
Loading
+6 −11
Original line number Original line Diff line number Diff line
@@ -2216,17 +2216,10 @@ public class HeadsetService extends ProfileService {
    /** Called from {@link HeadsetClientStateMachine} to update inband ringing status. */
    /** Called from {@link HeadsetClientStateMachine} to update inband ringing status. */
    public void updateInbandRinging(BluetoothDevice device, boolean connected) {
    public void updateInbandRinging(BluetoothDevice device, boolean connected) {
        synchronized (mStateMachines) {
        synchronized (mStateMachines) {
            List<BluetoothDevice> audioConnectableDevices = getConnectedDevices();
            final int enabled;
            final boolean inbandRingingRuntimeDisable = mInbandRingingRuntimeDisable;
            final boolean inbandRingingRuntimeDisable = mInbandRingingRuntimeDisable;


            if (audioConnectableDevices.size() > 1 || isHeadsetClientConnected()) {
            mInbandRingingRuntimeDisable =
                mInbandRingingRuntimeDisable = true;
                    getConnectedDevices().size() > 1 || isHeadsetClientConnected();
                enabled = 0;
            } else {
                mInbandRingingRuntimeDisable = false;
                enabled = 1;
            }


            final boolean updateAll = inbandRingingRuntimeDisable != mInbandRingingRuntimeDisable;
            final boolean updateAll = inbandRingingRuntimeDisable != mInbandRingingRuntimeDisable;


@@ -2236,7 +2229,7 @@ public class HeadsetService extends ProfileService {
                            + " Device="
                            + " Device="
                            + device
                            + device
                            + " enabled="
                            + " enabled="
                            + enabled
                            + !mInbandRingingRuntimeDisable
                            + " connected="
                            + " connected="
                            + connected
                            + connected
                            + " Update all="
                            + " Update all="
@@ -2244,7 +2237,9 @@ public class HeadsetService extends ProfileService {


            StateMachineTask sendBsirTask =
            StateMachineTask sendBsirTask =
                    stateMachine ->
                    stateMachine ->
                            stateMachine.sendMessage(HeadsetStateMachine.SEND_BSIR, enabled);
                            stateMachine.sendMessage(
                                    HeadsetStateMachine.SEND_BSIR,
                                    mInbandRingingRuntimeDisable ? 0 : 1);


            if (updateAll) {
            if (updateAll) {
                doForEachConnectedStateMachine(sendBsirTask);
                doForEachConnectedStateMachine(sendBsirTask);