| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h" | 5 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" |
| 8 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
| 9 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" | 10 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" |
| 10 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" | 11 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" |
| 11 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" | 12 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" |
| 12 #include "chromeos/dbus/experimental_bluetooth_device_client.h" | 13 #include "chromeos/dbus/experimental_bluetooth_device_client.h" |
| 13 #include "dbus/bus.h" | 14 #include "dbus/bus.h" |
| 14 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" | 15 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" |
| 15 #include "device/bluetooth/bluetooth_socket.h" | 16 #include "device/bluetooth/bluetooth_socket.h" |
| 16 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 17 | 18 |
| 18 using device::BluetoothDevice; | 19 using device::BluetoothDevice; |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // The agent path is relatively meaningless since BlueZ only supports one | 23 // The agent path is relatively meaningless since BlueZ only supports one |
| 23 // at time and will fail in an attempt to register another with "Already Exists" | 24 // at time and will fail in an attempt to register another with "Already Exists" |
| 24 // (which we fail in OnRegisterAgentError with ERROR_INPROGRESS). | 25 // (which we fail in OnRegisterAgentError with ERROR_INPROGRESS). |
| 25 const char kAgentPath[] = "/org/chromium/bluetooth_agent"; | 26 const char kAgentPath[] = "/org/chromium/bluetooth_agent"; |
| 26 | 27 |
| 28 // Histogram enumerations for pairing methods. |
| 29 enum UMAPairingMethod { |
| 30 UMA_PAIRING_METHOD_NONE, |
| 31 UMA_PAIRING_METHOD_REQUEST_PINCODE, |
| 32 UMA_PAIRING_METHOD_REQUEST_PASSKEY, |
| 33 UMA_PAIRING_METHOD_DISPLAY_PINCODE, |
| 34 UMA_PAIRING_METHOD_DISPLAY_PASSKEY, |
| 35 UMA_PAIRING_METHOD_CONFIRM_PASSKEY, |
| 36 // NOTE: Add new pairing methods immediately above this line. Make sure to |
| 37 // update the enum list in tools/histogram/histograms.xml accordinly. |
| 38 UMA_PAIRING_METHOD_COUNT |
| 39 }; |
| 40 |
| 41 // Histogram enumerations for pairing results. |
| 42 enum UMAPairingResult { |
| 43 UMA_PAIRING_RESULT_SUCCESS, |
| 44 UMA_PAIRING_RESULT_INPROGRESS, |
| 45 UMA_PAIRING_RESULT_FAILED, |
| 46 UMA_PAIRING_RESULT_AUTH_FAILED, |
| 47 UMA_PAIRING_RESULT_AUTH_CANCELED, |
| 48 UMA_PAIRING_RESULT_AUTH_REJECTED, |
| 49 UMA_PAIRING_RESULT_AUTH_TIMEOUT, |
| 50 UMA_PAIRING_RESULT_UNSUPPORTED_DEVICE, |
| 51 UMA_PAIRING_RESULT_UNKNOWN_ERROR, |
| 52 // NOTE: Add new pairing results immediately above this line. Make sure to |
| 53 // update the enum list in tools/histogram/histograms.xml accordinly. |
| 54 UMA_PAIRING_RESULT_COUNT |
| 55 }; |
| 56 |
| 27 } // namespace | 57 } // namespace |
| 28 | 58 |
| 29 namespace chromeos { | 59 namespace chromeos { |
| 30 | 60 |
| 31 BluetoothDeviceExperimentalChromeOS::BluetoothDeviceExperimentalChromeOS( | 61 BluetoothDeviceExperimentalChromeOS::BluetoothDeviceExperimentalChromeOS( |
| 32 BluetoothAdapterExperimentalChromeOS* adapter, | 62 BluetoothAdapterExperimentalChromeOS* adapter, |
| 33 const dbus::ObjectPath& object_path) | 63 const dbus::ObjectPath& object_path) |
| 34 : adapter_(adapter), | 64 : adapter_(adapter), |
| 35 object_path_(object_path), | 65 object_path_(object_path), |
| 36 num_connecting_calls_(0), | 66 num_connecting_calls_(0), |
| 37 pairing_delegate_(NULL), | 67 pairing_delegate_(NULL), |
| 68 pairing_delegate_used_(false), |
| 38 weak_ptr_factory_(this) { | 69 weak_ptr_factory_(this) { |
| 39 } | 70 } |
| 40 | 71 |
| 41 BluetoothDeviceExperimentalChromeOS::~BluetoothDeviceExperimentalChromeOS() { | 72 BluetoothDeviceExperimentalChromeOS::~BluetoothDeviceExperimentalChromeOS() { |
| 42 } | 73 } |
| 43 | 74 |
| 44 uint32 BluetoothDeviceExperimentalChromeOS::GetBluetoothClass() const { | 75 uint32 BluetoothDeviceExperimentalChromeOS::GetBluetoothClass() const { |
| 45 ExperimentalBluetoothDeviceClient::Properties* properties = | 76 ExperimentalBluetoothDeviceClient::Properties* properties = |
| 46 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> | 77 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
| 47 GetProperties(object_path_); | 78 GetProperties(object_path_); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 61 | 92 |
| 62 std::string BluetoothDeviceExperimentalChromeOS::GetAddress() const { | 93 std::string BluetoothDeviceExperimentalChromeOS::GetAddress() const { |
| 63 ExperimentalBluetoothDeviceClient::Properties* properties = | 94 ExperimentalBluetoothDeviceClient::Properties* properties = |
| 64 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> | 95 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
| 65 GetProperties(object_path_); | 96 GetProperties(object_path_); |
| 66 DCHECK(properties); | 97 DCHECK(properties); |
| 67 | 98 |
| 68 return properties->address.value(); | 99 return properties->address.value(); |
| 69 } | 100 } |
| 70 | 101 |
| 102 std::string BluetoothDeviceExperimentalChromeOS::GetModalias() const { |
| 103 ExperimentalBluetoothDeviceClient::Properties* properties = |
| 104 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
| 105 GetProperties(object_path_); |
| 106 DCHECK(properties); |
| 107 |
| 108 return properties->modalias.value(); |
| 109 } |
| 110 |
| 71 bool BluetoothDeviceExperimentalChromeOS::IsPaired() const { | 111 bool BluetoothDeviceExperimentalChromeOS::IsPaired() const { |
| 72 ExperimentalBluetoothDeviceClient::Properties* properties = | 112 ExperimentalBluetoothDeviceClient::Properties* properties = |
| 73 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> | 113 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
| 74 GetProperties(object_path_); | 114 GetProperties(object_path_); |
| 75 DCHECK(properties); | 115 DCHECK(properties); |
| 76 | 116 |
| 77 // Trusted devices are devices that don't support pairing but that the | 117 // Trusted devices are devices that don't support pairing but that the |
| 78 // user has explicitly connected; it makes no sense for UI purposes to | 118 // user has explicitly connected; it makes no sense for UI purposes to |
| 79 // treat them differently from each other. | 119 // treat them differently from each other. |
| 80 return properties->paired.value() || properties->trusted.value(); | 120 return properties->paired.value() || properties->trusted.value(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 184 |
| 145 if (IsPaired() || IsConnected() || !pairing_delegate || !IsPairable()) { | 185 if (IsPaired() || IsConnected() || !pairing_delegate || !IsPairable()) { |
| 146 // No need to pair, or unable to, skip straight to connection. | 186 // No need to pair, or unable to, skip straight to connection. |
| 147 ConnectInternal(callback, error_callback); | 187 ConnectInternal(callback, error_callback); |
| 148 } else { | 188 } else { |
| 149 // Initiate high-security connection with pairing. | 189 // Initiate high-security connection with pairing. |
| 150 DCHECK(!pairing_delegate_); | 190 DCHECK(!pairing_delegate_); |
| 151 DCHECK(agent_.get() == NULL); | 191 DCHECK(agent_.get() == NULL); |
| 152 | 192 |
| 153 pairing_delegate_ = pairing_delegate; | 193 pairing_delegate_ = pairing_delegate; |
| 194 pairing_delegate_used_ = false; |
| 154 | 195 |
| 155 // The agent path is relatively meaningless since BlueZ only supports | 196 // The agent path is relatively meaningless since BlueZ only supports |
| 156 // one per application at a time. | 197 // one per application at a time. |
| 157 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); | 198 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); |
| 158 agent_.reset(ExperimentalBluetoothAgentServiceProvider::Create( | 199 agent_.reset(ExperimentalBluetoothAgentServiceProvider::Create( |
| 159 system_bus, dbus::ObjectPath(kAgentPath), this)); | 200 system_bus, dbus::ObjectPath(kAgentPath), this)); |
| 160 DCHECK(agent_.get()); | 201 DCHECK(agent_.get()); |
| 161 | 202 |
| 162 VLOG(1) << object_path_.value() << ": Registering agent for pairing"; | 203 VLOG(1) << object_path_.value() << ": Registering agent for pairing"; |
| 163 DBusThreadManager::Get()->GetExperimentalBluetoothAgentManagerClient()-> | 204 DBusThreadManager::Get()->GetExperimentalBluetoothAgentManagerClient()-> |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 UnregisterAgent(); | 333 UnregisterAgent(); |
| 293 } | 334 } |
| 294 | 335 |
| 295 void BluetoothDeviceExperimentalChromeOS::RequestPinCode( | 336 void BluetoothDeviceExperimentalChromeOS::RequestPinCode( |
| 296 const dbus::ObjectPath& device_path, | 337 const dbus::ObjectPath& device_path, |
| 297 const PinCodeCallback& callback) { | 338 const PinCodeCallback& callback) { |
| 298 DCHECK(agent_.get()); | 339 DCHECK(agent_.get()); |
| 299 DCHECK(device_path == object_path_); | 340 DCHECK(device_path == object_path_); |
| 300 VLOG(1) << object_path_.value() << ": RequestPinCode"; | 341 VLOG(1) << object_path_.value() << ": RequestPinCode"; |
| 301 | 342 |
| 343 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
| 344 UMA_PAIRING_METHOD_REQUEST_PINCODE, |
| 345 UMA_PAIRING_METHOD_COUNT); |
| 346 |
| 302 DCHECK(pairing_delegate_); | 347 DCHECK(pairing_delegate_); |
| 303 DCHECK(pincode_callback_.is_null()); | 348 DCHECK(pincode_callback_.is_null()); |
| 304 pincode_callback_ = callback; | 349 pincode_callback_ = callback; |
| 305 pairing_delegate_->RequestPinCode(this); | 350 pairing_delegate_->RequestPinCode(this); |
| 306 } | 351 } |
| 307 | 352 |
| 308 void BluetoothDeviceExperimentalChromeOS::DisplayPinCode( | 353 void BluetoothDeviceExperimentalChromeOS::DisplayPinCode( |
| 309 const dbus::ObjectPath& device_path, | 354 const dbus::ObjectPath& device_path, |
| 310 const std::string& pincode) { | 355 const std::string& pincode) { |
| 311 DCHECK(agent_.get()); | 356 DCHECK(agent_.get()); |
| 312 DCHECK(device_path == object_path_); | 357 DCHECK(device_path == object_path_); |
| 313 VLOG(1) << object_path_.value() << ": DisplayPinCode: " << pincode; | 358 VLOG(1) << object_path_.value() << ": DisplayPinCode: " << pincode; |
| 314 | 359 |
| 360 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
| 361 UMA_PAIRING_METHOD_DISPLAY_PINCODE, |
| 362 UMA_PAIRING_METHOD_COUNT); |
| 363 |
| 315 DCHECK(pairing_delegate_); | 364 DCHECK(pairing_delegate_); |
| 316 pairing_delegate_->DisplayPinCode(this, pincode); | 365 pairing_delegate_->DisplayPinCode(this, pincode); |
| 317 } | 366 } |
| 318 | 367 |
| 319 void BluetoothDeviceExperimentalChromeOS::RequestPasskey( | 368 void BluetoothDeviceExperimentalChromeOS::RequestPasskey( |
| 320 const dbus::ObjectPath& device_path, | 369 const dbus::ObjectPath& device_path, |
| 321 const PasskeyCallback& callback) { | 370 const PasskeyCallback& callback) { |
| 322 DCHECK(agent_.get()); | 371 DCHECK(agent_.get()); |
| 323 DCHECK(device_path == object_path_); | 372 DCHECK(device_path == object_path_); |
| 324 VLOG(1) << object_path_.value() << ": RequestPasskey"; | 373 VLOG(1) << object_path_.value() << ": RequestPasskey"; |
| 325 | 374 |
| 375 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
| 376 UMA_PAIRING_METHOD_REQUEST_PASSKEY, |
| 377 UMA_PAIRING_METHOD_COUNT); |
| 378 |
| 326 DCHECK(pairing_delegate_); | 379 DCHECK(pairing_delegate_); |
| 327 DCHECK(passkey_callback_.is_null()); | 380 DCHECK(passkey_callback_.is_null()); |
| 328 passkey_callback_ = callback; | 381 passkey_callback_ = callback; |
| 329 pairing_delegate_->RequestPasskey(this); | 382 pairing_delegate_->RequestPasskey(this); |
| 330 } | 383 } |
| 331 | 384 |
| 332 void BluetoothDeviceExperimentalChromeOS::DisplayPasskey( | 385 void BluetoothDeviceExperimentalChromeOS::DisplayPasskey( |
| 333 const dbus::ObjectPath& device_path, | 386 const dbus::ObjectPath& device_path, |
| 334 uint32 passkey, int16 entered) { | 387 uint32 passkey, int16 entered) { |
| 335 DCHECK(agent_.get()); | 388 DCHECK(agent_.get()); |
| 336 DCHECK(device_path == object_path_); | 389 DCHECK(device_path == object_path_); |
| 337 VLOG(1) << object_path_.value() << ": DisplayPasskey: " << passkey | 390 VLOG(1) << object_path_.value() << ": DisplayPasskey: " << passkey |
| 338 << " (" << entered << " entered)"; | 391 << " (" << entered << " entered)"; |
| 339 | 392 |
| 393 if (entered == 0) |
| 394 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
| 395 UMA_PAIRING_METHOD_DISPLAY_PASSKEY, |
| 396 UMA_PAIRING_METHOD_COUNT); |
| 397 |
| 340 DCHECK(pairing_delegate_); | 398 DCHECK(pairing_delegate_); |
| 341 if (entered == 0) | 399 if (entered == 0) |
| 342 pairing_delegate_->DisplayPasskey(this, passkey); | 400 pairing_delegate_->DisplayPasskey(this, passkey); |
| 343 pairing_delegate_->KeysEntered(this, entered); | 401 pairing_delegate_->KeysEntered(this, entered); |
| 344 } | 402 } |
| 345 | 403 |
| 346 void BluetoothDeviceExperimentalChromeOS::RequestConfirmation( | 404 void BluetoothDeviceExperimentalChromeOS::RequestConfirmation( |
| 347 const dbus::ObjectPath& device_path, | 405 const dbus::ObjectPath& device_path, |
| 348 uint32 passkey, | 406 uint32 passkey, |
| 349 const ConfirmationCallback& callback) { | 407 const ConfirmationCallback& callback) { |
| 350 DCHECK(agent_.get()); | 408 DCHECK(agent_.get()); |
| 351 DCHECK(device_path == object_path_); | 409 DCHECK(device_path == object_path_); |
| 352 VLOG(1) << object_path_.value() << ": RequestConfirmation: " << passkey; | 410 VLOG(1) << object_path_.value() << ": RequestConfirmation: " << passkey; |
| 353 | 411 |
| 412 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
| 413 UMA_PAIRING_METHOD_CONFIRM_PASSKEY, |
| 414 UMA_PAIRING_METHOD_COUNT); |
| 415 |
| 354 DCHECK(pairing_delegate_); | 416 DCHECK(pairing_delegate_); |
| 355 DCHECK(confirmation_callback_.is_null()); | 417 DCHECK(confirmation_callback_.is_null()); |
| 356 confirmation_callback_ = callback; | 418 confirmation_callback_ = callback; |
| 357 pairing_delegate_->ConfirmPasskey(this, passkey); | 419 pairing_delegate_->ConfirmPasskey(this, passkey); |
| 358 } | 420 } |
| 359 | 421 |
| 360 void BluetoothDeviceExperimentalChromeOS::RequestAuthorization( | 422 void BluetoothDeviceExperimentalChromeOS::RequestAuthorization( |
| 361 const dbus::ObjectPath& device_path, | 423 const dbus::ObjectPath& device_path, |
| 362 const ConfirmationCallback& callback) { | 424 const ConfirmationCallback& callback) { |
| 363 // TODO(keybuk): implement | 425 // TODO(keybuk): implement |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // Determine the error code from error_name. | 485 // Determine the error code from error_name. |
| 424 ConnectErrorCode error_code = ERROR_UNKNOWN; | 486 ConnectErrorCode error_code = ERROR_UNKNOWN; |
| 425 if (error_name == bluetooth_adapter::kErrorFailed) { | 487 if (error_name == bluetooth_adapter::kErrorFailed) { |
| 426 error_code = ERROR_FAILED; | 488 error_code = ERROR_FAILED; |
| 427 } else if (error_name == bluetooth_adapter::kErrorInProgress) { | 489 } else if (error_name == bluetooth_adapter::kErrorInProgress) { |
| 428 error_code = ERROR_INPROGRESS; | 490 error_code = ERROR_INPROGRESS; |
| 429 } else if (error_name == bluetooth_adapter::kErrorNotSupported) { | 491 } else if (error_name == bluetooth_adapter::kErrorNotSupported) { |
| 430 error_code = ERROR_UNSUPPORTED_DEVICE; | 492 error_code = ERROR_UNSUPPORTED_DEVICE; |
| 431 } | 493 } |
| 432 | 494 |
| 495 RecordPairingResult(false, error_code); |
| 433 error_callback.Run(error_code); | 496 error_callback.Run(error_code); |
| 434 } | 497 } |
| 435 | 498 |
| 436 void BluetoothDeviceExperimentalChromeOS::OnRegisterAgent( | 499 void BluetoothDeviceExperimentalChromeOS::OnRegisterAgent( |
| 437 const base::Closure& callback, | 500 const base::Closure& callback, |
| 438 const ConnectErrorCallback& error_callback) { | 501 const ConnectErrorCallback& error_callback) { |
| 439 VLOG(1) << object_path_.value() << ": Agent registered, now pairing"; | 502 VLOG(1) << object_path_.value() << ": Agent registered, now pairing"; |
| 440 | 503 |
| 441 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> | 504 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
| 442 Pair(object_path_, | 505 Pair(object_path_, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 461 VLOG(1) << object_path_.value() << ": " << num_connecting_calls_ | 524 VLOG(1) << object_path_.value() << ": " << num_connecting_calls_ |
| 462 << " still in progress"; | 525 << " still in progress"; |
| 463 | 526 |
| 464 UnregisterAgent(); | 527 UnregisterAgent(); |
| 465 | 528 |
| 466 // Determine the error code from error_name. | 529 // Determine the error code from error_name. |
| 467 ConnectErrorCode error_code = ERROR_UNKNOWN; | 530 ConnectErrorCode error_code = ERROR_UNKNOWN; |
| 468 if (error_name == bluetooth_adapter::kErrorAlreadyExists) | 531 if (error_name == bluetooth_adapter::kErrorAlreadyExists) |
| 469 error_code = ERROR_INPROGRESS; | 532 error_code = ERROR_INPROGRESS; |
| 470 | 533 |
| 534 RecordPairingResult(false, error_code); |
| 471 error_callback.Run(error_code); | 535 error_callback.Run(error_code); |
| 472 } | 536 } |
| 473 | 537 |
| 474 void BluetoothDeviceExperimentalChromeOS::OnPair( | 538 void BluetoothDeviceExperimentalChromeOS::OnPair( |
| 475 const base::Closure& callback, | 539 const base::Closure& callback, |
| 476 const ConnectErrorCallback& error_callback) { | 540 const ConnectErrorCallback& error_callback) { |
| 477 VLOG(1) << object_path_.value() << ": Paired"; | 541 VLOG(1) << object_path_.value() << ": Paired"; |
| 542 |
| 543 if (!pairing_delegate_used_) |
| 544 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
| 545 UMA_PAIRING_METHOD_NONE, |
| 546 UMA_PAIRING_METHOD_COUNT); |
| 478 UnregisterAgent(); | 547 UnregisterAgent(); |
| 479 SetTrusted(); | 548 SetTrusted(); |
| 480 ConnectInternal(callback, error_callback); | 549 ConnectInternal(callback, error_callback); |
| 481 } | 550 } |
| 482 | 551 |
| 483 void BluetoothDeviceExperimentalChromeOS::OnPairError( | 552 void BluetoothDeviceExperimentalChromeOS::OnPairError( |
| 484 const ConnectErrorCallback& error_callback, | 553 const ConnectErrorCallback& error_callback, |
| 485 const std::string& error_name, | 554 const std::string& error_name, |
| 486 const std::string& error_message) { | 555 const std::string& error_message) { |
| 487 --num_connecting_calls_; | 556 --num_connecting_calls_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 500 } else if (error_name == bluetooth_adapter::kErrorAuthenticationFailed) { | 569 } else if (error_name == bluetooth_adapter::kErrorAuthenticationFailed) { |
| 501 error_code = ERROR_AUTH_FAILED; | 570 error_code = ERROR_AUTH_FAILED; |
| 502 } else if (error_name == bluetooth_adapter::kErrorAuthenticationCanceled) { | 571 } else if (error_name == bluetooth_adapter::kErrorAuthenticationCanceled) { |
| 503 error_code = ERROR_AUTH_CANCELED; | 572 error_code = ERROR_AUTH_CANCELED; |
| 504 } else if (error_name == bluetooth_adapter::kErrorAuthenticationRejected) { | 573 } else if (error_name == bluetooth_adapter::kErrorAuthenticationRejected) { |
| 505 error_code = ERROR_AUTH_REJECTED; | 574 error_code = ERROR_AUTH_REJECTED; |
| 506 } else if (error_name == bluetooth_adapter::kErrorAuthenticationTimeout) { | 575 } else if (error_name == bluetooth_adapter::kErrorAuthenticationTimeout) { |
| 507 error_code = ERROR_AUTH_TIMEOUT; | 576 error_code = ERROR_AUTH_TIMEOUT; |
| 508 } | 577 } |
| 509 | 578 |
| 579 RecordPairingResult(false, error_code); |
| 510 error_callback.Run(error_code); | 580 error_callback.Run(error_code); |
| 511 } | 581 } |
| 512 | 582 |
| 513 void BluetoothDeviceExperimentalChromeOS::OnCancelPairingError( | 583 void BluetoothDeviceExperimentalChromeOS::OnCancelPairingError( |
| 514 const std::string& error_name, | 584 const std::string& error_name, |
| 515 const std::string& error_message) { | 585 const std::string& error_message) { |
| 516 LOG(WARNING) << object_path_.value() << ": Failed to cancel pairing: " | 586 LOG(WARNING) << object_path_.value() << ": Failed to cancel pairing: " |
| 517 << error_name << ": " << error_message; | 587 << error_name << ": " << error_message; |
| 518 } | 588 } |
| 519 | 589 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 | 679 |
| 610 if (!confirmation_callback_.is_null()) { | 680 if (!confirmation_callback_.is_null()) { |
| 611 confirmation_callback_.Run(status); | 681 confirmation_callback_.Run(status); |
| 612 confirmation_callback_.Reset(); | 682 confirmation_callback_.Reset(); |
| 613 callback_run = true; | 683 callback_run = true; |
| 614 } | 684 } |
| 615 | 685 |
| 616 return callback_run; | 686 return callback_run; |
| 617 } | 687 } |
| 618 | 688 |
| 689 void BluetoothDeviceExperimentalChromeOS::RecordPairingResult( |
| 690 bool success, |
| 691 ConnectErrorCode error_code) { |
| 692 UMAPairingResult pairing_result; |
| 693 if (success) { |
| 694 pairing_result = UMA_PAIRING_RESULT_SUCCESS; |
| 695 } else { |
| 696 switch (error_code) { |
| 697 case ERROR_INPROGRESS: |
| 698 pairing_result = UMA_PAIRING_RESULT_INPROGRESS; |
| 699 break; |
| 700 case ERROR_FAILED: |
| 701 pairing_result = UMA_PAIRING_RESULT_FAILED; |
| 702 break; |
| 703 case ERROR_AUTH_FAILED: |
| 704 pairing_result = UMA_PAIRING_RESULT_AUTH_FAILED; |
| 705 break; |
| 706 case ERROR_AUTH_CANCELED: |
| 707 pairing_result = UMA_PAIRING_RESULT_AUTH_CANCELED; |
| 708 break; |
| 709 case ERROR_AUTH_REJECTED: |
| 710 pairing_result = UMA_PAIRING_RESULT_AUTH_REJECTED; |
| 711 break; |
| 712 case ERROR_AUTH_TIMEOUT: |
| 713 pairing_result = UMA_PAIRING_RESULT_AUTH_TIMEOUT; |
| 714 break; |
| 715 case ERROR_UNSUPPORTED_DEVICE: |
| 716 pairing_result = UMA_PAIRING_RESULT_UNSUPPORTED_DEVICE; |
| 717 break; |
| 718 default: |
| 719 pairing_result = UMA_PAIRING_RESULT_UNKNOWN_ERROR; |
| 720 } |
| 721 } |
| 722 |
| 723 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult", |
| 724 pairing_result, |
| 725 UMA_PAIRING_RESULT_COUNT); |
| 726 } |
| 727 |
| 619 } // namespace chromeos | 728 } // namespace chromeos |
| OLD | NEW |