summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/app/src/com/android/bluetooth/btservice/AdapterService.java15
-rw-r--r--android/app/src/com/android/bluetooth/btservice/Config.java32
-rw-r--r--android/app/src/com/android/bluetooth/le_audio/LeAudioService.java8
3 files changed, 45 insertions, 10 deletions
diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterService.java b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
index f3ad2ea140..e6581c5ad3 100644
--- a/android/app/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
@@ -765,8 +765,9 @@ public class AdapterService extends Service {
nonSupportedProfiles.add(BassClientService.class);
}
- if (isLeAudioBroadcastSourceSupported()) {
- Config.addSupportedProfile(BluetoothProfile.LE_AUDIO_BROADCAST);
+ if (!isLeAudioBroadcastSourceSupported()) {
+ Config.updateSupportedProfileMask(
+ false, LeAudioService.class, BluetoothProfile.LE_AUDIO_BROADCAST);
}
if (!nonSupportedProfiles.isEmpty()) {
@@ -3540,7 +3541,8 @@ public class AdapterService extends Service {
return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
}
- if (service.isLeAudioBroadcastSourceSupported()) {
+ long supportBitMask = Config.getSupportedProfilesBitMask();
+ if ((supportBitMask & (1 << BluetoothProfile.LE_AUDIO_BROADCAST)) != 0) {
return BluetoothStatusCodes.FEATURE_SUPPORTED;
}
@@ -4828,8 +4830,7 @@ public class AdapterService extends Service {
* @return true, if the LE audio broadcast source is supported
*/
public boolean isLeAudioBroadcastSourceSupported() {
- return BluetoothProperties.isProfileBapBroadcastSourceEnabled().orElse(false)
- && mAdapterProperties.isLePeriodicAdvertisingSupported()
+ return mAdapterProperties.isLePeriodicAdvertisingSupported()
&& mAdapterProperties.isLeExtendedAdvertisingSupported()
&& mAdapterProperties.isLeIsochronousBroadcasterSupported();
}
@@ -4846,6 +4847,10 @@ public class AdapterService extends Service {
|| mAdapterProperties.isLePeriodicAdvertisingSyncTransferRecipientSupported());
}
+ public long getSupportedProfilesBitMask() {
+ return Config.getSupportedProfilesBitMask();
+ }
+
/**
* Check if the LE audio CIS central feature is supported.
*
diff --git a/android/app/src/com/android/bluetooth/btservice/Config.java b/android/app/src/com/android/bluetooth/btservice/Config.java
index ce7a3f2d72..07fce6f77d 100644
--- a/android/app/src/com/android/bluetooth/btservice/Config.java
+++ b/android/app/src/com/android/bluetooth/btservice/Config.java
@@ -61,13 +61,14 @@ public class Config {
private static final String FEATURE_HEARING_AID = "settings_bluetooth_hearing_aid";
private static final String FEATURE_BATTERY = "settings_bluetooth_battery";
- private static long sSupportedMask = 0;
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_BROADCAST_DYNAMIC_SWITCH_PROPERTY =
+ "ro.bluetooth.leaudio_broadcast_switcher.supported";
private static final String LE_AUDIO_DYNAMIC_ENABLED_PROPERTY =
"persist.bluetooth.leaudio_switcher.enabled";
@@ -174,6 +175,11 @@ public class Config {
private static boolean sIsGdEnabledUptoScanningLayer = false;
static void init(Context ctx) {
+ if (LeAudioService.isBroadcastEnabled()) {
+ updateSupportedProfileMask(
+ true, LeAudioService.class, BluetoothProfile.LE_AUDIO_BROADCAST);
+ }
+
final boolean leAudioDynamicSwitchSupported =
SystemProperties.getBoolean(LE_AUDIO_DYNAMIC_SWITCH_PROPERTY, false);
@@ -214,6 +220,15 @@ public class Config {
setProfileEnabled(TbsService.class, enable);
setProfileEnabled(McpService.class, enable);
setProfileEnabled(VolumeControlService.class, enable);
+
+ final boolean broadcastDynamicSwitchSupported =
+ SystemProperties.getBoolean(LE_AUDIO_BROADCAST_DYNAMIC_SWITCH_PROPERTY, false);
+
+ if (broadcastDynamicSwitchSupported) {
+ setProfileEnabled(BassClientService.class, enable);
+ updateSupportedProfileMask(
+ enable, LeAudioService.class, BluetoothProfile.LE_AUDIO_BROADCAST);
+ }
}
/**
@@ -235,8 +250,17 @@ public class Config {
sSupportedProfiles = profilesList.toArray(new Class[profilesList.size()]);
}
- static void addSupportedProfile(int supportedProfile) {
- sSupportedMask |= (1 << supportedProfile);
+ static void updateSupportedProfileMask(Boolean enable, Class profile, int supportedProfile) {
+ for (ProfileConfig config : PROFILE_SERVICES_AND_FLAGS) {
+ if (config.mClass == profile) {
+ if (enable) {
+ config.mMask |= 1 << supportedProfile;
+ } else {
+ config.mMask &= ~(1 << supportedProfile);
+ }
+ return;
+ }
+ }
}
static HashSet<Class> getLeAudioUnicastProfiles() {
@@ -262,7 +286,7 @@ public class Config {
}
static long getSupportedProfilesBitMask() {
- long mask = sSupportedMask;
+ long mask = 0;
for (final Class profileClass : getSupportedProfiles()) {
mask |= getProfileMask(profileClass);
}
diff --git a/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java b/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java
index 729aaf1132..931f1069cb 100644
--- a/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java
+++ b/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java
@@ -181,6 +181,10 @@ public class LeAudioService extends ProfileService {
return BluetoothProperties.isProfileBapUnicastClientEnabled().orElse(false);
}
+ public static boolean isBroadcastEnabled() {
+ return BluetoothProperties.isProfileBapBroadcastSourceEnabled().orElse(false);
+ }
+
@Override
protected void create() {
Log.i(TAG, "create()");
@@ -239,7 +243,9 @@ public class LeAudioService extends ProfileService {
LeAudioTmapGattServer.TMAP_ROLE_FLAG_CG | LeAudioTmapGattServer.TMAP_ROLE_FLAG_UMS;
// Initialize Broadcast native interface
- if (mAdapterService.isLeAudioBroadcastSourceSupported()) {
+ if ((mAdapterService.getSupportedProfilesBitMask()
+ & (1 << BluetoothProfile.LE_AUDIO_BROADCAST)) != 0) {
+ Log.i(TAG, "Init Le Audio broadcaster");
mBroadcastCallbacks = new RemoteCallbackList<IBluetoothLeBroadcastCallback>();
mLeAudioBroadcasterNativeInterface = Objects.requireNonNull(
LeAudioBroadcasterNativeInterface.getInstance(),