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

Commit ba6fd213 authored by Yuyang Huang's avatar Yuyang Huang
Browse files

simplify in band ringtone decision

Bug: 346498545
Test: atest HeadsetService
Flag: exempt, no logical change
Change-Id: Ife3777427ad50d3bb8dcd6077cb45606f4ee9942
parent be3d2e85
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -2216,17 +2216,10 @@ public class HeadsetService extends ProfileService {
    /** Called from {@link HeadsetClientStateMachine} to update inband ringing status. */
    public void updateInbandRinging(BluetoothDevice device, boolean connected) {
        synchronized (mStateMachines) {
            List<BluetoothDevice> audioConnectableDevices = getConnectedDevices();
            final int enabled;
            final boolean inbandRingingRuntimeDisable = mInbandRingingRuntimeDisable;

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

            final boolean updateAll = inbandRingingRuntimeDisable != mInbandRingingRuntimeDisable;

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

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

            if (updateAll) {
                doForEachConnectedStateMachine(sendBsirTask);