am 38702d5f: Merge "DO NOT MERGE: Disconnect PBAP while disconnecting HFP profile." into gingerbread

Merge commit '38702d5f1c42e2dfcc8fa5472c8fe842b4056914' into gingerbread-plus-aosp

* commit '38702d5f1c42e2dfcc8fa5472c8fe842b4056914':
  DO NOT MERGE: Disconnect PBAP while disconnecting HFP profile.
This commit is contained in:
Jaikumar Ganesh
2010-10-07 16:58:13 -07:00
committed by Android Git Automerger

View File

@@ -67,10 +67,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
private static final int DISCONNECT_HFP_INCOMING = 6; private static final int DISCONNECT_HFP_INCOMING = 6;
public static final int DISCONNECT_A2DP_OUTGOING = 7; public static final int DISCONNECT_A2DP_OUTGOING = 7;
public static final int DISCONNECT_A2DP_INCOMING = 8; public static final int DISCONNECT_A2DP_INCOMING = 8;
public static final int DISCONNECT_PBAP_OUTGOING = 9;
public static final int UNPAIR = 9; public static final int UNPAIR = 100;
public static final int AUTO_CONNECT_PROFILES = 10; public static final int AUTO_CONNECT_PROFILES = 101;
public static final int TRANSITION_TO_STABLE = 11; public static final int TRANSITION_TO_STABLE = 102;
private static final int AUTO_CONNECT_DELAY = 6000; // 6 secs private static final int AUTO_CONNECT_DELAY = 6000; // 6 secs
@@ -84,7 +85,9 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
private BluetoothService mService; private BluetoothService mService;
private BluetoothA2dpService mA2dpService; private BluetoothA2dpService mA2dpService;
private BluetoothHeadset mHeadsetService; private BluetoothHeadset mHeadsetService;
private BluetoothPbap mPbapService;
private boolean mHeadsetServiceConnected; private boolean mHeadsetServiceConnected;
private boolean mPbapServiceConnected;
private BluetoothDevice mDevice; private BluetoothDevice mDevice;
private int mHeadsetState; private int mHeadsetState;
@@ -176,6 +179,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
mContext.registerReceiver(mBroadcastReceiver, filter); mContext.registerReceiver(mBroadcastReceiver, filter);
HeadsetServiceListener l = new HeadsetServiceListener(); HeadsetServiceListener l = new HeadsetServiceListener();
PbapServiceListener p = new PbapServiceListener();
} }
private class HeadsetServiceListener implements BluetoothHeadset.ServiceListener { private class HeadsetServiceListener implements BluetoothHeadset.ServiceListener {
@@ -194,6 +198,22 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
} }
} }
private class PbapServiceListener implements BluetoothPbap.ServiceListener {
public PbapServiceListener() {
mPbapService = new BluetoothPbap(mContext, this);
}
public void onServiceConnected() {
synchronized(BluetoothDeviceProfileState.this) {
mPbapServiceConnected = true;
}
}
public void onServiceDisconnected() {
synchronized(BluetoothDeviceProfileState.this) {
mPbapServiceConnected = false;
}
}
}
private class BondedDevice extends HierarchicalState { private class BondedDevice extends HierarchicalState {
@Override @Override
protected void enter() { protected void enter() {
@@ -224,6 +244,9 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
case DISCONNECT_A2DP_INCOMING: case DISCONNECT_A2DP_INCOMING:
transitionTo(mIncomingA2dp); transitionTo(mIncomingA2dp);
break; break;
case DISCONNECT_PBAP_OUTGOING:
processCommand(DISCONNECT_PBAP_OUTGOING);
break;
case UNPAIR: case UNPAIR:
if (mHeadsetState != BluetoothHeadset.STATE_DISCONNECTED) { if (mHeadsetState != BluetoothHeadset.STATE_DISCONNECTED) {
sendMessage(DISCONNECT_HFP_OUTGOING); sendMessage(DISCONNECT_HFP_OUTGOING);
@@ -342,6 +365,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
deferMessage(deferMsg); deferMessage(deferMsg);
} }
break; break;
case DISCONNECT_PBAP_OUTGOING:
case UNPAIR: case UNPAIR:
case AUTO_CONNECT_PROFILES: case AUTO_CONNECT_PROFILES:
deferMessage(message); deferMessage(message);
@@ -409,6 +433,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
// If this causes incoming HFP to fail, it is more of a headset problem // If this causes incoming HFP to fail, it is more of a headset problem
// since both connections are incoming ones. // since both connections are incoming ones.
break; break;
case DISCONNECT_PBAP_OUTGOING:
case UNPAIR: case UNPAIR:
case AUTO_CONNECT_PROFILES: case AUTO_CONNECT_PROFILES:
deferMessage(message); deferMessage(message);
@@ -496,6 +521,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
case DISCONNECT_A2DP_INCOMING: case DISCONNECT_A2DP_INCOMING:
// Ignore, will be handled by Bluez // Ignore, will be handled by Bluez
break; break;
case DISCONNECT_PBAP_OUTGOING:
case UNPAIR: case UNPAIR:
case AUTO_CONNECT_PROFILES: case AUTO_CONNECT_PROFILES:
deferMessage(message); deferMessage(message);
@@ -561,6 +587,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
case DISCONNECT_A2DP_INCOMING: case DISCONNECT_A2DP_INCOMING:
// Ignore, will be handled by Bluez // Ignore, will be handled by Bluez
break; break;
case DISCONNECT_PBAP_OUTGOING:
case UNPAIR: case UNPAIR:
case AUTO_CONNECT_PROFILES: case AUTO_CONNECT_PROFILES:
deferMessage(message); deferMessage(message);
@@ -588,7 +615,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
} }
} }
synchronized void deferHeadsetMessage(int command) { synchronized void deferProfileServiceMessage(int command) {
Message msg = new Message(); Message msg = new Message();
msg.what = command; msg.what = command;
deferMessage(msg); deferMessage(msg);
@@ -604,7 +631,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
break; break;
case CONNECT_HFP_INCOMING: case CONNECT_HFP_INCOMING:
if (!mHeadsetServiceConnected) { if (!mHeadsetServiceConnected) {
deferHeadsetMessage(command); deferProfileServiceMessage(command);
} else if (mHeadsetState == BluetoothHeadset.STATE_CONNECTING) { } else if (mHeadsetState == BluetoothHeadset.STATE_CONNECTING) {
return mHeadsetService.acceptIncomingConnect(mDevice); return mHeadsetService.acceptIncomingConnect(mDevice);
} else if (mHeadsetState == BluetoothHeadset.STATE_DISCONNECTED) { } else if (mHeadsetState == BluetoothHeadset.STATE_DISCONNECTED) {
@@ -621,8 +648,13 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
return true; return true;
case DISCONNECT_HFP_OUTGOING: case DISCONNECT_HFP_OUTGOING:
if (!mHeadsetServiceConnected) { if (!mHeadsetServiceConnected) {
deferHeadsetMessage(command); deferProfileServiceMessage(command);
} else { } else {
// Disconnect PBAP
// TODO(): Add PBAP to the state machine.
Message m = new Message();
m.what = DISCONNECT_PBAP_OUTGOING;
deferMessage(m);
if (mHeadsetService.getPriority(mDevice) == if (mHeadsetService.getPriority(mDevice) ==
BluetoothHeadset.PRIORITY_AUTO_CONNECT) { BluetoothHeadset.PRIORITY_AUTO_CONNECT) {
mHeadsetService.setPriority(mDevice, BluetoothHeadset.PRIORITY_ON); mHeadsetService.setPriority(mDevice, BluetoothHeadset.PRIORITY_ON);
@@ -645,6 +677,13 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
return mA2dpService.disconnectSinkInternal(mDevice); return mA2dpService.disconnectSinkInternal(mDevice);
} }
break; break;
case DISCONNECT_PBAP_OUTGOING:
if (!mPbapServiceConnected) {
deferProfileServiceMessage(command);
} else {
return mPbapService.disconnect();
}
break;
case UNPAIR: case UNPAIR:
return mService.removeBondInternal(mDevice.getAddress()); return mService.removeBondInternal(mDevice.getAddress());
default: default: