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

Commit c80b8183 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Ic0706c46,I410fa2f3 am: 61a05dc6 am: 53adc7ce am: 05aad901

parents c149ed55 05aad901
Loading
Loading
Loading
Loading
+83 −60
Original line number Diff line number Diff line
@@ -288,7 +288,7 @@ class PhonePolicy {
        PanService panService = mFactory.getPanService();
        HearingAidService hearingAidService = mFactory.getHearingAidService();
        LeAudioService leAudioService = mFactory.getLeAudioService();
        CsipSetCoordinatorService csipSetCooridnatorService =
        CsipSetCoordinatorService csipSetCoordinatorService =
             mFactory.getCsipSetCoordinatorService();
        VolumeControlService volumeControlService =
             mFactory.getVolumeControlService();
@@ -296,14 +296,12 @@ class PhonePolicy {
        BassClientService bcService = mFactory.getBassClientService();
        BatteryService batteryService = mFactory.getBatteryService();

        boolean isLeAudioProfileAllowed = false;
        if ((leAudioService != null) && Utils.arrayContains(uuids,
                BluetoothUuid.LE_AUDIO) && (leAudioService.getConnectionPolicy(device)
        boolean isLeAudioProfileAllowed = (leAudioService != null)
                && Utils.arrayContains(uuids, BluetoothUuid.LE_AUDIO)
                && (leAudioService.getConnectionPolicy(device)
                    != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN)
                && mAdapterService.isLeAudioAllowed(device)
                && (sLeAudioEnabledByDefault || isDualModeAudioEnabled())) {
            isLeAudioProfileAllowed = true;
        }
                && (sLeAudioEnabledByDefault || isDualModeAudioEnabled());

        // Set profile priorities only for the profiles discovered on the remote device.
        // This avoids needless auto-connect attempts to profiles non-existent on the remote device
@@ -319,9 +317,10 @@ class PhonePolicy {
            }
        }

        if ((headsetService != null) && ((Utils.arrayContains(uuids, BluetoothUuid.HSP)
                || Utils.arrayContains(uuids, BluetoothUuid.HFP)) && (
                headsetService.getConnectionPolicy(device)
        if ((headsetService != null)
                && ((Utils.arrayContains(uuids, BluetoothUuid.HSP)
                    || Utils.arrayContains(uuids, BluetoothUuid.HFP))
                && (headsetService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN))) {
            if (!isDualModeAudioEnabled() && isLeAudioProfileAllowed) {
                debugLog("clear hfp profile priority for the le audio dual mode device "
@@ -339,9 +338,10 @@ class PhonePolicy {
            }
        }

        if ((a2dpService != null) && (Utils.arrayContains(uuids, BluetoothUuid.A2DP_SINK)
                || Utils.arrayContains(uuids, BluetoothUuid.ADV_AUDIO_DIST)) && (
                a2dpService.getConnectionPolicy(device)
        if ((a2dpService != null)
                && (Utils.arrayContains(uuids, BluetoothUuid.A2DP_SINK)
                    || Utils.arrayContains(uuids, BluetoothUuid.ADV_AUDIO_DIST))
                && (a2dpService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            if (!isDualModeAudioEnabled() && isLeAudioProfileAllowed) {
                debugLog("clear a2dp profile priority for the le audio dual mode device "
@@ -360,12 +360,13 @@ class PhonePolicy {
        }

        // CSIP should be connected prior to LE Audio
        if ((csipSetCooridnatorService != null)
        if ((csipSetCoordinatorService != null)
                && (Utils.arrayContains(uuids, BluetoothUuid.COORDINATED_SET))
                && (csipSetCooridnatorService.getConnectionPolicy(device)
                && (csipSetCoordinatorService.getConnectionPolicy(device)
                        == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            // Always allow CSIP during pairing process regardless of LE audio preference
            if (mAutoConnectProfilesSupported) {
                csipSetCooridnatorService.setConnectionPolicy(device,
                csipSetCoordinatorService.setConnectionPolicy(device,
                        BluetoothProfile.CONNECTION_POLICY_ALLOWED);
            } else {
                mAdapterService.getDatabase().setProfileConnectionPolicy(device,
@@ -375,8 +376,9 @@ class PhonePolicy {
        }

        // If we do not have a stored priority for HFP/A2DP (all roles) then default to on.
        if ((panService != null) && (Utils.arrayContains(uuids, BluetoothUuid.PANU) && (
                panService.getConnectionPolicy(device)
        if ((panService != null)
                && (Utils.arrayContains(uuids, BluetoothUuid.PANU)
                && (panService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)
                && mAdapterService.getResources()
                    .getBoolean(R.bool.config_bluetooth_pan_enable_autoconnect))) {
@@ -388,6 +390,10 @@ class PhonePolicy {
            }
        }

        if ((leAudioService != null)
                && Utils.arrayContains(uuids, BluetoothUuid.LE_AUDIO)
                && (leAudioService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            if (isLeAudioProfileAllowed) {
                debugLog("setting le audio profile priority for device " + device);
                if (mAutoConnectProfilesSupported) {
@@ -397,14 +403,16 @@ class PhonePolicy {
                    mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                            BluetoothProfile.LE_AUDIO, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
                }
        } else if (!sLeAudioEnabledByDefault) {
            debugLog("clear LEA profile priority because dual mode is disabled by default");
            } else {
                debugLog("clear LEA profile priority because LE audio is not allowed");
                mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                        BluetoothProfile.LE_AUDIO, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
            }
        }

        if ((hearingAidService != null) && Utils.arrayContains(uuids,
                BluetoothUuid.HEARING_AID) && (hearingAidService.getConnectionPolicy(device)
        if ((hearingAidService != null)
                && Utils.arrayContains(uuids, BluetoothUuid.HEARING_AID)
                && (hearingAidService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            if (isLeAudioProfileAllowed) {
                debugLog("LE Audio preferred over ASHA for device " + device);
@@ -423,9 +431,11 @@ class PhonePolicy {
            }
        }

        if ((volumeControlService != null) && Utils.arrayContains(uuids,
                BluetoothUuid.VOLUME_CONTROL) && (volumeControlService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_UNKNOWN) && isLeAudioProfileAllowed) {
        if ((volumeControlService != null)
                && Utils.arrayContains(uuids, BluetoothUuid.VOLUME_CONTROL)
                && (volumeControlService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            if (isLeAudioProfileAllowed) {
                debugLog("setting volume control profile priority for device " + device);
                if (mAutoConnectProfilesSupported) {
                    volumeControlService.setConnectionPolicy(device,
@@ -435,27 +445,38 @@ class PhonePolicy {
                            BluetoothProfile.VOLUME_CONTROL,
                            BluetoothProfile.CONNECTION_POLICY_ALLOWED);
                }
        } else if (!sLeAudioEnabledByDefault) {
            } else {
                debugLog("clear VCP priority because dual mode is disabled by default");
                mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                    BluetoothProfile.VOLUME_CONTROL, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
                        BluetoothProfile.VOLUME_CONTROL,
                        BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
            }
        }

        if ((hapClientService != null) && Utils.arrayContains(uuids,
                BluetoothUuid.HAS) && (hapClientService.getConnectionPolicy(device)
        if ((hapClientService != null)
                && Utils.arrayContains(uuids, BluetoothUuid.HAS)
                && (hapClientService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            debugLog("setting hearing access profile priority for device " + device);
            if (isLeAudioProfileAllowed) {
                if (mAutoConnectProfilesSupported) {
                    hapClientService.setConnectionPolicy(device,
                            BluetoothProfile.CONNECTION_POLICY_ALLOWED);
                } else {
                    mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                        BluetoothProfile.HAP_CLIENT, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
                            BluetoothProfile.HAP_CLIENT,
                            BluetoothProfile.CONNECTION_POLICY_ALLOWED);
                }
            } else {
                mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                        BluetoothProfile.HAP_CLIENT,
                        BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
            }
        }

        if ((bcService != null) && Utils.arrayContains(uuids,
                BluetoothUuid.BASS) && (bcService.getConnectionPolicy(device)
        if ((bcService != null)
                && Utils.arrayContains(uuids, BluetoothUuid.BASS)
                && (bcService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            debugLog("setting broadcast assistant profile priority for device " + device);
            if (mAutoConnectProfilesSupported) {
@@ -466,8 +487,10 @@ class PhonePolicy {
                        BluetoothProfile.CONNECTION_POLICY_ALLOWED);
            }
        }
        if ((batteryService != null) && Utils.arrayContains(uuids,
                BluetoothUuid.BATTERY) && (batteryService.getConnectionPolicy(device)

        if ((batteryService != null)
                && Utils.arrayContains(uuids, BluetoothUuid.BATTERY)
                && (batteryService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            debugLog("setting battery profile priority for device " + device);
            if (mAutoConnectProfilesSupported) {