diff options
author | deymo@chromium.org <deymo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-21 19:24:36 +0000 |
---|---|---|
committer | deymo@chromium.org <deymo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-21 19:24:36 +0000 |
commit | abe11710d5f2d62a848fbcbf04c15ec354a37b12 (patch) | |
tree | eef9cbf9d48263a5ac4569a0723751532f19e718 /device | |
parent | 3292ee0a5a2c62a15150c548210da4fd97352fc9 (diff) | |
download | chromium_src-abe11710d5f2d62a848fbcbf04c15ec354a37b12.zip chromium_src-abe11710d5f2d62a848fbcbf04c15ec354a37b12.tar.gz chromium_src-abe11710d5f2d62a848fbcbf04c15ec354a37b12.tar.bz2 |
Pass Bluetooth errors back to the UI.
Implement the functionality that passes the error codes and interprets them as error messages in the user interface. Introduced a new error code for an unsupported device.
BUG=chromium-os:27902
TEST=try it the chromebook pairing new devices.
Review URL: https://chromiumcodereview.appspot.com/11644010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r-- | device/bluetooth/bluetooth_device.h | 2 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_device_chromeos.cc | 45 |
2 files changed, 37 insertions, 10 deletions
diff --git a/device/bluetooth/bluetooth_device.h b/device/bluetooth/bluetooth_device.h index 9b703f8..893b925 100644 --- a/device/bluetooth/bluetooth_device.h +++ b/device/bluetooth/bluetooth_device.h @@ -58,11 +58,11 @@ class BluetoothDevice { ERROR_UNKNOWN, ERROR_INPROGRESS, ERROR_FAILED, - ERROR_CONNECT_FAILED, ERROR_AUTH_FAILED, ERROR_AUTH_CANCELED, ERROR_AUTH_REJECTED, ERROR_AUTH_TIMEOUT, + ERROR_UNSUPPORTED_DEVICE }; // Interface for observing changes from bluetooth devices. diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_chromeos.cc index 45a35b4..c5784cd 100644 --- a/device/bluetooth/bluetooth_device_chromeos.cc +++ b/device/bluetooth/bluetooth_device_chromeos.cc @@ -367,10 +367,24 @@ void BluetoothDeviceChromeOs::OnCreateDeviceError( const ConnectErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { - LOG(WARNING) << "Connection failed: " << address_ - << ": " << error_name << ": " << error_message; - error_callback.Run(ERROR_UNKNOWN); - // TODO(deymo): Determine the right error code from error_name. + ConnectErrorCode error_code = ERROR_UNKNOWN; + + // Determines the right error code from error_name, assuming the error name + // comes from CreatePairedDevice bluez function. + if (error_name == bluetooth_adapter::kErrorConnectionAttemptFailed) { + error_code = ERROR_FAILED; + } else if (error_name == bluetooth_adapter::kErrorAuthenticationFailed) { + error_code = ERROR_AUTH_FAILED; + } else if (error_name == bluetooth_adapter::kErrorAuthenticationRejected) { + error_code = ERROR_AUTH_REJECTED; + } else if (error_name == bluetooth_adapter::kErrorAuthenticationTimeout) { + error_code = ERROR_AUTH_TIMEOUT; + } else { + // Another unknown error was returned by bluez, report it in the log. + LOG(WARNING) << "Connection failed (on CreatePairedDevice): " << address_ + << ": " << error_name << ": " << error_message; + } + error_callback.Run(error_code); } void BluetoothDeviceChromeOs::CollectServiceRecordsCallback( @@ -427,7 +441,6 @@ void BluetoothDeviceChromeOs::OnIntrospect( if (!success) { LOG(WARNING) << "Failed to determine supported applications: " << address_; error_callback.Run(ERROR_UNKNOWN); - // TODO(deymo): Replace ERROR_UNKNOWN with an appropriate new constant. return; } @@ -490,10 +503,24 @@ void BluetoothDeviceChromeOs::OnConnectError( const dbus::ObjectPath& device_path, const std::string& error_name, const std::string& error_message) { - LOG(WARNING) << "Connection failed: " << address_ << ": " << interface_name - << ": " << error_name << ": " << error_message; - error_callback.Run(ERROR_UNKNOWN); - // TODO(deymo): Determine the right error code from error_name. + ConnectErrorCode error_code = ERROR_UNKNOWN; + + // Determines the right error code from error_name, assuming the error name + // comes from Connect bluez function. + if (error_name == bluetooth_adapter::kErrorFailed) { + error_code = ERROR_FAILED; + } else if (error_name == bluetooth_adapter::kErrorInProgress) { + error_code = ERROR_INPROGRESS; + } else if (error_name == bluetooth_adapter::kErrorNotSupported) { + error_code = ERROR_UNSUPPORTED_DEVICE; + } else { + // Another unknown error was returned by bluez, report it in the log. + LOG(WARNING) << "Connection failed (on Connect): " << address_ + << ": " << interface_name + << ": " << error_name << ": " << error_message; + } + + error_callback.Run(error_code); } void BluetoothDeviceChromeOs::DisconnectCallback( |