summaryrefslogtreecommitdiff
path: root/core/java/android/bluetooth/BluetoothDeviceProfileState.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/bluetooth/BluetoothDeviceProfileState.java')
-rw-r--r--core/java/android/bluetooth/BluetoothDeviceProfileState.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index ff82d39fc49f..17b28d1a809d 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -136,6 +136,10 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
Message msg = new Message();
msg.what = AUTO_CONNECT_PROFILES;
sendMessageDelayed(msg, AUTO_CONNECT_DELAY);
+ } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
+ // This is technically not needed, but we can get stuck sometimes.
+ // For example, if incoming A2DP fails, we are not informed by Bluez
+ sendMessage(TRANSITION_TO_STABLE);
}
}
};
@@ -175,6 +179,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
filter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
filter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
+ filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
mContext.registerReceiver(mBroadcastReceiver, filter);
@@ -302,7 +307,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
Log.e(TAG, "Error: OutgoingHandsfree state with command:" + mCommand);
}
mStatus = processCommand(mCommand);
- if (!mStatus) sendMessage(TRANSITION_TO_STABLE);
+ if (!mStatus) {
+ sendMessage(TRANSITION_TO_STABLE);
+ mService.sendProfileStateMessage(BluetoothProfileState.HFP,
+ BluetoothProfileState.TRANSITION_TO_STABLE);
+ }
}
@Override
@@ -393,7 +402,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
Log.e(TAG, "Error: IncomingHandsfree state with command:" + mCommand);
}
mStatus = processCommand(mCommand);
- if (!mStatus) sendMessage(TRANSITION_TO_STABLE);
+ if (!mStatus) {
+ sendMessage(TRANSITION_TO_STABLE);
+ mService.sendProfileStateMessage(BluetoothProfileState.HFP,
+ BluetoothProfileState.TRANSITION_TO_STABLE);
+ }
}
@Override
@@ -461,7 +474,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
Log.e(TAG, "Error: OutgoingA2DP state with command:" + mCommand);
}
mStatus = processCommand(mCommand);
- if (!mStatus) sendMessage(TRANSITION_TO_STABLE);
+ if (!mStatus) {
+ sendMessage(TRANSITION_TO_STABLE);
+ mService.sendProfileStateMessage(BluetoothProfileState.A2DP,
+ BluetoothProfileState.TRANSITION_TO_STABLE);
+ }
}
@Override
@@ -549,7 +566,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
Log.e(TAG, "Error: IncomingA2DP state with command:" + mCommand);
}
mStatus = processCommand(mCommand);
- if (!mStatus) sendMessage(TRANSITION_TO_STABLE);
+ if (!mStatus) {
+ sendMessage(TRANSITION_TO_STABLE);
+ mService.sendProfileStateMessage(BluetoothProfileState.A2DP,
+ BluetoothProfileState.TRANSITION_TO_STABLE);
+ }
}
@Override