24Q3: Remove Flag enable_hide_exclusively_managed_bluetooth_device
Bug: 324475542 Test: atest: com.android.settings.bluetooth.ConnectedBluetoothDeviceUpdaterTest Test: atest: com.android.settings.bluetooth.SavedBluetoothDeviceUpdaterTest Flag: EXEMPT removing com.android.settingslib.flags.enable_hide_exclusively_managed_bluetooth_device Change-Id: Ibcf78a0a72409371557f07f4c42c676d07c0741b
This commit is contained in:
@@ -26,7 +26,6 @@ import androidx.preference.Preference;
|
||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.flags.Flags;
|
||||
|
||||
/**
|
||||
* Controller to maintain connected bluetooth devices
|
||||
@@ -105,14 +104,12 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
|
||||
cachedDevice.getName() + ", isFilterMatched : " + isFilterMatched);
|
||||
}
|
||||
}
|
||||
if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
|
||||
if (BluetoothUtils.isExclusivelyManagedBluetoothDevice(mContext,
|
||||
cachedDevice.getDevice())) {
|
||||
if (DBG) {
|
||||
Log.d(TAG, "isFilterMatched() hide BluetoothDevice with exclusive manager");
|
||||
}
|
||||
return false;
|
||||
if (BluetoothUtils.isExclusivelyManagedBluetoothDevice(mContext,
|
||||
cachedDevice.getDevice())) {
|
||||
if (DBG) {
|
||||
Log.d(TAG, "isFilterMatched() hide BluetoothDevice with exclusive manager");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return isFilterMatched;
|
||||
}
|
||||
|
@@ -40,7 +40,6 @@ import com.android.settingslib.bluetooth.BluetoothUtils
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager
|
||||
import com.android.settingslib.flags.Flags
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -219,13 +218,11 @@ 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
|
||||
}
|
||||
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
|
||||
|
@@ -28,7 +28,6 @@ import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.flags.Flags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -107,16 +106,10 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
||||
+ ", is connected : " + device.isConnected() + ", is profile connected : "
|
||||
+ cachedDevice.isConnected() + ", is exclusively managed : "
|
||||
+ isExclusivelyManaged);
|
||||
if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
|
||||
return device.getBondState() == BluetoothDevice.BOND_BONDED
|
||||
&& (mShowConnectedDevice || (!device.isConnected()
|
||||
&& isDeviceInCachedDevicesList(cachedDevice)))
|
||||
&& !isExclusivelyManaged;
|
||||
} else {
|
||||
return device.getBondState() == BluetoothDevice.BOND_BONDED
|
||||
&& (mShowConnectedDevice || (!device.isConnected()
|
||||
&& isDeviceInCachedDevicesList(cachedDevice)));
|
||||
}
|
||||
return device.getBondState() == BluetoothDevice.BOND_BONDED
|
||||
&& (mShowConnectedDevice || (!device.isConnected()
|
||||
&& isDeviceInCachedDevicesList(cachedDevice)))
|
||||
&& !isExclusivelyManaged;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -34,9 +34,6 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.AudioManager;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
@@ -45,10 +42,8 @@ import com.android.settings.testutils.shadow.ShadowAudioManager;
|
||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
import com.android.settings.testutils.shadow.ShadowCachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.flags.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -69,9 +64,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||
private static final String TEST_EXCLUSIVE_MANAGER = "com.test.manager";
|
||||
|
||||
@Rule
|
||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||
|
||||
@Mock
|
||||
private DashboardFragment mDashboardFragment;
|
||||
@Mock
|
||||
@@ -365,7 +357,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_notExclusiveManagedDevice_addDevice() {
|
||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater
|
||||
@@ -380,7 +371,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_exclusivelyManagedDevice_packageNotInstalled_addDevice()
|
||||
throws Exception {
|
||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||
@@ -398,7 +388,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_exclusivelyManagedDevice_packageNotEnabled_addDevice()
|
||||
throws Exception {
|
||||
ApplicationInfo appInfo = new ApplicationInfo();
|
||||
@@ -417,7 +406,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_exclusivelyManagedDevice_packageInstalledAndEnabled_removePreference()
|
||||
throws Exception {
|
||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||
|
@@ -32,10 +32,6 @@ import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
@@ -44,10 +40,8 @@ import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.flags.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -67,9 +61,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||
private static final String TEST_EXCLUSIVE_MANAGER = "com.test.manager";
|
||||
|
||||
@Rule
|
||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||
|
||||
@Mock
|
||||
private DashboardFragment mDashboardFragment;
|
||||
@Mock
|
||||
@@ -121,29 +112,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
when(mDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_filterMatch_addPreference() {
|
||||
doReturn(BluetoothDevice.BOND_BONDED).when(mBluetoothDevice).getBondState();
|
||||
doReturn(false).when(mBluetoothDevice).isConnected();
|
||||
|
||||
mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
|
||||
|
||||
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_filterNotMatch_removePreference() {
|
||||
doReturn(BluetoothDevice.BOND_NONE).when(mBluetoothDevice).getBondState();
|
||||
doReturn(true).when(mBluetoothDevice).isConnected();
|
||||
|
||||
mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
|
||||
|
||||
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_deviceConnected_removePreference() {
|
||||
when(mBluetoothDevice.isConnected()).thenReturn(true);
|
||||
@@ -317,7 +285,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_notExclusivelyManagedDevice_addDevice() {
|
||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||
cachedDevices.add(mCachedBluetoothDevice);
|
||||
@@ -337,7 +304,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_existingExclusivelyManagedDevice_packageEnabled_removePreference()
|
||||
throws Exception {
|
||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||
@@ -360,7 +326,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_newExclusivelyManagedDevice_packageEnabled_doNotAddPreference()
|
||||
throws Exception {
|
||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||
@@ -383,7 +348,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_exclusivelyManagedDevice_packageNotInstalled_addDevice()
|
||||
throws Exception {
|
||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||
@@ -405,7 +369,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
||||
public void update_exclusivelyManagedDevice_packageNotEnabled_addDevice()
|
||||
throws Exception {
|
||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||
|
Reference in New Issue
Block a user