[Audiosharing] Enable audio sharing feature when preview option on.

Test: atest
Bug: 368401233
Flag: com.android.settingslib.flags.audio_sharing_developer_option
Change-Id: I41ad6c570a6c42c498efe5a9a261d929aeff2da6
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
index 0dc772a..ebd5a1d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
@@ -224,7 +224,7 @@
         // audio sharing is enabled.
         if (bluetoothProfile == BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT
                 && state == BluetoothAdapter.STATE_DISCONNECTED
-                && BluetoothUtils.isAudioSharingEnabled()) {
+                && BluetoothUtils.isAudioSharingUIAvailable(mContext)) {
             LocalBluetoothProfileManager profileManager = mBtManager.getProfileManager();
             if (profileManager != null
                     && profileManager.getLeAudioBroadcastProfile() != null
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 8641f70..d0827b3 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -1245,7 +1245,7 @@
      */
     public String getConnectionSummary(boolean shortSummary) {
         CharSequence summary = null;
-        if (BluetoothUtils.isAudioSharingEnabled()) {
+        if (BluetoothUtils.isAudioSharingUIAvailable(mContext)) {
             if (mBluetoothManager == null) {
                 mBluetoothManager = LocalBluetoothManager.getInstance(mContext, null);
             }
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java
index b9f16ed..4b7cb36 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java
@@ -383,11 +383,7 @@
                 preferredMainDevice.refresh();
                 hasChanged = true;
             }
-            if (isWorkProfile()) {
-                log("addMemberDevicesIntoMainDevice: skip sync source for work profile");
-            } else {
-                syncAudioSharingSourceIfNeeded(preferredMainDevice);
-            }
+            syncAudioSharingSourceIfNeeded(preferredMainDevice);
         }
         if (hasChanged) {
             log("addMemberDevicesIntoMainDevice: After changed, CachedBluetoothDevice list: "
@@ -402,8 +398,12 @@
     }
 
     private void syncAudioSharingSourceIfNeeded(CachedBluetoothDevice mainDevice) {
-        boolean isAudioSharingEnabled = BluetoothUtils.isAudioSharingEnabled();
+        boolean isAudioSharingEnabled = BluetoothUtils.isAudioSharingUIAvailable(mContext);
         if (isAudioSharingEnabled) {
+            if (isWorkProfile()) {
+                log("addMemberDevicesIntoMainDevice: skip sync source for work profile");
+                return;
+            }
             boolean hasBroadcastSource = BluetoothUtils.isBroadcasting(mBtManager)
                     && BluetoothUtils.hasConnectedBroadcastSource(
                     mainDevice, mBtManager);
@@ -433,6 +433,8 @@
                     }
                 }
             }
+        } else {
+            log("addMemberDevicesIntoMainDevice: skip sync source, flag disabled");
         }
     }