Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d39fbe0f authored by hughchen's avatar hughchen
Browse files

Remove all device from preference when BT is disabled

The issue is happened when BT is disabled then navigate to
"Connected devices". BluetoothDeviceUpdater didn't update
UI when BT is disabled. Remove all device from preference when
BT is disabled.

Bug: 80090956
Test: make -j42 RunSettingsRoboTests
Change-Id: Ia1fd8cfbcf95d712a1a702fdf101ff98186b76cd
parent 96b53495
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -115,6 +115,8 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
            for (CachedBluetoothDevice cachedBluetoothDevice : cachedDevices) {
                update(cachedBluetoothDevice);
            }
        } else {
          removeAllDevicesFromPreference();
        }
    }

+5 −2
Original line number Diff line number Diff line
@@ -215,11 +215,14 @@ public class BluetoothDeviceUpdaterTest {
    }

    @Test
    public void forceUpdate_bluetoothDisabled_doNothing() {
    public void forceUpdate_bluetoothDisabled_removeAllDevicesFromPreference() {
        mShadowBluetoothAdapter.setEnabled(false);
        mBluetoothDeviceUpdater.mPreferenceMap.put(mBluetoothDevice, mPreference);

        mBluetoothDeviceUpdater.forceUpdate();

        verify(mDevicePreferenceCallback, never()).onDeviceAdded(any(Preference.class));
        verify(mDevicePreferenceCallback).onDeviceRemoved(mPreference);
        assertThat(mBluetoothDeviceUpdater.mPreferenceMap).isEmpty();
    }

    @Test