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.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.flags.Flags;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller to maintain connected bluetooth devices
|
* Controller to maintain connected bluetooth devices
|
||||||
@@ -105,7 +104,6 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
|
|||||||
cachedDevice.getName() + ", isFilterMatched : " + isFilterMatched);
|
cachedDevice.getName() + ", isFilterMatched : " + isFilterMatched);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
|
|
||||||
if (BluetoothUtils.isExclusivelyManagedBluetoothDevice(mContext,
|
if (BluetoothUtils.isExclusivelyManagedBluetoothDevice(mContext,
|
||||||
cachedDevice.getDevice())) {
|
cachedDevice.getDevice())) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
@@ -113,7 +111,6 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return isFilterMatched;
|
return isFilterMatched;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,6 @@ import com.android.settingslib.bluetooth.BluetoothUtils
|
|||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager
|
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager
|
import com.android.settingslib.bluetooth.LocalBluetoothManager
|
||||||
import com.android.settingslib.flags.Flags
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -219,14 +218,12 @@ abstract class DeviceListPreferenceFragment(restrictedKey: String?) :
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
|
|
||||||
if (cachedDevice.device.bondState == BluetoothDevice.BOND_BONDED
|
if (cachedDevice.device.bondState == BluetoothDevice.BOND_BONDED
|
||||||
&& BluetoothUtils.isExclusivelyManagedBluetoothDevice(
|
&& BluetoothUtils.isExclusivelyManagedBluetoothDevice(
|
||||||
prefContext, cachedDevice.device)) {
|
prefContext, cachedDevice.device)) {
|
||||||
Log.d(TAG, "Trying to create preference for a exclusively managed device")
|
Log.d(TAG, "Trying to create preference for a exclusively managed device")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Only add device preference when it's not found in the map and there's no other state
|
// Only add device preference when it's not found in the map and there's no other state
|
||||||
// message showing in the list
|
// message showing in the list
|
||||||
val preference = devicePreferenceMap.computeIfAbsent(cachedDevice) {
|
val preference = devicePreferenceMap.computeIfAbsent(cachedDevice) {
|
||||||
|
@@ -28,7 +28,6 @@ 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.CachedBluetoothDeviceManager;
|
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||||
import com.android.settingslib.flags.Flags;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -107,16 +106,10 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
|||||||
+ ", is connected : " + device.isConnected() + ", is profile connected : "
|
+ ", is connected : " + device.isConnected() + ", is profile connected : "
|
||||||
+ cachedDevice.isConnected() + ", is exclusively managed : "
|
+ cachedDevice.isConnected() + ", is exclusively managed : "
|
||||||
+ isExclusivelyManaged);
|
+ isExclusivelyManaged);
|
||||||
if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
|
|
||||||
return device.getBondState() == BluetoothDevice.BOND_BONDED
|
return device.getBondState() == BluetoothDevice.BOND_BONDED
|
||||||
&& (mShowConnectedDevice || (!device.isConnected()
|
&& (mShowConnectedDevice || (!device.isConnected()
|
||||||
&& isDeviceInCachedDevicesList(cachedDevice)))
|
&& isDeviceInCachedDevicesList(cachedDevice)))
|
||||||
&& !isExclusivelyManaged;
|
&& !isExclusivelyManaged;
|
||||||
} else {
|
|
||||||
return device.getBondState() == BluetoothDevice.BOND_BONDED
|
|
||||||
&& (mShowConnectedDevice || (!device.isConnected()
|
|
||||||
&& isDeviceInCachedDevicesList(cachedDevice)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -34,9 +34,6 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.AudioManager;
|
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 android.util.Pair;
|
||||||
|
|
||||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
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.ShadowBluetoothAdapter;
|
||||||
import com.android.settings.testutils.shadow.ShadowCachedBluetoothDeviceManager;
|
import com.android.settings.testutils.shadow.ShadowCachedBluetoothDeviceManager;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.flags.Flags;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
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 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";
|
||||||
|
|
||||||
@Rule
|
|
||||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DashboardFragment mDashboardFragment;
|
private DashboardFragment mDashboardFragment;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -365,7 +357,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_notExclusiveManagedDevice_addDevice() {
|
public void update_notExclusiveManagedDevice_addDevice() {
|
||||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||||
when(mBluetoothDeviceUpdater
|
when(mBluetoothDeviceUpdater
|
||||||
@@ -380,7 +371,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_exclusivelyManagedDevice_packageNotInstalled_addDevice()
|
public void update_exclusivelyManagedDevice_packageNotInstalled_addDevice()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||||
@@ -398,7 +388,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_exclusivelyManagedDevice_packageNotEnabled_addDevice()
|
public void update_exclusivelyManagedDevice_packageNotEnabled_addDevice()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
ApplicationInfo appInfo = new ApplicationInfo();
|
ApplicationInfo appInfo = new ApplicationInfo();
|
||||||
@@ -417,7 +406,6 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_exclusivelyManagedDevice_packageInstalledAndEnabled_removePreference()
|
public void update_exclusivelyManagedDevice_packageInstalledAndEnabled_removePreference()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||||
|
@@ -32,10 +32,6 @@ import android.content.Context;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.drawable.Drawable;
|
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 android.util.Pair;
|
||||||
|
|
||||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
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.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.flags.Flags;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
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 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";
|
||||||
|
|
||||||
@Rule
|
|
||||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DashboardFragment mDashboardFragment;
|
private DashboardFragment mDashboardFragment;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -121,29 +112,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
|||||||
when(mDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
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
|
@Test
|
||||||
public void onProfileConnectionStateChanged_deviceConnected_removePreference() {
|
public void onProfileConnectionStateChanged_deviceConnected_removePreference() {
|
||||||
when(mBluetoothDevice.isConnected()).thenReturn(true);
|
when(mBluetoothDevice.isConnected()).thenReturn(true);
|
||||||
@@ -317,7 +285,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_notExclusivelyManagedDevice_addDevice() {
|
public void update_notExclusivelyManagedDevice_addDevice() {
|
||||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||||
cachedDevices.add(mCachedBluetoothDevice);
|
cachedDevices.add(mCachedBluetoothDevice);
|
||||||
@@ -337,7 +304,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_existingExclusivelyManagedDevice_packageEnabled_removePreference()
|
public void update_existingExclusivelyManagedDevice_packageEnabled_removePreference()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||||
@@ -360,7 +326,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_newExclusivelyManagedDevice_packageEnabled_doNotAddPreference()
|
public void update_newExclusivelyManagedDevice_packageEnabled_doNotAddPreference()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||||
@@ -383,7 +348,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_exclusivelyManagedDevice_packageNotInstalled_addDevice()
|
public void update_exclusivelyManagedDevice_packageNotInstalled_addDevice()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||||
@@ -405,7 +369,6 @@ public class SavedBluetoothDeviceUpdaterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
|
|
||||||
public void update_exclusivelyManagedDevice_packageNotEnabled_addDevice()
|
public void update_exclusivelyManagedDevice_packageNotEnabled_addDevice()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||||
|
Reference in New Issue
Block a user