From 1b5bd091ebe4be7d714d19d5b35d8d7233a7713a Mon Sep 17 00:00:00 2001 From: Zhihai Xu Date: Sat, 19 Oct 2013 23:37:35 -0700 Subject: [PATCH] need persist adding bluetooth MAP profile to profile list in case the settings process being killed bug:11303213 Change-Id: I1f227839931872ba6fdca0b5932a24e0b002ec44 --- .../settings/bluetooth/CachedBluetoothDevice.java | 5 ++--- .../settings/bluetooth/LocalBluetoothProfileManager.java | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index 77a946291af..12637974bfc 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -149,7 +149,6 @@ final class CachedBluetoothDevice implements Comparable { } if (profile instanceof MapProfile) { profile.setPreferred(mDevice, true); - refresh(); } } else if (profile instanceof MapProfile && newProfileState == BluetoothProfile.STATE_DISCONNECTED) { @@ -158,7 +157,6 @@ final class CachedBluetoothDevice implements Comparable { mProfiles.remove(profile); } profile.setPreferred(mDevice, false); - refresh(); } else if (mLocalNapRoleConnected && profile instanceof PanProfile && ((PanProfile) profile).isLocalRoleNap(mDevice) && newProfileState == BluetoothProfile.STATE_DISCONNECTED) { @@ -489,7 +487,8 @@ final class CachedBluetoothDevice implements Comparable { ParcelUuid[] localUuids = mLocalAdapter.getUuids(); if (localUuids == null) return false; - mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles, mLocalNapRoleConnected); + mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles, + mLocalNapRoleConnected, mDevice); if (DEBUG) { Log.e(TAG, "updating profiles for " + mDevice.getAliasName()); diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java index 78d64414360..8fff964878d 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java @@ -321,7 +321,7 @@ final class LocalBluetoothProfileManager { synchronized void updateProfiles(ParcelUuid[] uuids, ParcelUuid[] localUuids, Collection profiles, Collection removedProfiles, - boolean isPanNapConnected) { + boolean isPanNapConnected, BluetoothDevice device) { // Copy previous profile list into removedProfiles removedProfiles.clear(); removedProfiles.addAll(profiles); @@ -367,6 +367,13 @@ final class LocalBluetoothProfileManager { profiles.add(mPanProfile); removedProfiles.remove(mPanProfile); } + + if ((mMapProfile != null) && + (mMapProfile.getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED)) { + profiles.add(mMapProfile); + removedProfiles.remove(mMapProfile); + mMapProfile.setPreferred(device, true); + } } }