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

Commit ac30ec7b authored by Alice Kuo's avatar Alice Kuo
Browse files

Add LE audio dynamic switch feature

If the device set ro.bluetooth.leaudio_offload.supported=true and the
device supports LE audio hardware capabilities, the
feature could be switched via developer option

Bug: 233018305
Bug: 233005340
Test: switch LE audio feature, and check LE audio functionality status
Change-Id: I8ada3d9903c87d9f164ddfa80a3957c37b13a1fe
Merged-In: I8ada3d9903c87d9f164ddfa80a3957c37b13a1fe
parent 1762aaf8
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.bluetooth.btservice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.res.Resources;
import android.os.SystemProperties;
import android.util.Log;

import com.android.bluetooth.R;
@@ -66,6 +67,11 @@ public class Config {
    private static final String FFLAG_OVERRIDE_PREFIX = "sys.fflag.override.";
    private static final String PERSIST_PREFIX = "persist." + FFLAG_OVERRIDE_PREFIX;

    private static final String LE_AUDIO_DYNAMIC_SWITCH_PROPERTY =
            "ro.bluetooth.leaudio_switcher.supported";
    private static final String LE_AUDIO_DYNAMIC_ENABLED_PROPERTY =
            "persist.bluetooth.leaudio_switcher.enabled";

    private static final Set<String> PERSISTENT_FLAGS = Set.of(
            FEATURE_HEARING_AID,
            FEATURE_BATTERY
@@ -169,6 +175,19 @@ public class Config {
    private static boolean sIsGdEnabledUptoScanningLayer = false;

    static void init(Context ctx) {
        final boolean leAudioDynamicSwitchSupported =
                SystemProperties.getBoolean(LE_AUDIO_DYNAMIC_SWITCH_PROPERTY, false);

        if (leAudioDynamicSwitchSupported) {
            final String leAudioDynamicEnabled = SystemProperties
                    .get(LE_AUDIO_DYNAMIC_ENABLED_PROPERTY, "none");
            if (leAudioDynamicEnabled.equals("true")) {
                setLeAudioProfileStatus(true);
            } else if (leAudioDynamicEnabled.equals("false")) {
                setLeAudioProfileStatus(false);
            }
        }

        ArrayList<Class> profiles = new ArrayList<>(PROFILE_SERVICES_AND_FLAGS.length);
        for (ProfileConfig config : PROFILE_SERVICES_AND_FLAGS) {
            Log.i(TAG, "init: profile=" + config.mClass.getSimpleName() + ", enabled="
@@ -189,6 +208,15 @@ public class Config {
        sIsGdEnabledUptoScanningLayer = resources.getBoolean(R.bool.enable_gd_up_to_scanning_layer);
    }

    static void setLeAudioProfileStatus(Boolean enable) {
        setProfileEnabled(CsipSetCoordinatorService.class, enable);
        setProfileEnabled(HapClientService.class, enable);
        setProfileEnabled(LeAudioService.class, enable);
        setProfileEnabled(TbsService.class, enable);
        setProfileEnabled(McpService.class, enable);
        setProfileEnabled(VolumeControlService.class, enable);
    }

    /**
     * Remove the input profiles from the supported list.
     */