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

Commit f5fb891e authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Validate profile is enabled if setting device as active for it

Bug: 145004683
Test: Manual
Change-Id: Ieeacf328f5cd13456971d520c7ebd3055ce36a8e
parent 6d136dbb
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -2347,16 +2347,21 @@ public class AdapterService extends Service {
                return false;
        }

        if (setA2dp && mA2dpService != null) {
        if (setA2dp && mA2dpService != null && mA2dpService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
            Log.i(TAG, "setActiveDevice: Setting active A2dp device " + device.getAddress());
            mA2dpService.setActiveDevice(device);
        }

        // Always sets as active device for hearing aid profile
        if (mHearingAidService != null) {
        if (mHearingAidService != null && mHearingAidService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
            Log.i(TAG, "setActiveDevice: Setting active Hearing Aid " + device.getAddress());
            mHearingAidService.setActiveDevice(device);
        }

        if (setHeadset && mHeadsetService != null) {
        if (setHeadset && mHeadsetService != null && mHeadsetService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
            Log.i(TAG, "setActiveDevice: Setting active Headset " + device.getAddress());
            mHeadsetService.setActiveDevice(device);
        }