summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/bluetooth/CachedBluetoothDevice.java')
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/CachedBluetoothDevice.java33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index 01fd1b2..ef223d5 100644..100755
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -25,6 +25,7 @@ import android.os.ParcelUuid;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
+import android.bluetooth.BluetoothAdapter;
import java.util.ArrayList;
import java.util.Collection;
@@ -118,7 +119,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
Log.d(TAG, "onProfileStateChanged: profile " + profile +
" newProfileState " + newProfileState);
}
-
mProfileConnectionState.put(profile, newProfileState);
if (newProfileState == BluetoothProfile.STATE_CONNECTED) {
if (!mProfiles.contains(profile)) {
@@ -156,6 +156,14 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
for (LocalBluetoothProfile profile : mProfiles) {
disconnect(profile);
}
+ // Disconnect PBAP server in case its connected
+ // This is to ensure all the profiles are disconnected as some CK/Hs do not
+ // disconnect PBAP connection when HF connection is brought down
+ PbapServerProfile PbapProfile = mProfileManager.getPbapProfile();
+ if (PbapProfile.getConnectionStatus(mDevice) == BluetoothProfile.STATE_CONNECTED)
+ {
+ PbapProfile.disconnect(mDevice);
+ }
}
void disconnect(LocalBluetoothProfile profile) {
@@ -184,12 +192,15 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
private void connectWithoutResettingTimer(boolean connectAllProfiles) {
// Try to initialize the profiles if they were not.
if (mProfiles.isEmpty()) {
- if (!updateProfiles()) {
- // If UUIDs are not available yet, connect will be happen
- // upon arrival of the ACTION_UUID intent.
- if (DEBUG) Log.d(TAG, "No profiles. Maybe we will connect later");
- return;
- }
+ // if mProfiles is empty, then do not invoke updateProfiles. This causes a race
+ // condition with carkits during pairing, wherein RemoteDevice.UUIDs have been updated
+ // from bluetooth stack but ACTION.uuid is not sent yet.
+ // Eventually ACTION.uuid will be received which shall trigger the connection of the
+ // various profiles
+ // If UUIDs are not available yet, connect will be happen
+ // upon arrival of the ACTION_UUID intent.
+ Log.d(TAG, "No profiles. Maybe we will connect later");
+ return;
}
// Reset the only-show-one-error-dialog tracking variable
@@ -236,9 +247,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
// Reset the only-show-one-error-dialog tracking variable
mIsConnectingErrorPossible = true;
connectInt(profile);
+ // Refresh the UI based on profile.connect() call
+ refresh();
}
- private void connectInt(LocalBluetoothProfile profile) {
+ synchronized void connectInt(LocalBluetoothProfile profile) {
if (!ensurePaired()) {
return;
}
@@ -283,8 +296,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
}
void unpair() {
- disconnect();
-
int state = getBondState();
if (state == BluetoothDevice.BOND_BONDING) {
@@ -436,7 +447,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
ParcelUuid[] localUuids = mLocalAdapter.getUuids();
if (localUuids == null) return false;
- mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles);
+ mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles, mLocalNapRoleConnected);
if (DEBUG) {
Log.e(TAG, "updating profiles for " + mDevice.getAliasName());