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

Commit 62c77931 authored by William Escande's avatar William Escande
Browse files

HAP: offer a way to disable leaudio on some device

Bug: 345826775
Flag: com.android.bluetooth.flags.enable_hap_by_default
Test: m .
Change-Id: I62c8b466a9040d91cd7b5f9a18ebeb728852452d
parent b9819057
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -281,16 +281,23 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback {
        return isLeAudioOnlyGroup(device);
    }

    private static final String SYSPROP_HAP_ENABLED = "bluetooth.profile.hap.enabled_by_default";

    // return true if device support Hearing Access Service and it has not been manually disabled
    private boolean shouldEnableHapByDefault(BluetoothDevice device, ParcelUuid[] uuids) {
        if (!Flags.enableHapByDefault()) {
            Log.i(TAG, "shouldDefaultToHap: Flag enableHapByDefault is disabled");
            Log.i(TAG, "shouldEnableHapByDefault: Flag is disabled");
            return false;
        }

        HapClientService hap = mFactory.getHapClientService();
        if (hap == null) {
            Log.e(TAG, "shouldDefaultToHap: HapClient is null");
            Log.e(TAG, "shouldEnableHapByDefault: No HapClientService");
            return false;
        }

        if (!SystemProperties.getBoolean(SYSPROP_HAP_ENABLED, true)) {
            Log.i(TAG, "shouldEnableHapByDefault: SystemProperty is overridden to false");
            return false;
        }