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

Commit 94deb59d authored by Alice Kuo's avatar Alice Kuo Committed by Automerger Merge Worker
Browse files

Merge "Add LE audio dynamic switch feature" into tm-d1-dev am: cad1f984

parents 363ae7f4 cad1f984
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;
@@ -61,6 +62,11 @@ public class Config {
    private static final String FEATURE_BATTERY = "settings_bluetooth_battery";
    private static long sSupportedMask = 0;

    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 class ProfileConfig {
        Class mClass;
        boolean mSupported;
@@ -159,6 +165,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="
@@ -179,6 +198,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.
     */