diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothInputDevice.java | 13 | ||||
| -rw-r--r-- | core/java/android/bluetooth/BluetoothPan.java | 13 | ||||
| -rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 34 |
3 files changed, 52 insertions, 8 deletions
diff --git a/core/java/android/bluetooth/BluetoothInputDevice.java b/core/java/android/bluetooth/BluetoothInputDevice.java index bc8a836183bc..a70de59a48f6 100644 --- a/core/java/android/bluetooth/BluetoothInputDevice.java +++ b/core/java/android/bluetooth/BluetoothInputDevice.java @@ -85,6 +85,19 @@ public final class BluetoothInputDevice { */ public static final int PRIORITY_UNDEFINED = -1; + /** + * Return codes for the connect and disconnect Bluez / Dbus calls. + */ + public static final int INPUT_DISCONNECT_FAILED_NOT_CONNECTED = 5000; + + public static final int INPUT_CONNECT_FAILED_ALREADY_CONNECTED = 5001; + + public static final int INPUT_CONNECT_FAILED_ATTEMPT_FAILED = 5002; + + public static final int INPUT_OPERATION_GENERIC_FAILURE = 5003; + + public static final int INPUT_OPERATION_SUCCESS = 5004; + private final IBluetooth mService; private final Context mContext; diff --git a/core/java/android/bluetooth/BluetoothPan.java b/core/java/android/bluetooth/BluetoothPan.java index 7dee25e4afa8..1f07349b4c13 100644 --- a/core/java/android/bluetooth/BluetoothPan.java +++ b/core/java/android/bluetooth/BluetoothPan.java @@ -70,6 +70,19 @@ public final class BluetoothPan { public static final int STATE_CONNECTED = 2; public static final int STATE_DISCONNECTING = 3; + /** + * Return codes for the connect and disconnect Bluez / Dbus calls. + */ + public static final int PAN_DISCONNECT_FAILED_NOT_CONNECTED = 1000; + + public static final int PAN_CONNECT_FAILED_ALREADY_CONNECTED = 1001; + + public static final int PAN_CONNECT_FAILED_ATTEMPT_FAILED = 1002; + + public static final int PAN_OPERATION_GENERIC_FAILURE = 1003; + + public static final int PAN_OPERATION_SUCCESS = 1004; + private final IBluetooth mService; private final Context mContext; 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); |
