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

@@ -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,19 +562,15 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
*/
@Override
protected void refresh() {
if (Flags.enableBluetoothProfileToggleVisibilityChecker()) {
ThreadUtils.postOnBackgroundThread(
() -> {
mInvisiblePreferenceKey.set(
FeatureFactory.getFeatureFactory()
.getBluetoothFeatureProvider()
.getInvisibleProfilePreferenceKeys(
mContext, mCachedDevice.getDevice()));
ThreadUtils.postOnMainThread(this::refreshUi);
});
} else {
refreshUi();
}
ThreadUtils.postOnBackgroundThread(
() -> {
mInvisiblePreferenceKey.set(
FeatureFactory.getFeatureFactory()
.getBluetoothFeatureProvider()
.getInvisibleProfilePreferenceKeys(
mContext, mCachedDevice.getDevice()));
ThreadUtils.postOnMainThread(this::refreshUi);
});
}
private void refreshUi() {
@@ -619,13 +605,11 @@ 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) {
Preference pref = mProfilesContainer.getPreference(i);
pref.setVisible(pref.isVisible() && !invisibleKeys.contains(pref.getKey()));
}
Set<String> invisibleKeys = mInvisiblePreferenceKey.get();
if (invisibleKeys != null) {
for (int i = 0; i < mProfilesContainer.getPreferenceCount(); ++i) {
Preference pref = mProfilesContainer.getPreference(i);
pref.setVisible(pref.isVisible() && !invisibleKeys.contains(pref.getKey()));
}
}
}

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,12 +268,13 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
mExtraControlUriLoaded |= controlUri != null;
Uri finalControlUri = controlUri;
getController(SlicePreferenceController.class, controller -> {
controller.setSliceUri(sliceEnabled ? finalControlUri : null);
controller.onStart();
controller.displayPreference(getPreferenceScreen());
});
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

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.
*/