From 7a40ecd953d1c0005fc6b030da268d0d863826fa Mon Sep 17 00:00:00 2001 From: Haijie Hong Date: Tue, 16 Jul 2024 14:14:52 +0800 Subject: [PATCH] Determine LeAudio toggle visibility after mIsLeAudioOnlyDevice is initialized Bug: 352431349 Test: atest BluetoothDetailsProfilesControllerTest Flag: com.android.settings.flags.hide_le_audio_toggle_for_le_audio_only_device Change-Id: Ic6a8327f7c8e680a29dfd82407ac8304fc25cf89 --- .../BluetoothDetailsProfilesController.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java index 2e5daeb3c93..91d7a2eb898 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java @@ -182,7 +182,15 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll } if (profile instanceof LeAudioProfile) { - profilePref.setVisible(mIsLeAudioToggleEnabled); + boolean showLeAudioToggle = mIsLeAudioToggleEnabled; + if (Flags.hideLeAudioToggleForLeAudioOnlyDevice() && mIsLeAudioOnlyDevice) { + showLeAudioToggle = false; + Log.d( + TAG, + "Hide LeAudio toggle for LeAudio-only Device: " + + mCachedDevice.getDevice().getAnonymizedAddress()); + } + profilePref.setVisible(showLeAudioToggle); } if (profile instanceof MapProfile) { @@ -526,13 +534,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll boolean isLeEnabledByDefault = SystemProperties.getBoolean(LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY, true); mIsLeAudioToggleEnabled = isLeAudioToggleVisible || isLeEnabledByDefault; - if (Flags.hideLeAudioToggleForLeAudioOnlyDevice() && mIsLeAudioOnlyDevice) { - mIsLeAudioToggleEnabled = false; - Log.d( - TAG, - "Hide LeAudio toggle for LeAudio-only Device: " - + mCachedDevice.getDevice().getAnonymizedAddress()); - } Log.d(TAG, "BT_LE_AUDIO_CONTACT_SHARING_ENABLED:" + mIsLeContactSharingEnabled + ", LE_AUDIO_TOGGLE_VISIBLE_PROPERTY:" + isLeAudioToggleVisible + ", LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY:" + isLeEnabledByDefault);