From 9589041e1cf63b793e6ecb6702ca1b2b9d98efa6 Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Thu, 16 Jan 2020 18:18:12 +0800 Subject: [PATCH] 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 --- .../contextualcards/slices/BluetoothDevicesSlice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java index aa4d53b7f59..cf1e61fc49f 100644 --- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java +++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java @@ -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()); }