From c6f5643d966850a023ff9cae8af38b395898839b Mon Sep 17 00:00:00 2001 From: Stanley Tng Date: Tue, 25 Sep 2018 18:07:41 -0700 Subject: [PATCH] Fix missing connection state changes intent for Hearing Aids In some corner cases, the intent receiver for hearing aids CONNECTION_STATE_CHANGED is not registered. This fixes this problem. We need to check hearing aid profile before updateLocalProfile(). Note: This has been totally fixed in master in refactoring code. Bug: 116317072 Bug: 116044083 Bug: 116643085 Test: Manual tests with one Hearing Aid device and in Settings-Device details page. Change-Id: I20bf6b9fe929cd8753a20b8112e66467e560f6df Merged-In: Id2dc364dfa815e72db91b92bcee9745e6c40d34a --- .../bluetooth/LocalBluetoothProfileManager.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java index 62f8724870e3..29f21908f20d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java @@ -123,6 +123,14 @@ public class LocalBluetoothProfileManager { ParcelUuid[] uuids = adapter.getUuids(); + List supportedList = mLocalAdapter.getSupportedProfiles(); + if (supportedList.contains(BluetoothProfile.HEARING_AID)) { + mHearingAidProfile = new HearingAidProfile(mContext, mLocalAdapter, mDeviceManager, + this); + addProfile(mHearingAidProfile, HearingAidProfile.NAME, + BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED); + } + // uuids may be null if Bluetooth is turned off if (uuids != null) { updateLocalProfiles(uuids); @@ -159,13 +167,6 @@ public class LocalBluetoothProfileManager { addProfile(mPbapProfile, PbapServerProfile.NAME, BluetoothPbap.ACTION_CONNECTION_STATE_CHANGED); - List supportedList = mLocalAdapter.getSupportedProfiles(); - if (supportedList.contains(BluetoothProfile.HEARING_AID)) { - mHearingAidProfile = new HearingAidProfile(mContext, mLocalAdapter, mDeviceManager, - this); - addProfile(mHearingAidProfile, HearingAidProfile.NAME, - BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED); - } if (DEBUG) Log.d(TAG, "LocalBluetoothProfileManager construction complete"); } -- 2.11.0