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

Commit cce9979f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Cleanup of the setActiveDevice method."

parents 05440d82 0b7e89d0
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -5288,7 +5288,7 @@ public class AdapterService extends Service {
    }

    /**
     * Sets device as the active devices for the profiles passed into the function
     * Sets device as the active devices for the profiles passed into the function.
     *
     * @param device is the remote bluetooth device
     * @param profiles is a constant that references for which profiles we'll be setting the remote
@@ -5322,9 +5322,18 @@ public class AdapterService extends Service {
                return false;
        }

        if (mLeAudioService != null && (device == null

        boolean a2dpSupported = mA2dpService != null && (device == null
                || mA2dpService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        boolean hfpSupported = mHeadsetService != null && (device == null
                || mHeadsetService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        boolean leAudioSupported = mLeAudioService != null && (device == null
                || mLeAudioService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED)) {
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED);

        if (leAudioSupported) {
            Log.i(TAG, "setActiveDevice: Setting active Le Audio device " + device);
            if (device == null) {
                mLeAudioService.removeActiveDevice(false);
@@ -5333,9 +5342,7 @@ public class AdapterService extends Service {
            }
        }

        if (setA2dp && mA2dpService != null && (device == null
                || mA2dpService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED)) {
        if (setA2dp && a2dpSupported) {
            Log.i(TAG, "setActiveDevice: Setting active A2dp device " + device);
            if (device == null) {
                mA2dpService.removeActiveDevice(false);
@@ -5351,9 +5358,7 @@ public class AdapterService extends Service {
            mHearingAidService.setActiveDevice(device);
        }

        if (setHeadset && mHeadsetService != null && (device == null
                || mHeadsetService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED)) {
        if (setHeadset && hfpSupported) {
            Log.i(TAG, "setActiveDevice: Setting active Headset " + device);
            mHeadsetService.setActiveDevice(device);
        }
+3 −1
Original line number Diff line number Diff line
@@ -2375,7 +2375,9 @@ public final class BluetoothAdapter {
    }

    /**
     * Sets device as the active devices for the profiles passed into the function
     * Sets device as the active devices for the use cases passed into the function. Note that in
     * order to make a device active for LE Audio, it must be the active device for audio and
     * phone calls.
     *
     * @param device is the remote bluetooth device
     * @param profiles represents the purpose for which we are setting this as the active device.