Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15a9f143 authored by Haijie Hong's avatar Haijie Hong
Browse files

Clean up legacy bluetooth setting flags

BUG: 359415806
Test: atest SettingsRoboTests
Flag: EXEMPT clean up
Change-Id: I7c47d80e61cfb0e3b473106e0784cc96ba639452
parent 4cffde01
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -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"
+1 −5
Original line number Diff line number Diff line
@@ -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;
        }
+15 −31
Original line number Diff line number Diff line
@@ -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() {
+9 −16
Original line number Diff line number Diff line
@@ -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.
+2 −22
Original line number Diff line number Diff line
@@ -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();
    }

    /**
Loading