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

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

ActiveDevice: reduce complexity -> reduce nesting

Bug: 328842305
Test: None
Flag: Exempt refactor no-op
Change-Id: I975c4813a5c7141ff7ff7947137cddc69952c6e1
parent c5cbdb77
Loading
Loading
Loading
Loading
+49 −55
Original line number Diff line number Diff line
@@ -982,12 +982,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac

    private boolean setLeAudioActiveDevice(
            @Nullable BluetoothDevice device, boolean hasFallbackDevice) {
        Log.d(
                TAG,
                "setLeAudioActiveDevice("
                        + device
                        + ")"
                        + (device == null ? " hasFallbackDevice=" + hasFallbackDevice : ""));
        Log.d(TAG, "setLeAudioActiveDevice(" + device + ", " + hasFallbackDevice + ")");
        synchronized (mLock) {
            final LeAudioService leAudioService = mFactory.getLeAudioService();
            if (leAudioService == null) {
@@ -1113,7 +1108,10 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
                }
        }
        BluetoothDevice device = mDbManager.getMostRecentlyConnectedDevicesInList(connectedDevices);
        if (device != null) {
        if (device == null) {
            Log.d(TAG, "No fallback devices are found");
            return false;
        }
        if (mAudioManager.getMode() == AudioManager.MODE_NORMAL) {
            if (Objects.equals(a2dpFallbackDevice, device)) {
                Log.d(TAG, "Found an A2DP fallback device: " + device);
@@ -1167,10 +1165,6 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
        return true;
    }

        Log.d(TAG, "No fallback devices are found");
        return false;
    }

    private void resetState() {
        synchronized (mLock) {
            mA2dpConnectedDevices.clear();