Clean up legacy bluetooth setting flags

BUG: 359415806
Test: atest SettingsRoboTests
Flag: EXEMPT clean up
Change-Id: I7c47d80e61cfb0e3b473106e0784cc96ba639452
This commit is contained in:
Haijie Hong
2024-08-20 14:53:17 +08:00
parent 4cffde0188
commit 15a9f1437d
12 changed files with 35 additions and 218 deletions

View File

@@ -8,13 +8,6 @@ flag {
bug: "305636727"
}
flag {
name: "enable_bluetooth_profile_toggle_visibility_checker"
namespace: "pixel_cross_device_control"
description: "Gates whether to enable checker for bluetooth profile toggle visibility"
bug: "321178209"
}
flag {
name: "hide_le_audio_toggle_for_le_audio_only_device"
namespace: "pixel_cross_device_control"

View File

@@ -30,7 +30,6 @@ import android.net.Uri;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.text.TextUtils;
import android.util.Log;
@@ -42,7 +41,6 @@ import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -187,11 +185,9 @@ public class BluetoothDetailsCompanionAppsController extends BluetoothDetailsCon
// If the device is FastPair, remove CDM companion apps.
final BluetoothFeatureProvider bluetoothFeatureProvider = FeatureFactory.getFeatureFactory()
.getBluetoothFeatureProvider();
final boolean sliceEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_SLICE_SETTINGS_ENABLED, true);
final Uri settingsUri = bluetoothFeatureProvider.getBluetoothDeviceSettingsUri(
mCachedDevice.getDevice());
if (sliceEnabled && settingsUri != null) {
if (settingsUri != null) {
container.removeAll();
return;
}

View File

@@ -22,7 +22,6 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import android.sysprop.BluetoothProperties;
import android.text.TextUtils;
import android.util.Log;
@@ -36,7 +35,6 @@ import androidx.preference.SwitchPreferenceCompat;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.flags.Flags;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.bluetooth.A2dpProfile;
@@ -92,7 +90,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
private Set<CachedBluetoothDevice> mCachedDeviceGroup;
private Map<String, List<CachedBluetoothDevice>> mProfileDeviceMap =
new HashMap<String, List<CachedBluetoothDevice>>();
private boolean mIsLeContactSharingEnabled = false;
private boolean mIsLeAudioToggleEnabled = false;
private boolean mIsLeAudioOnlyDevice = false;
@@ -172,10 +169,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
boolean isBusy = deviceList != null
&& deviceList.stream().anyMatch(item -> item.isBusy());
profilePref.setEnabled(!isBusy);
} else if (profile instanceof PbapServerProfile
&& isLeAudioEnabled
&& !mIsLeContactSharingEnabled) {
profilePref.setEnabled(false);
} else {
profilePref.setEnabled(!mCachedDevice.isBusy());
}
@@ -531,15 +524,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
}
private void updateLeAudioConfig() {
mIsLeContactSharingEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED, true);
boolean isLeAudioToggleVisible = SystemProperties.getBoolean(
LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE);
boolean isLeEnabledByDefault =
SystemProperties.getBoolean(LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY, true);
mIsLeAudioToggleEnabled = isLeAudioToggleVisible || isLeEnabledByDefault;
Log.d(TAG, "BT_LE_AUDIO_CONTACT_SHARING_ENABLED:" + mIsLeContactSharingEnabled
+ ", LE_AUDIO_TOGGLE_VISIBLE_PROPERTY:" + isLeAudioToggleVisible
Log.d(TAG, "LE_AUDIO_TOGGLE_VISIBLE_PROPERTY:" + isLeAudioToggleVisible
+ ", LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY:" + isLeEnabledByDefault);
}
@@ -572,7 +562,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
*/
@Override
protected void refresh() {
if (Flags.enableBluetoothProfileToggleVisibilityChecker()) {
ThreadUtils.postOnBackgroundThread(
() -> {
mInvisiblePreferenceKey.set(
@@ -582,9 +571,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
mContext, mCachedDevice.getDevice()));
ThreadUtils.postOnMainThread(this::refreshUi);
});
} else {
refreshUi();
}
}
private void refreshUi() {
@@ -619,7 +605,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
mProfilesContainer.addPreference(preference);
}
if (Flags.enableBluetoothProfileToggleVisibilityChecker()) {
Set<String> invisibleKeys = mInvisiblePreferenceKey.get();
if (invisibleKeys != null) {
for (int i = 0; i < mProfilesContainer.getPreferenceCount(); ++i) {
@@ -628,7 +613,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
}
}
}
}
@Override
public String getPreferenceKey() {

View File

@@ -30,7 +30,6 @@ import android.hardware.input.InputManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.UserManager;
import android.provider.DeviceConfig;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
@@ -50,7 +49,6 @@ import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.bluetooth.ui.view.DeviceDetailsFragmentFormatter;
import com.android.settings.connecteddevice.stylus.StylusDevicesController;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.flags.Flags;
import com.android.settings.inputmethod.KeyboardSettingsPreferenceController;
@@ -232,17 +230,13 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
final BluetoothFeatureProvider featureProvider =
FeatureFactory.getFeatureFactory().getBluetoothFeatureProvider();
final boolean sliceEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_SLICE_SETTINGS_ENABLED, true);
getController(
BlockingPrefWithSliceController.class,
controller ->
controller.setSliceUri(
sliceEnabled
? featureProvider.getBluetoothDeviceSettingsUri(
mCachedDevice.getDevice())
: null));
featureProvider.getBluetoothDeviceSettingsUri(
mCachedDevice.getDevice())));
mManager.getEventManager().registerCallback(mBluetoothCallback);
mBluetoothAdapter.addOnMetadataChangedListener(
@@ -262,8 +256,6 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
private void updateExtraControlUri(int viewWidth) {
BluetoothFeatureProvider featureProvider =
FeatureFactory.getFeatureFactory().getBluetoothFeatureProvider();
boolean sliceEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_SLICE_SETTINGS_ENABLED, true);
Uri controlUri = null;
String uri = featureProvider.getBluetoothDeviceControlUri(mCachedDevice.getDevice());
if (!TextUtils.isEmpty(uri)) {
@@ -276,13 +268,14 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
mExtraControlUriLoaded |= controlUri != null;
Uri finalControlUri = controlUri;
getController(SlicePreferenceController.class, controller -> {
controller.setSliceUri(sliceEnabled ? finalControlUri : null);
getController(
SlicePreferenceController.class,
controller -> {
controller.setSliceUri(finalControlUri);
controller.onStart();
controller.displayPreference(getPreferenceScreen());
});
// Temporarily fix the issue that the page will be automatically scrolled to a wrong
// position when entering the page. This will make sure the bluetooth header is shown on top
// of the page.

View File

@@ -20,7 +20,6 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
import android.provider.DeviceConfig;
import android.text.Editable;
import android.util.Log;
import android.widget.CompoundButton;
@@ -30,7 +29,6 @@ import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.bluetooth.BluetoothPairingDialogFragment.BluetoothPairingDialogListener;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -71,7 +69,6 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
private boolean mPbapAllowed;
private boolean mIsCoordinatedSetMember;
private boolean mIsLeAudio;
private boolean mIsLeContactSharingEnabled;
private boolean mIsLateBonding;
/**
@@ -106,7 +103,6 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
mIsCoordinatedSetMember = false;
mIsLeAudio = false;
mIsLeContactSharingEnabled = true;
if (cachedDevice != null) {
mIsCoordinatedSetMember = cachedDevice.isCoordinatedSetMemberDevice();
@@ -115,13 +111,7 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
mIsLeAudio = true;
}
}
mIsLeContactSharingEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED, true);
Log.d(TAG,
"BT_LE_AUDIO_CONTACT_SHARING_ENABLED is "
+ mIsLeContactSharingEnabled + " isCooridnatedSetMember "
+ mIsCoordinatedSetMember);
Log.d(TAG, "isCooridnatedSetMember: " + mIsCoordinatedSetMember);
}
}
@@ -221,23 +211,13 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
return mIsLeAudio;
}
@VisibleForTesting
boolean isLeContactSharingEnabled() {
return mIsLeContactSharingEnabled;
}
/**
* A method whether the device allows to show the le audio's contact sharing.
*
* @return A boolean whether the device allows to show the contact sharing.
*/
public boolean isContactSharingVisible() {
boolean isContactSharingVisible = !isProfileReady();
// If device do not support the ContactSharing of LE audio device, hiding ContactSharing UI
if (isLeAudio() && !isLeContactSharingEnabled()) {
isContactSharingVisible = false;
}
return isContactSharingVisible;
return !isProfileReady();
}
/**

View File

@@ -18,7 +18,6 @@ package com.android.settings.connecteddevice;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.net.Uri;
import android.provider.DeviceConfig;
import android.text.TextUtils;
import android.util.Log;
@@ -28,7 +27,6 @@ import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.connecteddevice.audiosharing.AudioSharingDevicePreferenceController;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.overlay.SurveyFeatureProvider;
@@ -71,11 +69,6 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
@Override
public void onAttach(Context context) {
super.onAttach(context);
final boolean nearbyEnabled =
DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_NEAR_BY_SUGGESTION_ENABLED,
true);
String callingAppPackageName =
((SettingsActivity) getActivity()).getInitialCallingPackage();
String action = getIntent() != null ? getIntent().getAction() : "";
@@ -94,10 +87,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
use(ConnectedDeviceGroupController.class).init(this);
use(PreviouslyConnectedDevicePreferenceController.class).init(this);
use(SlicePreferenceController.class)
.setSliceUri(
nearbyEnabled
? Uri.parse(getString(R.string.config_nearby_devices_slice_uri))
: null);
.setSliceUri(Uri.parse(getString(R.string.config_nearby_devices_slice_uri)));
use(DiscoverableFooterPreferenceController.class)
.setAlwaysDiscoverable(isAlwaysDiscoverable(callingAppPackageName, action));

View File

@@ -21,23 +21,6 @@ package com.android.settings.core;
* {@link android.provider.DeviceConfig}
*/
public class SettingsUIDeviceConfig {
/**
* {@code true} if slice settings is enabled in BT device detail page
*/
public static final String BT_SLICE_SETTINGS_ENABLED = "bt_slice_settings_enabled";
/**
* {@code true} if advanced header is enabled in BT device detail page
*/
public static final String BT_ADVANCED_HEADER_ENABLED = "bt_advanced_header_enabled";
/**
* {@code true} if near by device suggestion is enabled in connected device page
*/
public static final String BT_NEAR_BY_SUGGESTION_ENABLED = "bt_near_by_suggestion_enabled";
/**
* {@code true} if le audio contact sharing is enabled in BT device detail page
*/
public static final String BT_LE_AUDIO_CONTACT_SHARING_ENABLED =
"bt_le_audio_contact_sharing_enabled";
/**
* {@code true} whether or not event_log for generic actions is enabled. Default is true.
*/

View File

@@ -30,7 +30,6 @@ import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.DeviceConfig;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
@@ -44,7 +43,6 @@ import androidx.preference.PreferenceFragmentCompat;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.flags.Flags;
import com.android.settings.fuelgauge.BatteryMeterView;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
@@ -339,9 +337,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
}
@Test
public void getAvailabilityStatus_untetheredHeadsetWithConfigOn_returnAvailable() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
public void getAvailabilityStatus_untetheredHeadset_returnAvailable() {
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
@@ -350,31 +346,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
}
@Test
public void getAvailabilityStatus_untetheredHeadsetWithConfigOff_returnUnavailable() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "false", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
}
@Test
public void getAvailabilityStatus_notUntetheredHeadsetWithConfigOn_returnUnavailable() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("false".getBytes());
assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
}
@Test
public void getAvailabilityStatus_notUntetheredHeadsetWithConfigOff_returnUnavailable() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "false", true);
public void getAvailabilityStatus_notUntetheredHeadset_returnUnavailable() {
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("false".getBytes());
@@ -393,8 +365,6 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
@Test
public void onStart_isAvailable_registerCallback() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
Set<CachedBluetoothDevice> cacheBluetoothDevices = new HashSet<>();
@@ -424,8 +394,6 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
@Test
public void onStart_isAvailableButNoBluetoothDevice_notNeedToRegisterCallback() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
when(mCachedDevice.getDevice()).thenReturn(null);
@@ -452,8 +420,6 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
@Test
public void onStop_noBluetoothDevice_noNeedToUnregisterCallback() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
when(mCachedDevice.getDevice()).thenReturn(null);
@@ -549,8 +515,6 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
@Test
@EnableFlags(Flags.FLAG_ENABLE_BLUETOOTH_DEVICE_DETAILS_POLISH)
public void enablePolishFlag_renameButtonShown() {
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
.thenReturn("true".getBytes());
Set<CachedBluetoothDevice> cacheBluetoothDevices = new HashSet<>();

View File

@@ -26,7 +26,6 @@ import static org.mockito.Mockito.when;
import android.bluetooth.BluetoothDevice;
import android.graphics.drawable.Drawable;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
@@ -127,24 +126,10 @@ public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsContro
}
@Test
public void isAvailable_untetheredHeadsetWithConfigOn_returnFalse() {
android.provider.DeviceConfig.setProperty(
android.provider.DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
public void isAvailable_untetheredHeadset_returnFalse() {
when(mBluetoothDevice.getMetadata(
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn("true".getBytes());
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_untetheredHeadsetWithConfigOff_returnTrue() {
android.provider.DeviceConfig.setProperty(
android.provider.DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "false", true);
when(mBluetoothDevice.getMetadata(
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn("true".getBytes());
assertThat(mController.isAvailable()).isTrue();
}
}

View File

@@ -554,7 +554,6 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
@Test
public void prefKeyInBlockingList_hideToggle() {
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_BLUETOOTH_PROFILE_TOGGLE_VISIBILITY_CHECKER);
setupDevice(makeDefaultDeviceConfig());
addA2dpProfileToDevice(true, true, true);
@@ -569,7 +568,6 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
@Test
public void prefKeyNotInBlockingList_showToggle() {
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_BLUETOOTH_PROFILE_TOGGLE_VISIBILITY_CHECKER);
setupDevice(makeDefaultDeviceConfig());
addA2dpProfileToDevice(true, true, true);

View File

@@ -30,7 +30,6 @@ import android.content.Context;
import android.content.Intent;
import android.os.Parcel;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
@@ -177,30 +176,11 @@ public class BluetoothPairingControllerTest {
assertThat(mBluetoothPairingController.isLeAudio()).isTrue();
}
@Test
public void isLeContactSharingEnabled_configIsFalse_returnsFalse() {
mockIsLeContactSharingEnabled(false);
mBluetoothPairingController = createBluetoothPairingController();
assertThat(mBluetoothPairingController.isLeContactSharingEnabled()).isFalse();
}
@Test
public void isLeContactSharingEnabled_configIsTrue_returnsTrue() {
mockIsLeContactSharingEnabled(true);
mBluetoothPairingController = createBluetoothPairingController();
assertThat(mBluetoothPairingController.isLeContactSharingEnabled()).isTrue();
}
@Test
public void isContactSharingVisible_profileIsNotReady_returnsTrue() {
// isProfileReady=false, isLeAudio=false, isLeContactSharingEnabled=true
// isProfileReady=false, isLeAudio=false
mockIsProfileReady(false);
mockIsLeAudio(false);
mockIsLeContactSharingEnabled(true);
mBluetoothPairingController = createBluetoothPairingController();
mBluetoothPairingController.mockPbapClientProfile(mPbapLocalBluetoothProfile);
@@ -210,10 +190,9 @@ public class BluetoothPairingControllerTest {
@Test
public void isContactSharingVisible_profileIsReady_returnsFalse() {
// isProfileReady=true, isLeAudio=false, isLeContactSharingEnabled=true
// isProfileReady=true, isLeAudio=false
mockIsProfileReady(true);
mockIsLeAudio(false);
mockIsLeContactSharingEnabled(true);
mBluetoothPairingController = createBluetoothPairingController();
mBluetoothPairingController.mockPbapClientProfile(mPbapLocalBluetoothProfile);
@@ -223,10 +202,9 @@ public class BluetoothPairingControllerTest {
@Test
public void isContactSharingVisible_DeviceIsLeAudioAndProfileIsReady_returnsFalse() {
// isProfileReady=true, isLeAudio=true, isLeContactSharingEnabled=true
// isProfileReady=true, isLeAudio=true
mockIsProfileReady(true);
mockIsLeAudio(true);
mockIsLeContactSharingEnabled(true);
mBluetoothPairingController = createBluetoothPairingController();
mBluetoothPairingController.mockPbapClientProfile(mPbapLocalBluetoothProfile);
@@ -236,10 +214,9 @@ public class BluetoothPairingControllerTest {
@Test
public void isContactSharingVisible_DeviceIsLeAudioAndProfileIsNotReady_returnsTrue() {
// isProfileReady=false, isLeAudio=true, isLeContactSharingEnabled=true
// isProfileReady=false, isLeAudio=true
mockIsProfileReady(false);
mockIsLeAudio(true);
mockIsLeContactSharingEnabled(true);
mBluetoothPairingController = createBluetoothPairingController();
mBluetoothPairingController.mockPbapClientProfile(mPbapLocalBluetoothProfile);
@@ -247,19 +224,6 @@ public class BluetoothPairingControllerTest {
assertThat(mBluetoothPairingController.isContactSharingVisible()).isTrue();
}
@Test
public void isContactSharingVisible_DeviceIsLeAndContactSharingIsNotEnabled_returnsFalse() {
// isProfileReady=false, isLeAudio=true, isLeContactSharingEnabled=false
mockIsProfileReady(false);
mockIsLeAudio(true);
mockIsLeContactSharingEnabled(false);
mBluetoothPairingController = createBluetoothPairingController();
mBluetoothPairingController.mockPbapClientProfile(mPbapLocalBluetoothProfile);
assertThat(mBluetoothPairingController.isContactSharingVisible()).isFalse();
}
private void mockIsProfileReady(boolean mockValue) {
when(mPbapLocalBluetoothProfile.isProfileReady()).thenReturn(mockValue);
}
@@ -271,11 +235,4 @@ public class BluetoothPairingControllerTest {
}
when(mLocalBluetoothProfile.getProfileId()).thenReturn(profileId);
}
private void mockIsLeContactSharingEnabled(boolean mockValue) {
android.provider.DeviceConfig.setProperty(
android.provider.DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED,
/* value= */ mockValue ? "true" : "false", true);
}
}

View File

@@ -28,7 +28,6 @@ import android.platform.test.flag.junit.SetFlagsRule;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.flags.Flags;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
@@ -63,11 +62,6 @@ public class GeneralBluetoothDetailsHeaderControllerTest
public void setUp() {
super.setUp();
FakeFeatureFactory.setupForTest();
android.provider.DeviceConfig.setProperty(
android.provider.DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED,
"true",
true);
mController =
new GeneralBluetoothDetailsHeaderController(
mContext, mFragment, mCachedDevice, mLifecycle);