b/2296110 Dialog for setting up dock audio.

Reimplemented as a Foreground Service just so it can get on top of the Car Dock App.
Added debounce mechanism to not disconnect immediately after getting a undock event.
Each dock now has its own "Remember setting".
Remember Settings is on by default

Change-Id: I80790bdb7c831e2a642365b92433012191aa70c1
This commit is contained in:
Michael Chan
2009-12-06 01:04:04 -08:00
parent 0bd445b974
commit df9504ef58
8 changed files with 667 additions and 453 deletions

View File

@@ -227,44 +227,46 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
}
public void onProfileStateChanged(Profile profile, int newProfileState) {
if (D) {
Log.d(TAG, "onProfileStateChanged:" + workQueue.toString());
}
int newState = LocalBluetoothProfileManager.getProfileManager(mLocalManager,
profile).convertState(newProfileState);
if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED) {
if (!mProfiles.contains(profile)) {
mProfiles.add(profile);
synchronized (workQueue) {
if (D) {
Log.d(TAG, "onProfileStateChanged:" + workQueue.toString());
}
}
/* 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.cachedDevice.mDevice.equals(mDevice)) {
// 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, "mDevice:" + mDevice + " != 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 {
// Remove the first item and process the next one
workQueue.poll();
}
} else if (!job.cachedDevice.mDevice.equals(mDevice)) {
// 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, "mDevice:" + mDevice + " != head:" + job.toString());
}
processCommands();
// 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();
}
processCommands();
}
}
}