Merge "[Temp bonding] Hide temp bond devices from existing lists" into main
This commit is contained in:
@@ -26,6 +26,7 @@ import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
|||||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
|
import com.android.settingslib.flags.Flags;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
/** Controller to maintain available media Bluetooth devices */
|
/** Controller to maintain available media Bluetooth devices */
|
||||||
@@ -60,6 +61,14 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
|
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
|
||||||
|
// If the device is temporary bond, it shouldn't be shown here.
|
||||||
|
if (Flags.enableTemporaryBondDevicesUi()
|
||||||
|
&& BluetoothUtils.isTemporaryBondDevice(cachedDevice.getDevice())) {
|
||||||
|
Log.d(TAG,
|
||||||
|
"isFilterMatched() Filter out temporary bond device " + cachedDevice.getName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final int currentAudioProfile;
|
final int currentAudioProfile;
|
||||||
|
|
||||||
if (mAudioMode == AudioManager.MODE_RINGTONE
|
if (mAudioMode == AudioManager.MODE_RINGTONE
|
||||||
|
@@ -57,6 +57,14 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
|
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
|
||||||
|
// If the device is temporary bond, it shouldn't be shown here.
|
||||||
|
if (Flags.enableTemporaryBondDevicesUi()
|
||||||
|
&& BluetoothUtils.isTemporaryBondDevice(cachedDevice.getDevice())) {
|
||||||
|
Log.d(TAG,
|
||||||
|
"isFilterMatched() Filter out temporary bond device " + cachedDevice.getName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final int currentAudioProfile;
|
final int currentAudioProfile;
|
||||||
|
|
||||||
if (mAudioMode == AudioManager.MODE_RINGTONE
|
if (mAudioMode == AudioManager.MODE_RINGTONE
|
||||||
|
@@ -29,6 +29,7 @@ import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
|||||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
|
import com.android.settingslib.flags.Flags;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
public class AudioSharingBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
public class AudioSharingBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
||||||
@@ -51,6 +52,14 @@ public class AudioSharingBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
|
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
|
||||||
|
// If the device is temporary bond, it shouldn't be shown here.
|
||||||
|
if (Flags.enableTemporaryBondDevicesUi()
|
||||||
|
&& BluetoothUtils.isTemporaryBondDevice(cachedDevice.getDevice())) {
|
||||||
|
Log.d(TAG,
|
||||||
|
"isFilterMatched() Filter out temporary bond device " + cachedDevice.getName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isFilterMatched = false;
|
boolean isFilterMatched = false;
|
||||||
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
|
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
|
||||||
// If device is LE audio device and has a broadcast source,
|
// If device is LE audio device and has a broadcast source,
|
||||||
|
@@ -68,6 +68,9 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
|
|
||||||
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||||
private static final String TEST_EXCLUSIVE_MANAGER = "com.test.manager";
|
private static final String TEST_EXCLUSIVE_MANAGER = "com.test.manager";
|
||||||
|
private static final String TEMP_BOND_METADATA =
|
||||||
|
"<TEMP_BOND_TYPE>le_audio_sharing</TEMP_BOND_TYPE>";
|
||||||
|
private static final int METADATA_FAST_PAIR_CUSTOMIZED_FIELDS = 25;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||||
@@ -405,6 +408,22 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice);
|
verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI)
|
||||||
|
public void update_temporaryBondDevice_removePreference() {
|
||||||
|
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||||
|
when(mBluetoothDeviceUpdater
|
||||||
|
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||||
|
when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true);
|
||||||
|
when(mBluetoothDevice.getMetadata(METADATA_FAST_PAIR_CUSTOMIZED_FIELDS))
|
||||||
|
.thenReturn(TEMP_BOND_METADATA.getBytes());
|
||||||
|
|
||||||
|
mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
|
||||||
|
|
||||||
|
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||||
|
verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice);
|
||||||
|
}
|
||||||
|
|
||||||
private void setUpDeviceUpdaterWithAudioMode(int audioMode) {
|
private void setUpDeviceUpdaterWithAudioMode(int audioMode) {
|
||||||
mAudioManager.setMode(audioMode);
|
mAudioManager.setMode(audioMode);
|
||||||
mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
|
mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
|
||||||
|
Reference in New Issue
Block a user