Loading src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java +5 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -105,7 +104,6 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater { cachedDevice.getName() + ", isFilterMatched : " + isFilterMatched); } } if (Flags.enableHideExclusivelyManagedBluetoothDevice()) { if (BluetoothUtils.isExclusivelyManagedBluetoothDevice(mContext, cachedDevice.getDevice())) { if (DBG) { Loading @@ -113,7 +111,6 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater { } return false; } } return isFilterMatched; } Loading src/com/android/settings/bluetooth/DeviceListPreferenceFragment.kt +5 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -219,14 +218,12 @@ 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) { Loading src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java +4 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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))); } } @Override Loading tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java +0 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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 Loading Loading @@ -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 Loading @@ -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); Loading @@ -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(); Loading @@ -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); Loading tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java +0 −37 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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); Loading @@ -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<>(); Loading @@ -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<>(); Loading @@ -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<>(); Loading @@ -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<>(); Loading Loading
src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java +5 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -105,7 +104,6 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater { cachedDevice.getName() + ", isFilterMatched : " + isFilterMatched); } } if (Flags.enableHideExclusivelyManagedBluetoothDevice()) { if (BluetoothUtils.isExclusivelyManagedBluetoothDevice(mContext, cachedDevice.getDevice())) { if (DBG) { Loading @@ -113,7 +111,6 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater { } return false; } } return isFilterMatched; } Loading
src/com/android/settings/bluetooth/DeviceListPreferenceFragment.kt +5 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -219,14 +218,12 @@ 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) { Loading
src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java +4 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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))); } } @Override Loading
tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java +0 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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 Loading Loading @@ -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 Loading @@ -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); Loading @@ -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(); Loading @@ -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); Loading
tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java +0 −37 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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); Loading @@ -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<>(); Loading @@ -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<>(); Loading @@ -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<>(); Loading @@ -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<>(); Loading