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

Commit 59903618 authored by William Escande's avatar William Escande
Browse files

InCallService: Stop hiding code in setter

When setting the headset or LeCall, it is confusing that the setter is
doing more than setting it.
By inlining the method, we remove this abstraction

Bug: 330247213
Fix: 330247213
Test: atest BluetoothInstrumentationTests:BluetoothInCallServiceTests
Flag: Exempt refactor
Change-Id: Ice096f0c02222b9b88d60fceeeea23d165d95d52
parent 9d9075c8
Loading
Loading
Loading
Loading
+14 −29
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ import com.android.bluetooth.tbs.BluetoothLeCallControlProxy;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -153,13 +152,20 @@ public class BluetoothInCallService extends InCallService {
                public void onServiceConnected(int profile, BluetoothProfile proxy) {
                    synchronized (LOCK) {
                        if (profile == BluetoothProfile.HEADSET) {
                            setBluetoothHeadset(
                                    new BluetoothHeadsetProxy((BluetoothHeadset) proxy));
                            mBluetoothHeadset = new BluetoothHeadsetProxy((BluetoothHeadset) proxy);
                            updateHeadsetWithCallState(true /* force */);
                        } else {
                            setBluetoothLeCallControl(
                                    new BluetoothLeCallControlProxy(
                                            (BluetoothLeCallControl) proxy));
                            mBluetoothLeCallControl =
                                    new BluetoothLeCallControlProxy((BluetoothLeCallControl) proxy);

                            mBluetoothLeCallControl.registerBearer(
                                    TAG,
                                    List.of("tel"),
                                    BluetoothLeCallControl.CAPABILITY_HOLD_CALL,
                                    getNetworkOperator(),
                                    getBearerTechnology(),
                                    mExecutor,
                                    mBluetoothLeCallControlCallback);
                            sendTbsCurrentCallsList();
                        }
                    }
@@ -169,9 +175,9 @@ public class BluetoothInCallService extends InCallService {
                public void onServiceDisconnected(int profile) {
                    synchronized (LOCK) {
                        if (profile == BluetoothProfile.HEADSET) {
                            setBluetoothHeadset(null);
                            mBluetoothHeadset = null;
                        } else {
                            setBluetoothLeCallControl(null);
                            mBluetoothLeCallControl = null;
                        }
                    }
                }
@@ -1377,11 +1383,6 @@ public class BluetoothInCallService extends InCallService {
        return mCallbacks.get(call.getId());
    }

    @VisibleForTesting
    public void setBluetoothHeadset(BluetoothHeadsetProxy bluetoothHeadset) {
        mBluetoothHeadset = bluetoothHeadset;
    }

    @VisibleForTesting
    public BluetoothCall getBluetoothCallById(Integer id) {
        if (mBluetoothCallHashMap.containsKey(id)) {
@@ -1553,22 +1554,6 @@ public class BluetoothInCallService extends InCallService {
        }
    }

    @VisibleForTesting
    public void setBluetoothLeCallControl(BluetoothLeCallControlProxy bluetoothTbs) {
        mBluetoothLeCallControl = bluetoothTbs;

        if ((mBluetoothLeCallControl) != null) {
            mBluetoothLeCallControl.registerBearer(
                    TAG,
                    new ArrayList<String>(Arrays.asList("tel")),
                    BluetoothLeCallControl.CAPABILITY_HOLD_CALL,
                    getNetworkOperator(),
                    getBearerTechnology(),
                    mExecutor,
                    mBluetoothLeCallControlCallback);
        }
    }

    private Integer getTbsCallState(BluetoothCall call) {
        switch (call.getState()) {
            case Call.STATE_ACTIVE: