Commit f3e10319 authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

Instant Tethering: Add more host connection failure metrics.

Breaks up the UNKNOWN_ERROR enum into 3 enums:
1) UNKNOWN_ERROR, which precisely captures when the host returns an
   UNKNOWN_ERROR response code.
2) NO_RESPONSE, which captures when the client never received a response at
   all. This likely indicates a Bluetooth error.
3) INVALID_HOTSPOT_CREDENTIALS, which captures when the host returns a SUCCESS
   response, but with invalid SSID or password info.

Bug: 785514
Change-Id: I0d40283d8b458dd45a1d490fb53eb075e2eb05e4
Reviewed-on: https://chromium-review.googlesource.com/1011595
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarJeremy Klein <jlklein@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550719}
parent 7c723eb6
...@@ -78,9 +78,7 @@ ConnectTetheringOperation::ConnectTetheringOperation( ...@@ -78,9 +78,7 @@ ConnectTetheringOperation::ConnectTetheringOperation(
tether_host_response_recorder_(tether_host_response_recorder), tether_host_response_recorder_(tether_host_response_recorder),
clock_(base::DefaultClock::GetInstance()), clock_(base::DefaultClock::GetInstance()),
setup_required_(setup_required), setup_required_(setup_required),
error_code_to_return_( error_code_to_return_(HostResponseErrorCode::NO_RESPONSE) {}
ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR) {}
ConnectTetheringOperation::~ConnectTetheringOperation() = default; ConnectTetheringOperation::~ConnectTetheringOperation() = default;
...@@ -140,12 +138,15 @@ void ConnectTetheringOperation::OnMessageReceived( ...@@ -140,12 +138,15 @@ void ConnectTetheringOperation::OnMessageReceived(
<< remote_device.GetTruncatedDeviceIdForLogs() << " and " << remote_device.GetTruncatedDeviceIdForLogs() << " and "
<< "response_code == SUCCESS, but the response did not " << "response_code == SUCCESS, but the response did not "
<< "contain a Wi-Fi SSID and/or password."; << "contain a Wi-Fi SSID and/or password.";
error_code_to_return_ =
HostResponseErrorCode::INVALID_HOTSPOT_CREDENTIALS;
} }
} else { } else {
PA_LOG(INFO) << "Received ConnectTetheringResponse from device with ID " PA_LOG(INFO) << "Received ConnectTetheringResponse from device with ID "
<< remote_device.GetTruncatedDeviceIdForLogs() << " and " << remote_device.GetTruncatedDeviceIdForLogs() << " and "
<< "response_code == " << response->response_code() << "."; << "response_code == " << response->response_code() << ".";
error_code_to_return_ = response->response_code(); error_code_to_return_ = ConnectTetheringResponseCodeToHostResponseErrorCode(
response->response_code());
} }
// UMA_HISTOGRAM_MEDIUM_TIMES is used because UMA_HISTOGRAM_TIMES has a max // UMA_HISTOGRAM_MEDIUM_TIMES is used because UMA_HISTOGRAM_TIMES has a max
...@@ -198,7 +199,7 @@ void ConnectTetheringOperation::NotifyObserversOfSuccessfulResponse( ...@@ -198,7 +199,7 @@ void ConnectTetheringOperation::NotifyObserversOfSuccessfulResponse(
} }
void ConnectTetheringOperation::NotifyObserversOfConnectionFailure( void ConnectTetheringOperation::NotifyObserversOfConnectionFailure(
ConnectTetheringResponse_ResponseCode error_code) { HostResponseErrorCode error_code) {
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
observer.OnConnectTetheringFailure(remote_device_, error_code); observer.OnConnectTetheringFailure(remote_device_, error_code);
} }
...@@ -210,6 +211,38 @@ uint32_t ConnectTetheringOperation::GetTimeoutSeconds() { ...@@ -210,6 +211,38 @@ uint32_t ConnectTetheringOperation::GetTimeoutSeconds() {
kSetupNotRequiredResponseTimeoutSeconds; kSetupNotRequiredResponseTimeoutSeconds;
} }
ConnectTetheringOperation::HostResponseErrorCode
ConnectTetheringOperation::ConnectTetheringResponseCodeToHostResponseErrorCode(
ConnectTetheringResponse_ResponseCode error_code) {
switch (error_code) {
case ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED:
return HostResponseErrorCode::PROVISIONING_FAILED;
case ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_TETHERING_TIMEOUT:
return HostResponseErrorCode::TETHERING_TIMEOUT;
case ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_TETHERING_UNSUPPORTED:
return HostResponseErrorCode::TETHERING_UNSUPPORTED;
case ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_NO_CELL_DATA:
return HostResponseErrorCode::NO_CELL_DATA;
case ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_ENABLING_HOTSPOT_FAILED:
return HostResponseErrorCode::ENABLING_HOTSPOT_FAILED;
case ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_ENABLING_HOTSPOT_TIMEOUT:
return HostResponseErrorCode::ENABLING_HOTSPOT_TIMEOUT;
case ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR:
return HostResponseErrorCode::UNKNOWN_ERROR;
default:
break;
}
return HostResponseErrorCode::NO_RESPONSE;
}
void ConnectTetheringOperation::SetClockForTest(base::Clock* clock_for_test) { void ConnectTetheringOperation::SetClockForTest(base::Clock* clock_for_test) {
clock_ = clock_for_test; clock_ = clock_for_test;
} }
......
...@@ -28,6 +28,20 @@ class TetherHostResponseRecorder; ...@@ -28,6 +28,20 @@ class TetherHostResponseRecorder;
// notifies observers when the RemoteDevice sends a response. // notifies observers when the RemoteDevice sends a response.
class ConnectTetheringOperation : public MessageTransferOperation { class ConnectTetheringOperation : public MessageTransferOperation {
public: public:
// Includes all error codes of ConnectTetheringResponse_ResponseCode, but
// includes extra values, |NO_RESPONSE| and |INVALID_HOTSPOT_CREDENTIALS|.
enum HostResponseErrorCode {
PROVISIONING_FAILED = 0,
TETHERING_TIMEOUT = 1,
TETHERING_UNSUPPORTED = 2,
NO_CELL_DATA = 3,
ENABLING_HOTSPOT_FAILED = 4,
ENABLING_HOTSPOT_TIMEOUT = 5,
UNKNOWN_ERROR = 6,
NO_RESPONSE = 7,
INVALID_HOTSPOT_CREDENTIALS = 8
};
class Factory { class Factory {
public: public:
static std::unique_ptr<ConnectTetheringOperation> NewInstance( static std::unique_ptr<ConnectTetheringOperation> NewInstance(
...@@ -59,7 +73,7 @@ class ConnectTetheringOperation : public MessageTransferOperation { ...@@ -59,7 +73,7 @@ class ConnectTetheringOperation : public MessageTransferOperation {
const std::string& password) = 0; const std::string& password) = 0;
virtual void OnConnectTetheringFailure( virtual void OnConnectTetheringFailure(
const cryptauth::RemoteDevice& remote_device, const cryptauth::RemoteDevice& remote_device,
ConnectTetheringResponse_ResponseCode error_code) = 0; HostResponseErrorCode error_code) = 0;
}; };
~ConnectTetheringOperation() override; ~ConnectTetheringOperation() override;
...@@ -87,14 +101,16 @@ class ConnectTetheringOperation : public MessageTransferOperation { ...@@ -87,14 +101,16 @@ class ConnectTetheringOperation : public MessageTransferOperation {
void NotifyConnectTetheringRequestSent(); void NotifyConnectTetheringRequestSent();
void NotifyObserversOfSuccessfulResponse(const std::string& ssid, void NotifyObserversOfSuccessfulResponse(const std::string& ssid,
const std::string& password); const std::string& password);
void NotifyObserversOfConnectionFailure( void NotifyObserversOfConnectionFailure(HostResponseErrorCode error_code);
ConnectTetheringResponse_ResponseCode error_code);
private: private:
friend class ConnectTetheringOperationTest; friend class ConnectTetheringOperationTest;
FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest, FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest,
TestOperation_SetupRequired); TestOperation_SetupRequired);
HostResponseErrorCode ConnectTetheringResponseCodeToHostResponseErrorCode(
ConnectTetheringResponse_ResponseCode error_code);
void SetClockForTest(base::Clock* clock_for_test); void SetClockForTest(base::Clock* clock_for_test);
// The amount of time this operation will wait for a response. The timeout // The amount of time this operation will wait for a response. The timeout
...@@ -112,7 +128,7 @@ class ConnectTetheringOperation : public MessageTransferOperation { ...@@ -112,7 +128,7 @@ class ConnectTetheringOperation : public MessageTransferOperation {
// OnOperationFinished(). // OnOperationFinished().
std::string ssid_to_return_; std::string ssid_to_return_;
std::string password_to_return_; std::string password_to_return_;
ConnectTetheringResponse_ResponseCode error_code_to_return_; HostResponseErrorCode error_code_to_return_;
base::Time connect_tethering_request_start_time_; base::Time connect_tethering_request_start_time_;
base::ObserverList<Observer> observer_list_; base::ObserverList<Observer> observer_list_;
......
...@@ -46,7 +46,9 @@ class TestObserver final : public ConnectTetheringOperation::Observer { ...@@ -46,7 +46,9 @@ class TestObserver final : public ConnectTetheringOperation::Observer {
const std::string& password() { return password_; } const std::string& password() { return password_; }
bool has_received_failure() { return has_received_failure_; } bool has_received_failure() { return has_received_failure_; }
bool has_sent_request() { return has_sent_request_; } bool has_sent_request() { return has_sent_request_; }
ConnectTetheringResponse_ResponseCode error_code() { return error_code_; } ConnectTetheringOperation::HostResponseErrorCode error_code() {
return error_code_;
}
// ConnectTetheringOperation::Observer: // ConnectTetheringOperation::Observer:
void OnConnectTetheringRequestSent( void OnConnectTetheringRequestSent(
...@@ -65,7 +67,7 @@ class TestObserver final : public ConnectTetheringOperation::Observer { ...@@ -65,7 +67,7 @@ class TestObserver final : public ConnectTetheringOperation::Observer {
void OnConnectTetheringFailure( void OnConnectTetheringFailure(
const cryptauth::RemoteDevice& remote_device, const cryptauth::RemoteDevice& remote_device,
ConnectTetheringResponse_ResponseCode error_code) override { ConnectTetheringOperation::HostResponseErrorCode error_code) override {
has_received_failure_ = true; has_received_failure_ = true;
remote_device_ = remote_device; remote_device_ = remote_device;
error_code_ = error_code; error_code_ = error_code;
...@@ -77,7 +79,7 @@ class TestObserver final : public ConnectTetheringOperation::Observer { ...@@ -77,7 +79,7 @@ class TestObserver final : public ConnectTetheringOperation::Observer {
std::string password_; std::string password_;
bool has_received_failure_ = false; bool has_received_failure_ = false;
bool has_sent_request_ = false; bool has_sent_request_ = false;
ConnectTetheringResponse_ResponseCode error_code_; ConnectTetheringOperation::HostResponseErrorCode error_code_;
}; };
std::string CreateConnectTetheringRequestString() { std::string CreateConnectTetheringRequestString() {
...@@ -154,6 +156,7 @@ class ConnectTetheringOperationTest : public testing::Test { ...@@ -154,6 +156,7 @@ class ConnectTetheringOperationTest : public testing::Test {
void SimulateResponseReceivedAndVerifyObserverCallbackInvoked( void SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode response_code, ConnectTetheringResponse_ResponseCode response_code,
ConnectTetheringOperation::HostResponseErrorCode expected_error_code,
bool use_proto_without_ssid_and_password) { bool use_proto_without_ssid_and_password) {
test_clock_.Advance(kConnectTetheringResponseTime); test_clock_.Advance(kConnectTetheringResponseTime);
...@@ -184,7 +187,7 @@ class ConnectTetheringOperationTest : public testing::Test { ...@@ -184,7 +187,7 @@ class ConnectTetheringOperationTest : public testing::Test {
EXPECT_EQ(std::string(kTestPassword), test_observer_->password()); EXPECT_EQ(std::string(kTestPassword), test_observer_->password());
} else { } else {
EXPECT_TRUE(test_observer_->has_received_failure()); EXPECT_TRUE(test_observer_->has_received_failure());
EXPECT_EQ(expected_response_code, test_observer_->error_code()); EXPECT_EQ(expected_error_code, test_observer_->error_code());
} }
histogram_tester_.ExpectTimeBucketCount( histogram_tester_.ExpectTimeBucketCount(
...@@ -228,6 +231,8 @@ TEST_F(ConnectTetheringOperationTest, TestOperation_SuccessButInvalidResponse) { ...@@ -228,6 +231,8 @@ TEST_F(ConnectTetheringOperationTest, TestOperation_SuccessButInvalidResponse) {
SimulateResponseReceivedAndVerifyObserverCallbackInvoked( SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS, ConnectTetheringResponse_ResponseCode_SUCCESS,
ConnectTetheringOperation::HostResponseErrorCode::
INVALID_HOTSPOT_CREDENTIALS,
true /* use_proto_without_ssid_and_password */); true /* use_proto_without_ssid_and_password */);
} }
...@@ -239,6 +244,7 @@ TEST_F(ConnectTetheringOperationTest, TestOperation_SuccessWithValidResponse) { ...@@ -239,6 +244,7 @@ TEST_F(ConnectTetheringOperationTest, TestOperation_SuccessWithValidResponse) {
SimulateResponseReceivedAndVerifyObserverCallbackInvoked( SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS, ConnectTetheringResponse_ResponseCode_SUCCESS,
ConnectTetheringOperation::HostResponseErrorCode::UNKNOWN_ERROR,
false /* use_proto_without_ssid_and_password */); false /* use_proto_without_ssid_and_password */);
} }
...@@ -251,6 +257,7 @@ TEST_F(ConnectTetheringOperationTest, TestOperation_UnknownError) { ...@@ -251,6 +257,7 @@ TEST_F(ConnectTetheringOperationTest, TestOperation_UnknownError) {
SimulateResponseReceivedAndVerifyObserverCallbackInvoked( SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR, ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR,
ConnectTetheringOperation::HostResponseErrorCode::UNKNOWN_ERROR,
false /* use_proto_without_ssid_and_password */); false /* use_proto_without_ssid_and_password */);
} }
...@@ -263,6 +270,7 @@ TEST_F(ConnectTetheringOperationTest, TestOperation_ProvisioningFailed) { ...@@ -263,6 +270,7 @@ TEST_F(ConnectTetheringOperationTest, TestOperation_ProvisioningFailed) {
SimulateResponseReceivedAndVerifyObserverCallbackInvoked( SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED, ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED,
ConnectTetheringOperation::HostResponseErrorCode::PROVISIONING_FAILED,
false /* use_proto_without_ssid_and_password */); false /* use_proto_without_ssid_and_password */);
} }
...@@ -278,8 +286,7 @@ TEST_F(ConnectTetheringOperationTest, TestCannotConnect) { ...@@ -278,8 +286,7 @@ TEST_F(ConnectTetheringOperationTest, TestCannotConnect) {
// The maximum number of connection failures has occurred. // The maximum number of connection failures has occurred.
EXPECT_TRUE(test_observer_->has_received_failure()); EXPECT_TRUE(test_observer_->has_received_failure());
EXPECT_EQ(ConnectTetheringResponse_ResponseCode:: EXPECT_EQ(ConnectTetheringOperation::HostResponseErrorCode::NO_RESPONSE,
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR,
test_observer_->error_code()); test_observer_->error_code());
histogram_tester_.ExpectTotalCount( histogram_tester_.ExpectTotalCount(
......
...@@ -95,6 +95,15 @@ void HostConnectionMetricsLogger::RecordConnectionToHostResult( ...@@ -95,6 +95,15 @@ void HostConnectionMetricsLogger::RecordConnectionToHostResult(
RecordConnectionResultFailure( RecordConnectionResultFailure(
ConnectionToHostResult_FailureEventType::ENABLING_HOTSPOT_TIMEOUT); ConnectionToHostResult_FailureEventType::ENABLING_HOTSPOT_TIMEOUT);
break; break;
case ConnectionToHostResult::CONNECTION_RESULT_FAILURE_NO_RESPONSE:
RecordConnectionResultFailure(
ConnectionToHostResult_FailureEventType::NO_RESPONSE);
break;
case ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_INVALID_HOTSPOT_CREDENTIALS:
RecordConnectionResultFailure(
ConnectionToHostResult_FailureEventType::INVALID_HOTSPOT_CREDENTIALS);
break;
default: default:
NOTREACHED(); NOTREACHED();
}; };
......
...@@ -40,7 +40,9 @@ class HostConnectionMetricsLogger ...@@ -40,7 +40,9 @@ class HostConnectionMetricsLogger
CONNECTION_RESULT_FAILURE_TETHERING_UNSUPPORTED, CONNECTION_RESULT_FAILURE_TETHERING_UNSUPPORTED,
CONNECTION_RESULT_FAILURE_NO_CELL_DATA, CONNECTION_RESULT_FAILURE_NO_CELL_DATA,
CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_FAILED, CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_FAILED,
CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_TIMEOUT CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_TIMEOUT,
CONNECTION_RESULT_FAILURE_NO_RESPONSE,
CONNECTION_RESULT_FAILURE_INVALID_HOTSPOT_CREDENTIALS
}; };
// Record the result of an attempted host connection. // Record the result of an attempted host connection.
...@@ -105,6 +107,11 @@ class HostConnectionMetricsLogger ...@@ -105,6 +107,11 @@ class HostConnectionMetricsLogger
RecordConnectToHostDuration); RecordConnectToHostDuration);
FRIEND_TEST_ALL_PREFIXES(HostConnectionMetricsLoggerTest, FRIEND_TEST_ALL_PREFIXES(HostConnectionMetricsLoggerTest,
RecordConnectToHostDuration_Background); RecordConnectToHostDuration_Background);
FRIEND_TEST_ALL_PREFIXES(HostConnectionMetricsLoggerTest,
RecordConnectionResultFailureNoResponse);
FRIEND_TEST_ALL_PREFIXES(
HostConnectionMetricsLoggerTest,
RecordConnectionResultFailureInvalidHotspotCredentials);
// An Instant Tethering connection can fail for several different reasons. // An Instant Tethering connection can fail for several different reasons.
// Though traditionally success and each failure case would be logged to a // Though traditionally success and each failure case would be logged to a
...@@ -140,6 +147,8 @@ class HostConnectionMetricsLogger ...@@ -140,6 +147,8 @@ class HostConnectionMetricsLogger
NO_CELL_DATA = 4, NO_CELL_DATA = 4,
ENABLING_HOTSPOT_FAILED = 5, ENABLING_HOTSPOT_FAILED = 5,
ENABLING_HOTSPOT_TIMEOUT = 6, ENABLING_HOTSPOT_TIMEOUT = 6,
NO_RESPONSE = 7,
INVALID_HOTSPOT_CREDENTIALS = 8,
FAILURE_MAX FAILURE_MAX
}; };
......
...@@ -464,6 +464,41 @@ TEST_F(HostConnectionMetricsLoggerTest, ...@@ -464,6 +464,41 @@ TEST_F(HostConnectionMetricsLoggerTest,
VerifyConnectToHostDuration(true /* is_background_advertisement */); VerifyConnectToHostDuration(true /* is_background_advertisement */);
} }
TEST_F(HostConnectionMetricsLoggerTest,
RecordConnectionResultFailureNoResponse) {
SetActiveHostToConnectingAndReceiveAdvertisement(
test_devices_[0].GetDeviceId(), false /* is_background_advertisement */);
metrics_logger_->RecordConnectionToHostResult(
HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_NO_RESPONSE,
test_devices_[0].GetDeviceId());
VerifyFailure(HostConnectionMetricsLogger::
ConnectionToHostResult_FailureEventType::NO_RESPONSE);
VerifySuccess(HostConnectionMetricsLogger::
ConnectionToHostResult_SuccessEventType::FAILURE,
false /* is_background_advertisement */);
}
TEST_F(HostConnectionMetricsLoggerTest,
RecordConnectionResultFailureInvalidHotspotCredentials) {
SetActiveHostToConnectingAndReceiveAdvertisement(
test_devices_[0].GetDeviceId(), false /* is_background_advertisement */);
metrics_logger_->RecordConnectionToHostResult(
HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_INVALID_HOTSPOT_CREDENTIALS,
test_devices_[0].GetDeviceId());
VerifyFailure(
HostConnectionMetricsLogger::ConnectionToHostResult_FailureEventType::
INVALID_HOTSPOT_CREDENTIALS);
VerifySuccess(HostConnectionMetricsLogger::
ConnectionToHostResult_SuccessEventType::FAILURE,
false /* is_background_advertisement */);
}
} // namespace tether } // namespace tether
} // namespace chromeos } // namespace chromeos
...@@ -202,7 +202,7 @@ void TetherConnectorImpl::OnSuccessfulConnectTetheringResponse( ...@@ -202,7 +202,7 @@ void TetherConnectorImpl::OnSuccessfulConnectTetheringResponse(
void TetherConnectorImpl::OnConnectTetheringFailure( void TetherConnectorImpl::OnConnectTetheringFailure(
const cryptauth::RemoteDevice& remote_device, const cryptauth::RemoteDevice& remote_device,
ConnectTetheringResponse_ResponseCode error_code) { ConnectTetheringOperation::HostResponseErrorCode error_code) {
std::string device_id_copy = remote_device.GetDeviceId(); std::string device_id_copy = remote_device.GetDeviceId();
if (device_id_pending_connection_ != device_id_copy) { if (device_id_pending_connection_ != device_id_copy) {
// If the failure was part of a previous attempt for a different device, // If the failure was part of a previous attempt for a different device,
...@@ -366,17 +366,15 @@ void TetherConnectorImpl::OnWifiConnection( ...@@ -366,17 +366,15 @@ void TetherConnectorImpl::OnWifiConnection(
HostConnectionMetricsLogger::ConnectionToHostResult HostConnectionMetricsLogger::ConnectionToHostResult
TetherConnectorImpl::GetConnectionToHostResultFromErrorCode( TetherConnectorImpl::GetConnectionToHostResultFromErrorCode(
const std::string& device_id, const std::string& device_id,
ConnectTetheringResponse_ResponseCode error_code) { ConnectTetheringOperation::HostResponseErrorCode error_code) {
if (error_code == if (error_code ==
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::PROVISIONING_FAILED) {
ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED) {
return HostConnectionMetricsLogger::ConnectionToHostResult:: return HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_PROVISIONING_FAILED; CONNECTION_RESULT_PROVISIONING_FAILED;
} }
if (error_code == if (error_code ==
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::TETHERING_TIMEOUT) {
ConnectTetheringResponse_ResponseCode_TETHERING_TIMEOUT) {
const std::string tether_network_guid = const std::string tether_network_guid =
device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId( device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId(
device_id); device_id);
...@@ -390,34 +388,43 @@ TetherConnectorImpl::GetConnectionToHostResultFromErrorCode( ...@@ -390,34 +388,43 @@ TetherConnectorImpl::GetConnectionToHostResultFromErrorCode(
} }
if (error_code == if (error_code ==
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::TETHERING_UNSUPPORTED) {
ConnectTetheringResponse_ResponseCode_TETHERING_UNSUPPORTED) {
return HostConnectionMetricsLogger::ConnectionToHostResult:: return HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_TETHERING_UNSUPPORTED; CONNECTION_RESULT_FAILURE_TETHERING_UNSUPPORTED;
} }
if (error_code == ConnectTetheringResponse_ResponseCode:: if (error_code ==
ConnectTetheringResponse_ResponseCode_NO_CELL_DATA) { ConnectTetheringOperation::HostResponseErrorCode::NO_CELL_DATA) {
return HostConnectionMetricsLogger::ConnectionToHostResult:: return HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_NO_CELL_DATA; CONNECTION_RESULT_FAILURE_NO_CELL_DATA;
} }
if (error_code == if (error_code == ConnectTetheringOperation::HostResponseErrorCode::
ConnectTetheringResponse_ResponseCode:: ENABLING_HOTSPOT_FAILED) {
ConnectTetheringResponse_ResponseCode_ENABLING_HOTSPOT_FAILED) {
return HostConnectionMetricsLogger::ConnectionToHostResult:: return HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_FAILED; CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_FAILED;
} }
if (error_code == if (error_code == ConnectTetheringOperation::HostResponseErrorCode::
ConnectTetheringResponse_ResponseCode:: ENABLING_HOTSPOT_TIMEOUT) {
ConnectTetheringResponse_ResponseCode_ENABLING_HOTSPOT_TIMEOUT) {
return HostConnectionMetricsLogger::ConnectionToHostResult:: return HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_TIMEOUT; CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_TIMEOUT;
} }
if (error_code ==
ConnectTetheringOperation::HostResponseErrorCode::UNKNOWN_ERROR) {
return HostConnectionMetricsLogger::ConnectionToHostResult:: return HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR; CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR;
}
if (error_code == ConnectTetheringOperation::HostResponseErrorCode::
INVALID_HOTSPOT_CREDENTIALS) {
return HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_INVALID_HOTSPOT_CREDENTIALS;
}
return HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_NO_RESPONSE;
} }
} // namespace tether } // namespace tether
......
...@@ -69,7 +69,7 @@ class TetherConnectorImpl : public TetherConnector, ...@@ -69,7 +69,7 @@ class TetherConnectorImpl : public TetherConnector,
const std::string& password) override; const std::string& password) override;
void OnConnectTetheringFailure( void OnConnectTetheringFailure(
const cryptauth::RemoteDevice& remote_device, const cryptauth::RemoteDevice& remote_device,
ConnectTetheringResponse_ResponseCode error_code) override; ConnectTetheringOperation::HostResponseErrorCode error_code) override;
private: private:
friend class TetherConnectorImplTest; friend class TetherConnectorImplTest;
...@@ -88,7 +88,7 @@ class TetherConnectorImpl : public TetherConnector, ...@@ -88,7 +88,7 @@ class TetherConnectorImpl : public TetherConnector,
HostConnectionMetricsLogger::ConnectionToHostResult HostConnectionMetricsLogger::ConnectionToHostResult
GetConnectionToHostResultFromErrorCode( GetConnectionToHostResultFromErrorCode(
const std::string& device_id, const std::string& device_id,
ConnectTetheringResponse_ResponseCode error_code); ConnectTetheringOperation::HostResponseErrorCode error_code);
NetworkConnectionHandler* network_connection_handler_; NetworkConnectionHandler* network_connection_handler_;
NetworkStateHandler* network_state_handler_; NetworkStateHandler* network_state_handler_;
......
...@@ -82,7 +82,8 @@ class FakeConnectTetheringOperation : public ConnectTetheringOperation { ...@@ -82,7 +82,8 @@ class FakeConnectTetheringOperation : public ConnectTetheringOperation {
NotifyObserversOfSuccessfulResponse(ssid, password); NotifyObserversOfSuccessfulResponse(ssid, password);
} }
void SendFailedResponse(ConnectTetheringResponse_ResponseCode error_code) { void SendFailedResponse(
ConnectTetheringOperation::HostResponseErrorCode error_code) {
NotifyObserversOfConnectionFailure(error_code); NotifyObserversOfConnectionFailure(error_code);
} }
...@@ -254,7 +255,7 @@ class TetherConnectorImplTest : public NetworkStateTest { ...@@ -254,7 +255,7 @@ class TetherConnectorImplTest : public NetworkStateTest {
} }
void VerifyConnectTetheringOperationFails( void VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode response_code, ConnectTetheringOperation::HostResponseErrorCode response_code,
bool setup_required, bool setup_required,
HostConnectionMetricsLogger::ConnectionToHostResult expected_event_type) { HostConnectionMetricsLogger::ConnectionToHostResult expected_event_type) {
EXPECT_CALL(*mock_host_connection_metrics_logger_, EXPECT_CALL(*mock_host_connection_metrics_logger_,
...@@ -400,8 +401,7 @@ TEST_F(TetherConnectorImplTest, TestCancelWhileOperationActive) { ...@@ -400,8 +401,7 @@ TEST_F(TetherConnectorImplTest, TestCancelWhileOperationActive) {
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_SetupNotRequired) { TestConnectTetheringOperationFails_SetupNotRequired) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::UNKNOWN_ERROR,
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR,
false /* setup_required */, false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR); CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR);
...@@ -410,8 +410,7 @@ TEST_F(TetherConnectorImplTest, ...@@ -410,8 +410,7 @@ TEST_F(TetherConnectorImplTest,
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_SetupRequired) { TestConnectTetheringOperationFails_SetupRequired) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::UNKNOWN_ERROR,
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR,
true /* setup_required */, true /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR); CONNECTION_RESULT_FAILURE_UNKNOWN_ERROR);
...@@ -420,8 +419,7 @@ TEST_F(TetherConnectorImplTest, ...@@ -420,8 +419,7 @@ TEST_F(TetherConnectorImplTest,
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_ProvisioningFailed) { TestConnectTetheringOperationFails_ProvisioningFailed) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::PROVISIONING_FAILED,
ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED,
false /* setup_required */, false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_PROVISIONING_FAILED); CONNECTION_RESULT_PROVISIONING_FAILED);
...@@ -430,8 +428,7 @@ TEST_F(TetherConnectorImplTest, ...@@ -430,8 +428,7 @@ TEST_F(TetherConnectorImplTest,
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_TetheringTimeout_SetupNotRequired) { TestConnectTetheringOperationFails_TetheringTimeout_SetupNotRequired) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::TETHERING_TIMEOUT,
ConnectTetheringResponse_ResponseCode_TETHERING_TIMEOUT,
false /* setup_required */, false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP_WAS_NOT_REQUIRED); CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP_WAS_NOT_REQUIRED);
...@@ -440,8 +437,7 @@ TEST_F(TetherConnectorImplTest, ...@@ -440,8 +437,7 @@ TEST_F(TetherConnectorImplTest,
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_TetheringTimeout_SetupRequired) { TestConnectTetheringOperationFails_TetheringTimeout_SetupRequired) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::TETHERING_TIMEOUT,
ConnectTetheringResponse_ResponseCode_TETHERING_TIMEOUT,
true /* setup_required */, true /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP_WAS_REQUIRED); CONNECTION_RESULT_FAILURE_TETHERING_TIMED_OUT_FIRST_TIME_SETUP_WAS_REQUIRED);
...@@ -450,8 +446,7 @@ TEST_F(TetherConnectorImplTest, ...@@ -450,8 +446,7 @@ TEST_F(TetherConnectorImplTest,
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_TetheringUnsupported) { TestConnectTetheringOperationFails_TetheringUnsupported) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::TETHERING_UNSUPPORTED,
ConnectTetheringResponse_ResponseCode_TETHERING_UNSUPPORTED,
false /* setup_required */, false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_TETHERING_UNSUPPORTED); CONNECTION_RESULT_FAILURE_TETHERING_UNSUPPORTED);
...@@ -459,8 +454,7 @@ TEST_F(TetherConnectorImplTest, ...@@ -459,8 +454,7 @@ TEST_F(TetherConnectorImplTest,
TEST_F(TetherConnectorImplTest, TestConnectTetheringOperationFails_NoCellData) { TEST_F(TetherConnectorImplTest, TestConnectTetheringOperationFails_NoCellData) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::NO_CELL_DATA,
ConnectTetheringResponse_ResponseCode_NO_CELL_DATA,
false /* setup_required */, false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_NO_CELL_DATA); CONNECTION_RESULT_FAILURE_NO_CELL_DATA);
...@@ -469,8 +463,7 @@ TEST_F(TetherConnectorImplTest, TestConnectTetheringOperationFails_NoCellData) { ...@@ -469,8 +463,7 @@ TEST_F(TetherConnectorImplTest, TestConnectTetheringOperationFails_NoCellData) {
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_EnableHotspotFailed) { TestConnectTetheringOperationFails_EnableHotspotFailed) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::ENABLING_HOTSPOT_FAILED,
ConnectTetheringResponse_ResponseCode_ENABLING_HOTSPOT_FAILED,
false /* setup_required */, false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_FAILED); CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_FAILED);
...@@ -479,13 +472,31 @@ TEST_F(TetherConnectorImplTest, ...@@ -479,13 +472,31 @@ TEST_F(TetherConnectorImplTest,
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_EnableHotspotTimeout) { TestConnectTetheringOperationFails_EnableHotspotTimeout) {
VerifyConnectTetheringOperationFails( VerifyConnectTetheringOperationFails(
ConnectTetheringResponse_ResponseCode:: ConnectTetheringOperation::HostResponseErrorCode::
ConnectTetheringResponse_ResponseCode_ENABLING_HOTSPOT_TIMEOUT, ENABLING_HOTSPOT_TIMEOUT,
false /* setup_required */, false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult:: HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_TIMEOUT); CONNECTION_RESULT_FAILURE_ENABLING_HOTSPOT_TIMEOUT);
} }
TEST_F(TetherConnectorImplTest, TestConnectTetheringOperationFails_NoResponse) {
VerifyConnectTetheringOperationFails(
ConnectTetheringOperation::HostResponseErrorCode::NO_RESPONSE,
false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_NO_RESPONSE);
}
TEST_F(TetherConnectorImplTest,
TestConnectTetheringOperationFails_InvalidHotspotCredentials) {
VerifyConnectTetheringOperationFails(
ConnectTetheringOperation::HostResponseErrorCode::
INVALID_HOTSPOT_CREDENTIALS,
false /* setup_required */,
HostConnectionMetricsLogger::ConnectionToHostResult::
CONNECTION_RESULT_FAILURE_INVALID_HOTSPOT_CREDENTIALS);
}
TEST_F(TetherConnectorImplTest, TEST_F(TetherConnectorImplTest,
ConnectionToHostFailedNotificationRemovedWhenConnectionStarts) { ConnectionToHostFailedNotificationRemovedWhenConnectionStarts) {
// Start with the "connection to host failed" notification showing. // Start with the "connection to host failed" notification showing.
......
...@@ -23869,6 +23869,8 @@ Called by update_gpu_driver_bug_workaround_entries.py.--> ...@@ -23869,6 +23869,8 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
<int value="4" label="No cellular data"/> <int value="4" label="No cellular data"/>
<int value="5" label="Enabling hotspot failed"/> <int value="5" label="Enabling hotspot failed"/>
<int value="6" label="Enabling hotspot timed out"/> <int value="6" label="Enabling hotspot timed out"/>
<int value="7" label="No response"/>
<int value="8" label="Invalid hotspot credentials"/>
</enum> </enum>
<enum name="InstantTethering_ConnectionToHostResult_Failure_ClientConnection"> <enum name="InstantTethering_ConnectionToHostResult_Failure_ClientConnection">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment