| Index: components/pairing/bluetooth_host_pairing_controller.cc
|
| diff --git a/components/pairing/bluetooth_host_pairing_controller.cc b/components/pairing/bluetooth_host_pairing_controller.cc
|
| index 8b0b201521495019db5cac03930a610c0a98a362..8e365e8ba197fc3e657e5d99e1df7e309bd12912 100644
|
| --- a/components/pairing/bluetooth_host_pairing_controller.cc
|
| +++ b/components/pairing/bluetooth_host_pairing_controller.cc
|
| @@ -165,6 +165,27 @@ void BluetoothHostPairingController::SendHostStatus() {
|
| ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| +void BluetoothHostPairingController::SendErrorCodeAndMessage() {
|
| + if (error_code_ == HostPairingController::ERROR_NONE)
|
| + return;
|
| +
|
| + pairing_api::Error error_status;
|
| + error_status.set_api_version(kPairingAPIVersion);
|
| + error_status.mutable_parameters()->set_code(error_code_);
|
| + error_status.mutable_parameters()->set_description(error_message_);
|
| +
|
| + int size = 0;
|
| + scoped_refptr<net::IOBuffer> io_buffer(
|
| + ProtoDecoder::SendError(error_status, &size));
|
| +
|
| + controller_socket_->Send(
|
| + io_buffer, size,
|
| + base::Bind(&BluetoothHostPairingController::OnSendComplete,
|
| + ptr_factory_.GetWeakPtr()),
|
| + base::Bind(&BluetoothHostPairingController::OnSendError,
|
| + ptr_factory_.GetWeakPtr()));
|
| +}
|
| +
|
| void BluetoothHostPairingController::Reset() {
|
| if (adapter_.get()) {
|
| device::BluetoothDevice* device =
|
| @@ -499,9 +520,12 @@ std::string BluetoothHostPairingController::GetEnrollmentDomain() {
|
| void BluetoothHostPairingController::OnNetworkConnectivityChanged(
|
| Connectivity connectivity_status) {
|
| connectivity_status_ = connectivity_status;
|
| - if (connectivity_status == CONNECTIVITY_NONE)
|
| + if (connectivity_status == CONNECTIVITY_NONE) {
|
| ChangeStage(STAGE_SETUP_NETWORK_ERROR);
|
| - SendHostStatus();
|
| + SendErrorCodeAndMessage();
|
| + } else {
|
| + SendHostStatus();
|
| + }
|
| }
|
|
|
| void BluetoothHostPairingController::OnUpdateStatusChanged(
|
| @@ -520,10 +544,11 @@ void BluetoothHostPairingController::OnEnrollmentStatusChanged(
|
| enrollment_status_ = enrollment_status;
|
| if (enrollment_status == ENROLLMENT_STATUS_SUCCESS) {
|
| ChangeStage(STAGE_ENROLLMENT_SUCCESS);
|
| + SendHostStatus();
|
| } else if (enrollment_status == ENROLLMENT_STATUS_FAILURE) {
|
| ChangeStage(STAGE_ENROLLMENT_ERROR);
|
| + SendErrorCodeAndMessage();
|
| }
|
| - SendHostStatus();
|
| }
|
|
|
| void BluetoothHostPairingController::SetPermanentId(
|
| @@ -531,6 +556,13 @@ void BluetoothHostPairingController::SetPermanentId(
|
| permanent_id_ = permanent_id;
|
| }
|
|
|
| +void BluetoothHostPairingController::SetErrorCodeAndMessage(
|
| + int error_code,
|
| + const std::string& error_message) {
|
| + error_code_ = error_code;
|
| + error_message_ = error_message;
|
| +}
|
| +
|
| void BluetoothHostPairingController::RequestPinCode(
|
| device::BluetoothDevice* device) {
|
| // Disallow unknown device.
|
|
|