Loading src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +7 −7 Original line number Diff line number Diff line Loading @@ -69,7 +69,9 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll private static final String ENABLE_DUAL_MODE_AUDIO = "persist.bluetooth.enable_dual_mode_audio"; private static final String CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT = "le_audio_enabled_by_default"; private static final boolean LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE = true; private static final boolean LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE = true; private static final String LE_AUDIO_TOGGLE_VISIBLE_PROPERTY = "persist.bluetooth.leaudio.toggle_visible"; private LocalBluetoothManager mManager; private LocalBluetoothProfileManager mProfileManager; Loading Loading @@ -464,15 +466,13 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll 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, LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE); boolean isLeAudioToggleVisible = SystemProperties.getBoolean( LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE); boolean isLeEnabledByDefault = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false); mIsLeAudioToggleEnabled = isLeDeviceDetailEnabled || isLeEnabledByDefault; mIsLeAudioToggleEnabled = isLeAudioToggleVisible || isLeEnabledByDefault; Log.d(TAG, "BT_LE_AUDIO_CONTACT_SHARING_ENABLED:" + mIsLeContactSharingEnabled + ", BT_LE_AUDIO_DEVICE_DETAIL_ENABLED:" + isLeDeviceDetailEnabled + ", LE_AUDIO_TOGGLE_VISIBLE_PROPERTY:" + isLeAudioToggleVisible + ", CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT:" + isLeEnabledByDefault); } Loading src/com/android/settings/core/SettingsUIDeviceConfig.java +0 −5 Original line number Diff line number Diff line Loading @@ -42,9 +42,4 @@ public class SettingsUIDeviceConfig { * {@code true} whether or not event_log for generic actions is enabled. Default is true. */ public static final String GENERIC_EVENT_LOGGING_ENABLED = "event_logging_enabled"; /** * {@code true} whether to show LE Audio toggle in device detail page. Default is false. */ public static final String BT_LE_AUDIO_DEVICE_DETAIL_ENABLED = "bt_le_audio_device_detail_enabled"; } src/com/android/settings/development/BluetoothLeAudioDeviceDetailsPreferenceController.java +9 −21 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothStatusCodes; import android.content.Context; import android.os.SystemProperties; import android.provider.DeviceConfig; import androidx.annotation.VisibleForTesting; Loading @@ -27,7 +28,6 @@ import androidx.preference.Preference; import androidx.preference.SwitchPreference; import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.SettingsUIDeviceConfig; import com.android.settingslib.development.DeveloperOptionsPreferenceController; /** Loading @@ -40,9 +40,12 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController private static final String PREFERENCE_KEY = "bluetooth_show_leaudio_device_details"; private static final String CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT = "le_audio_enabled_by_default"; private static final boolean LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE = true; private static final boolean LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE = true; static int sLeAudioSupportedStateCache = BluetoothStatusCodes.ERROR_UNKNOWN; static final String LE_AUDIO_TOGGLE_VISIBLE_PROPERTY = "persist.bluetooth.leaudio.toggle_visible"; @VisibleForTesting BluetoothAdapter mBluetoothAdapter; Loading Loading @@ -73,10 +76,7 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean isEnabled = (Boolean) newValue; DeviceConfig.setProperty( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, isEnabled ? "true" : "false", LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE); SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, Boolean.toString(isEnabled)); return true; } Loading @@ -86,25 +86,13 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController return; } final boolean leAudioDeviceDetailEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE); final boolean isLeAudioToggleVisible = SystemProperties.getBoolean( LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE); final boolean leAudioEnabledByDefault = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_BLUETOOTH, CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false); mPreference.setEnabled(!leAudioEnabledByDefault); ((SwitchPreference) mPreference).setChecked(leAudioDeviceDetailEnabled ((SwitchPreference) mPreference).setChecked(isLeAudioToggleVisible || leAudioEnabledByDefault); } @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); // Reset the toggle to null when the developer option is disabled DeviceConfig.setProperty( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "null", LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE); } } tests/robotests/src/com/android/settings/development/BluetoothLeAudioDeviceDetailsPreferenceControllerTest.java +10 −13 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.settings.development; import static com.android.settings.development.BluetoothLeAudioDeviceDetailsPreferenceController .LE_AUDIO_TOGGLE_VISIBLE_PROPERTY; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.spy; Loading @@ -25,12 +28,11 @@ import static org.mockito.Mockito.when; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothStatusCodes; import android.content.Context; import android.provider.DeviceConfig; import android.os.SystemProperties; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import com.android.settings.core.SettingsUIDeviceConfig; import com.android.settings.testutils.shadow.ShadowDeviceConfig; import org.junit.After; Loading Loading @@ -77,9 +79,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceControllerTest { public void onPreferenceChanged_settingEnabled_shouldTurnOnLeAudioDeviceDetailSetting() { mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; mController.onPreferenceChange(mPreference, true /* new value */); final boolean isEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, false); final boolean isEnabled = SystemProperties.getBoolean( LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, false); assertThat(isEnabled).isTrue(); } Loading @@ -88,9 +89,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceControllerTest { public void onPreferenceChanged_settingDisabled_shouldTurnOffLeAudioDeviceDetailSetting() { mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; mController.onPreferenceChange(mPreference, false /* new value */); final boolean isEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, false); final boolean isEnabled = SystemProperties.getBoolean( LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, true); assertThat(isEnabled).isFalse(); } Loading @@ -98,18 +98,15 @@ public class BluetoothLeAudioDeviceDetailsPreferenceControllerTest { @Test public void updateState_settingEnabled_preferenceShouldBeChecked() { mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "true", false); SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, "true"); mController.updateState(mPreference); verify(mPreference).setChecked(true); } @Test public void updateState_settingDisabled_preferenceShouldNotBeChecked() { mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "false", false); SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, "false"); mController.updateState(mPreference); verify(mPreference).setChecked(false); Loading Loading
src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +7 −7 Original line number Diff line number Diff line Loading @@ -69,7 +69,9 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll private static final String ENABLE_DUAL_MODE_AUDIO = "persist.bluetooth.enable_dual_mode_audio"; private static final String CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT = "le_audio_enabled_by_default"; private static final boolean LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE = true; private static final boolean LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE = true; private static final String LE_AUDIO_TOGGLE_VISIBLE_PROPERTY = "persist.bluetooth.leaudio.toggle_visible"; private LocalBluetoothManager mManager; private LocalBluetoothProfileManager mProfileManager; Loading Loading @@ -464,15 +466,13 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll 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, LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE); boolean isLeAudioToggleVisible = SystemProperties.getBoolean( LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE); boolean isLeEnabledByDefault = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false); mIsLeAudioToggleEnabled = isLeDeviceDetailEnabled || isLeEnabledByDefault; mIsLeAudioToggleEnabled = isLeAudioToggleVisible || isLeEnabledByDefault; Log.d(TAG, "BT_LE_AUDIO_CONTACT_SHARING_ENABLED:" + mIsLeContactSharingEnabled + ", BT_LE_AUDIO_DEVICE_DETAIL_ENABLED:" + isLeDeviceDetailEnabled + ", LE_AUDIO_TOGGLE_VISIBLE_PROPERTY:" + isLeAudioToggleVisible + ", CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT:" + isLeEnabledByDefault); } Loading
src/com/android/settings/core/SettingsUIDeviceConfig.java +0 −5 Original line number Diff line number Diff line Loading @@ -42,9 +42,4 @@ public class SettingsUIDeviceConfig { * {@code true} whether or not event_log for generic actions is enabled. Default is true. */ public static final String GENERIC_EVENT_LOGGING_ENABLED = "event_logging_enabled"; /** * {@code true} whether to show LE Audio toggle in device detail page. Default is false. */ public static final String BT_LE_AUDIO_DEVICE_DETAIL_ENABLED = "bt_le_audio_device_detail_enabled"; }
src/com/android/settings/development/BluetoothLeAudioDeviceDetailsPreferenceController.java +9 −21 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothStatusCodes; import android.content.Context; import android.os.SystemProperties; import android.provider.DeviceConfig; import androidx.annotation.VisibleForTesting; Loading @@ -27,7 +28,6 @@ import androidx.preference.Preference; import androidx.preference.SwitchPreference; import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.SettingsUIDeviceConfig; import com.android.settingslib.development.DeveloperOptionsPreferenceController; /** Loading @@ -40,9 +40,12 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController private static final String PREFERENCE_KEY = "bluetooth_show_leaudio_device_details"; private static final String CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT = "le_audio_enabled_by_default"; private static final boolean LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE = true; private static final boolean LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE = true; static int sLeAudioSupportedStateCache = BluetoothStatusCodes.ERROR_UNKNOWN; static final String LE_AUDIO_TOGGLE_VISIBLE_PROPERTY = "persist.bluetooth.leaudio.toggle_visible"; @VisibleForTesting BluetoothAdapter mBluetoothAdapter; Loading Loading @@ -73,10 +76,7 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean isEnabled = (Boolean) newValue; DeviceConfig.setProperty( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, isEnabled ? "true" : "false", LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE); SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, Boolean.toString(isEnabled)); return true; } Loading @@ -86,25 +86,13 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController return; } final boolean leAudioDeviceDetailEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE); final boolean isLeAudioToggleVisible = SystemProperties.getBoolean( LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE); final boolean leAudioEnabledByDefault = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_BLUETOOTH, CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false); mPreference.setEnabled(!leAudioEnabledByDefault); ((SwitchPreference) mPreference).setChecked(leAudioDeviceDetailEnabled ((SwitchPreference) mPreference).setChecked(isLeAudioToggleVisible || leAudioEnabledByDefault); } @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); // Reset the toggle to null when the developer option is disabled DeviceConfig.setProperty( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "null", LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE); } }
tests/robotests/src/com/android/settings/development/BluetoothLeAudioDeviceDetailsPreferenceControllerTest.java +10 −13 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.settings.development; import static com.android.settings.development.BluetoothLeAudioDeviceDetailsPreferenceController .LE_AUDIO_TOGGLE_VISIBLE_PROPERTY; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.spy; Loading @@ -25,12 +28,11 @@ import static org.mockito.Mockito.when; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothStatusCodes; import android.content.Context; import android.provider.DeviceConfig; import android.os.SystemProperties; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import com.android.settings.core.SettingsUIDeviceConfig; import com.android.settings.testutils.shadow.ShadowDeviceConfig; import org.junit.After; Loading Loading @@ -77,9 +79,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceControllerTest { public void onPreferenceChanged_settingEnabled_shouldTurnOnLeAudioDeviceDetailSetting() { mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; mController.onPreferenceChange(mPreference, true /* new value */); final boolean isEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, false); final boolean isEnabled = SystemProperties.getBoolean( LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, false); assertThat(isEnabled).isTrue(); } Loading @@ -88,9 +89,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceControllerTest { public void onPreferenceChanged_settingDisabled_shouldTurnOffLeAudioDeviceDetailSetting() { mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; mController.onPreferenceChange(mPreference, false /* new value */); final boolean isEnabled = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, false); final boolean isEnabled = SystemProperties.getBoolean( LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, true); assertThat(isEnabled).isFalse(); } Loading @@ -98,18 +98,15 @@ public class BluetoothLeAudioDeviceDetailsPreferenceControllerTest { @Test public void updateState_settingEnabled_preferenceShouldBeChecked() { mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "true", false); SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, "true"); mController.updateState(mPreference); verify(mPreference).setChecked(true); } @Test public void updateState_settingDisabled_preferenceShouldNotBeChecked() { mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "false", false); SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, "false"); mController.updateState(mPreference); verify(mPreference).setChecked(false); Loading