Add bond state checking into BluetoothDevicesSlice

Make the Bluetooth device connected checking to be consistent with
BluetoothDeviceUpdater. Because it's more safe to check the bond state
and connected state together to handle abnoraml status from Bluetooth.

Fixes: 147351883
Test: visual, robotests
Change-Id: I4e34b73f16b44972fbb7273a5e13be1f3096835e
This commit is contained in:
Yanting Yang
2020-01-16 18:18:12 +08:00
parent 69a7e054f5
commit 9589041e1c

View File

@@ -19,6 +19,7 @@ package com.android.settings.homepage.contextualcards.slices;
import android.app.PendingIntent;
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -184,7 +185,8 @@ public class BluetoothDevicesSlice implements CustomSliceable {
// Get all connected devices and sort them.
return cachedDevices.stream()
.filter(device -> device.getDevice().isConnected())
.filter(device -> device.getDevice().getBondState() == BluetoothDevice.BOND_BONDED
&& device.getDevice().isConnected())
.sorted(COMPARATOR).collect(Collectors.toList());
}