Merge changes I35c3ca3d,I5522ee84
* changes:
AvrcpController null pointer exceptions.
Update A2DP Sink Connect timeouts.
diff --git a/src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java b/src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java
index 7a5de62..58a6109 100644
--- a/src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java
+++ b/src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java
@@ -74,6 +74,7 @@
private static final int IS_INVALID_DEVICE = 0;
private static final int IS_VALID_DEVICE = 1;
+ private static final int CONNECT_TIMEOUT_MS = 5000;
public static final int AVRC_ID_PLAY = 0x44;
public static final int AVRC_ID_PAUSE = 0x46;
public static final int KEY_STATE_PRESSED = 0;
@@ -215,9 +216,6 @@
mTargetDevice = device;
transitionTo(mPending);
}
- // TODO(BT) remove CONNECT_TIMEOUT when the stack
- // sends back events consistently
- sendMessageDelayed(CONNECT_TIMEOUT, 30000);
break;
case DISCONNECT:
// ignore
@@ -298,6 +296,7 @@
@Override
public void enter() {
log("Enter Pending: " + getCurrentMessage().what);
+ sendMessageDelayed(CONNECT_TIMEOUT, CONNECT_TIMEOUT_MS);
}
@Override
@@ -330,7 +329,6 @@
log("STACK_EVENT " + event.type);
switch (event.type) {
case EVENT_TYPE_CONNECTION_STATE_CHANGED:
- removeMessages(CONNECT_TIMEOUT);
processConnectionEvent(event.device, event.valueInt);
break;
case EVENT_TYPE_AUDIO_CONFIG_CHANGED:
@@ -347,6 +345,11 @@
return retValue;
}
+ @Override
+ public void exit() {
+ removeMessages(CONNECT_TIMEOUT);
+ }
+
// in Pending state
private void processConnectionEvent(BluetoothDevice device, int state) {
log("processConnectionEvent state " + state);
@@ -671,7 +674,7 @@
}
if (currentState == mConnected) {
- if (mCurrentDevice.equals(device)) {
+ if (mCurrentDevice != null && mCurrentDevice.equals(device)) {
return BluetoothProfile.STATE_CONNECTED;
}
return BluetoothProfile.STATE_DISCONNECTED;