summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/bluetooth/LocalBluetoothDevice.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/bluetooth/LocalBluetoothDevice.java')
-rw-r--r--src/com/android/settings/bluetooth/LocalBluetoothDevice.java56
1 files changed, 35 insertions, 21 deletions
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothDevice.java b/src/com/android/settings/bluetooth/LocalBluetoothDevice.java
index 5c79761..5259d7b 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothDevice.java
@@ -16,9 +16,6 @@
package com.android.settings.bluetooth;
-import com.android.settings.R;
-import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
-
import android.app.AlertDialog;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
@@ -32,6 +29,9 @@ import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
+import com.android.settings.R;
+import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
+
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -210,32 +210,46 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
return successful;
}
- public void onProfileStateChanged() {
+ public void onProfileStateChanged(Profile profile, int newProfileState) {
if (D) {
Log.d(TAG, "onProfileStateChanged:" + workQueue.toString());
}
- BluetoothJob job = workQueue.peek();
- if (job == null) {
- return;
- } else if (job.device.mAddress != mAddress) {
- // This can happen in 2 cases: 1) BT device initiated pairing and
- // 2) disconnects of one headset that's triggered by connects of
- // another.
- if (D) {
- Log.d(TAG, "mAddresses:" + mAddress + " != head:" + job.toString());
+
+ int newState = LocalBluetoothProfileManager.getProfileManager(mLocalManager,
+ profile).convertState(newProfileState);
+
+ if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED) {
+ if (!mProfiles.contains(profile)) {
+ mProfiles.add(profile);
}
+ }
- // Check to see if we need to remove the stale items from the queue
- if (!pruneQueue(null)) {
- // nothing in the queue was modify. Just ignore the notification and return.
+ /* Ignore the transient states e.g. connecting, disconnecting */
+ if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED ||
+ newState == SettingsBtStatus.CONNECTION_STATUS_DISCONNECTED) {
+ BluetoothJob job = workQueue.peek();
+ if (job == null) {
return;
+ } else if (job.device.mAddress != mAddress) {
+ // This can happen in 2 cases: 1) BT device initiated pairing and
+ // 2) disconnects of one headset that's triggered by connects of
+ // another.
+ if (D) {
+ Log.d(TAG, "mAddresses:" + mAddress + " != head:" + job.toString());
+ }
+
+ // Check to see if we need to remove the stale items from the queue
+ if (!pruneQueue(null)) {
+ // nothing in the queue was modify. Just ignore the notification and return.
+ return;
+ }
+ } else {
+ // Remove the first item and process the next one
+ workQueue.poll();
}
- } else {
- // Remove the first item and process the next one
- workQueue.poll();
- }
- processCommands();
+ processCommands();
+ }
}
/*