summaryrefslogtreecommitdiff
path: root/core/java/android/server/BluetoothEventLoop.java
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2011-01-19 13:59:32 -0800
committerJaikumar Ganesh <jaikumar@google.com>2011-01-19 14:06:29 -0800
commitfbe807d064ada99211b102914df514aa562256f8 (patch)
tree012462235f36ab6ee1e3fe7088f4f9338f09bb39 /core/java/android/server/BluetoothEventLoop.java
parent529fc53d3fd298ee5aef20e3a07bd263f7376b8d (diff)
Make connection / disconnect failure more robust.
Add error codes so that the states can be tracked better. Change-Id: Ic07a5d34589134b68dedeb4803ccb523aa01b567
Diffstat (limited to 'core/java/android/server/BluetoothEventLoop.java')
-rw-r--r--core/java/android/server/BluetoothEventLoop.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index 539a696bdb8e..cd3bc3e7c32a 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -748,9 +748,9 @@ class BluetoothEventLoop {
}
}
- private void onInputDeviceConnectionResult(String path, boolean result) {
+ private void onInputDeviceConnectionResult(String path, int result) {
// Success case gets handled by Property Change signal
- if (!result) {
+ if (result != BluetoothInputDevice.INPUT_OPERATION_SUCCESS) {
String address = mBluetoothService.getAddressFromObjectPath(path);
if (address == null) return;
@@ -758,9 +758,18 @@ class BluetoothEventLoop {
BluetoothDevice device = mAdapter.getRemoteDevice(address);
int state = mBluetoothService.getInputDeviceState(device);
if (state == BluetoothInputDevice.STATE_CONNECTING) {
- connected = false;
+ if (result == BluetoothInputDevice.INPUT_CONNECT_FAILED_ALREADY_CONNECTED) {
+ connected = true;
+ } else {
+ connected = false;
+ }
} else if (state == BluetoothInputDevice.STATE_DISCONNECTING) {
- connected = true;
+ if (result == BluetoothInputDevice.INPUT_DISCONNECT_FAILED_NOT_CONNECTED) {
+ connected = false;
+ } else {
+ // There is no better way to handle this, this shouldn't happen
+ connected = true;
+ }
} else {
Log.e(TAG, "Error onInputDeviceConnectionResult. State is:" + state);
}
@@ -768,10 +777,10 @@ class BluetoothEventLoop {
}
}
- private void onPanDeviceConnectionResult(String path, boolean result) {
+ private void onPanDeviceConnectionResult(String path, int result) {
log ("onPanDeviceConnectionResult " + path + " " + result);
// Success case gets handled by Property Change signal
- if (!result) {
+ if (result != BluetoothPan.PAN_OPERATION_SUCCESS) {
String address = mBluetoothService.getAddressFromObjectPath(path);
if (address == null) return;
@@ -779,9 +788,18 @@ class BluetoothEventLoop {
BluetoothDevice device = mAdapter.getRemoteDevice(address);
int state = mBluetoothService.getPanDeviceState(device);
if (state == BluetoothPan.STATE_CONNECTING) {
- connected = false;
+ if (result == BluetoothPan.PAN_CONNECT_FAILED_ALREADY_CONNECTED) {
+ connected = true;
+ } else {
+ connected = false;
+ }
} else if (state == BluetoothPan.STATE_DISCONNECTING) {
- connected = true;
+ if (result == BluetoothPan.PAN_DISCONNECT_FAILED_NOT_CONNECTED) {
+ connected = false;
+ } else {
+ // There is no better way to handle this, this shouldn't happen
+ connected = true;
+ }
} else {
Log.e(TAG, "Error onPanDeviceConnectionResult. State is: "
+ state + " result: "+ result);