summaryrefslogtreecommitdiff
path: root/packages/SettingsLib/src
diff options
context:
space:
mode:
author MichaƂ Narajowski <narajn@google.com> 2023-03-07 10:09:18 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-03-07 10:09:18 +0000
commit2dbeb96d78f286002269335d3d8e6f87f343dfbc (patch)
tree94744a504b694957014588389254d328ae8cfbf1 /packages/SettingsLib/src
parentd6d15db75e383a59fc309782e00b50b2894476c6 (diff)
parentf9da437a5fcb84346a12bd0fac8659cc8f5dab59 (diff)
CachedBluetoothDevice: Fix detecting connect fail am: f9da437a5f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2465935 Change-Id: If1af40f811dba7ca8d5eadbd61cb90f43a5b5e9d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 07422508910d..fe448fccae3a 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -208,7 +208,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
synchronized (mProfileLock) {
if (profile instanceof A2dpProfile || profile instanceof HeadsetProfile
- || profile instanceof HearingAidProfile) {
+ || profile instanceof HearingAidProfile || profile instanceof LeAudioProfile) {
setProfileConnectedStatus(profile.getProfileId(), false);
switch (newProfileState) {
case BluetoothProfile.STATE_CONNECTED:
@@ -226,7 +226,20 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
case BluetoothProfile.STATE_DISCONNECTED:
if (mHandler.hasMessages(profile.getProfileId())) {
mHandler.removeMessages(profile.getProfileId());
- setProfileConnectedStatus(profile.getProfileId(), true);
+ if (profile.getConnectionPolicy(mDevice) >
+ BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) {
+ /*
+ * If we received state DISCONNECTED and previous state was
+ * CONNECTING and connection policy is FORBIDDEN or UNKNOWN
+ * then it's not really a failure to connect.
+ *
+ * Connection profile is considered as failed when connection
+ * policy indicates that profile should be connected
+ * but it got disconnected.
+ */
+ Log.w(TAG, "onProfileStateChanged(): Failed to connect profile");
+ setProfileConnectedStatus(profile.getProfileId(), true);
+ }
}
break;
default:
@@ -1194,6 +1207,13 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
}
private boolean isProfileConnectedFail() {
+ Log.d(TAG, "anonymizedAddress=" + mDevice.getAnonymizedAddress()
+ + " mIsA2dpProfileConnectedFail=" + mIsA2dpProfileConnectedFail
+ + " mIsHearingAidProfileConnectedFail=" + mIsHearingAidProfileConnectedFail
+ + " mIsLeAudioProfileConnectedFail=" + mIsLeAudioProfileConnectedFail
+ + " mIsHeadsetProfileConnectedFail=" + mIsHeadsetProfileConnectedFail
+ + " isConnectedSapDevice()=" + isConnectedSapDevice());
+
return mIsA2dpProfileConnectedFail || mIsHearingAidProfileConnectedFail
|| (!isConnectedSapDevice() && mIsHeadsetProfileConnectedFail)
|| mIsLeAudioProfileConnectedFail;