From ea85e3b2fa402ccef41ca2ddd9be645d86125103 Mon Sep 17 00:00:00 2001 From: SongFerngWang Date: Tue, 6 Jun 2023 19:45:00 +0800 Subject: [PATCH] Add the log and moving it into onResume Since user can open two settings app(one is via settings app button and other one is via quick settings) and user can switch them to foreground by the recent page. If user can goto the deviceDetails at Settings_A and then changes the config value at settings_B, then the user goes back Settings_A to check the UI. If config is in the init, the UI can't refresh the UI. Bug: 285086232 Test: build pass. Change-Id: I2284940eddcd02c543522b60f951c0d8d25775fd --- .../BluetoothDetailsProfilesController.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java index aaedebd7634..17304fd13ed 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java @@ -96,12 +96,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll protected void init(PreferenceScreen screen) { mProfilesContainer = (PreferenceCategory)screen.findPreference(getPreferenceKey()); mProfilesContainer.setLayoutResource(R.layout.preference_bluetooth_profile_category); - mIsLeContactSharingEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI, - SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED, true); - mIsLeAudioToggleEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI, - SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, true) - || DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, - CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false); // Call refresh here even though it will get called later in onResume, to avoid the // list of switches appearing to "pop" into the page. refresh(); @@ -437,6 +431,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll @Override public void onResume() { + updateLeAudioConfig(); for (CachedBluetoothDevice item : mAllOfCachedDevices) { item.registerCallback(this); } @@ -444,6 +439,20 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll refresh(); } + private void updateLeAudioConfig() { + mIsLeContactSharingEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI, + SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED, true); + boolean isLeDeviceDetailEnabled = DeviceConfig.getBoolean( + DeviceConfig.NAMESPACE_SETTINGS_UI, + SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, true); + boolean isLeEnabledByDefault = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, + CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false); + mIsLeAudioToggleEnabled = isLeDeviceDetailEnabled || isLeEnabledByDefault; + Log.d(TAG, "BT_LE_AUDIO_CONTACT_SHARING_ENABLED:" + mIsLeContactSharingEnabled + + ", BT_LE_AUDIO_DEVICE_DETAIL_ENABLED:" + isLeDeviceDetailEnabled + + ", CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT:" + isLeEnabledByDefault); + } + @Override public void onDeviceAttributesChanged() { for (CachedBluetoothDevice item : mAllOfCachedDevices) {