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

Commit 9dc594b9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Show all devices, including connected ones, into "Previously connected"...

Merge "Show all devices, including connected ones, into "Previously connected" page" into rvc-qpr-dev am: a21c26df

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12493713

Change-Id: I2bd0c2be1c9d9856f568df93339d526d1fed145a
parents 84ac3605 a21c26df
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;

import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.connecteddevice.PreviouslyConnectedDeviceDashboardFragment;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
@@ -42,13 +43,15 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater

    private static final String PREF_KEY = "saved_bt";

    private final boolean mDisplayConnected;

    @VisibleForTesting
    BluetoothAdapter mBluetoothAdapter;

    public SavedBluetoothDeviceUpdater(Context context, DashboardFragment fragment,
            DevicePreferenceCallback devicePreferenceCallback) {
        super(context, fragment, devicePreferenceCallback);

        mDisplayConnected = (fragment instanceof PreviouslyConnectedDeviceDashboardFragment);
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    }

@@ -101,7 +104,8 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater
                    ", is connected : " + device.isConnected() + ", is profile connected : "
                    + cachedDevice.isConnected());
        }
        return device.getBondState() == BluetoothDevice.BOND_BONDED && !device.isConnected();
        return device.getBondState() == BluetoothDevice.BOND_BONDED
                && (mDisplayConnected || !device.isConnected());
    }

    @Override
@@ -109,6 +113,9 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater
        mMetricsFeatureProvider.logClickedPreference(preference, mFragment.getMetricsCategory());
        final CachedBluetoothDevice device = ((BluetoothDevicePreference) preference)
                .getBluetoothDevice();
        if (device.isConnected()) {
            return device.setActive();
        }
        device.connect();
        return true;
    }
+9 −0
Original line number Diff line number Diff line
@@ -144,6 +144,15 @@ public class SavedBluetoothDeviceUpdaterTest {
        verify(mCachedBluetoothDevice).connect();
    }

    @Test
    public void onClick_Preference_connected_setActive() {
        when(mCachedBluetoothDevice.isConnected()).thenReturn(true);

        mBluetoothDeviceUpdater.onPreferenceClick(mPreference);

        verify(mCachedBluetoothDevice).setActive();
    }

    @Test
    public void forceUpdate_findCachedBluetoothDeviceIsMatched_addPreference() {
        final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();