OSDN Git Service

Fix missing connection state changes intent for Hearing Aids
authorStanley Tng <stng@google.com>
Wed, 26 Sep 2018 01:07:41 +0000 (18:07 -0700)
committerHansong Zhang <hsz@google.com>
Mon, 1 Oct 2018 20:39:38 +0000 (13:39 -0700)
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

packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java

index 62f8724..29f2190 100644 (file)
@@ -123,6 +123,14 @@ public class LocalBluetoothProfileManager {
 
         ParcelUuid[] uuids = adapter.getUuids();
 
+        List<Integer> 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<Integer> 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");
     }