Merge "[Hide DCK devices] Hide DCK devices from settings app (available devices section)." into main

This commit is contained in:
Ze Li
2024-02-21 08:59:19 +00:00
committed by Android (Google) Code Review

View File

@@ -34,8 +34,10 @@ import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceGroup
import com.android.settings.R
import com.android.settings.dashboard.RestrictedDashboardFragment
import com.android.settings.flags.Flags
import com.android.settingslib.bluetooth.BluetoothCallback
import com.android.settingslib.bluetooth.BluetoothDeviceFilter
import com.android.settingslib.bluetooth.BluetoothUtils
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager
import com.android.settingslib.bluetooth.LocalBluetoothManager
@@ -217,6 +219,14 @@ abstract class DeviceListPreferenceFragment(restrictedKey: String?) :
)
return
}
if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
if (cachedDevice.device.bondState == BluetoothDevice.BOND_BONDED
&& BluetoothUtils.isExclusivelyManagedBluetoothDevice(
prefContext, cachedDevice.device)) {
Log.d(TAG, "Trying to create preference for a exclusively managed device")
return
}
}
// Only add device preference when it's not found in the map and there's no other state
// message showing in the list
val preference = devicePreferenceMap.computeIfAbsent(cachedDevice) {