mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
analytics: Modify OperationResultCode in C++ implementation
PiperOrigin-RevId: 704951400
This commit is contained in:
committed by
Copybara-Service
parent
d9b2f1aaa9
commit
fb2e7e687b
@@ -107,8 +107,7 @@ using ::nearby::analytics::EventLogger;
|
||||
using SafeDisconnectionResult = ::location::nearby::analytics::proto::
|
||||
ConnectionsLog::EstablishedConnection::SafeDisconnectionResult;
|
||||
|
||||
// TODO(edwinwu): Add ifttt in Android counterpart.
|
||||
OperationResultCategory ConvertToOperationResultCateory(
|
||||
OperationResultCategory ConvertToOperationResultCategory(
|
||||
OperationResultCode result_code) {
|
||||
if (result_code == OperationResultCode::DETAIL_SUCCESS) {
|
||||
return OperationResultCategory::CATEGORY_SUCCESS;
|
||||
@@ -537,7 +536,7 @@ void AnalyticsRecorder::OnIncomingConnectionAttemptLocked(
|
||||
std::make_unique<ConnectionsLog::OperationResult>();
|
||||
operation_result_proto->set_result_code(
|
||||
connection_attempt_metadata_params->operation_result_code);
|
||||
operation_result_proto->set_result_category(ConvertToOperationResultCateory(
|
||||
operation_result_proto->set_result_category(ConvertToOperationResultCategory(
|
||||
connection_attempt_metadata_params->operation_result_code));
|
||||
connection_attempt->set_allocated_operation_result(
|
||||
operation_result_proto.release());
|
||||
@@ -625,7 +624,7 @@ void AnalyticsRecorder::OnOutgoingConnectionAttemptLocked(
|
||||
std::make_unique<ConnectionsLog::OperationResult>();
|
||||
operation_result_proto->set_result_code(
|
||||
connection_attempt_metadata_params->operation_result_code);
|
||||
operation_result_proto->set_result_category(ConvertToOperationResultCateory(
|
||||
operation_result_proto->set_result_category(ConvertToOperationResultCategory(
|
||||
connection_attempt_metadata_params->operation_result_code));
|
||||
connection_attempt->set_allocated_operation_result(
|
||||
operation_result_proto.release());
|
||||
@@ -1359,7 +1358,7 @@ void AnalyticsRecorder::FinishUpgradeAttemptLocked(
|
||||
std::make_unique<ConnectionsLog::OperationResult>();
|
||||
operation_result_proto->set_result_code(operation_result_code);
|
||||
operation_result_proto->set_result_category(
|
||||
ConvertToOperationResultCateory(operation_result_code));
|
||||
ConvertToOperationResultCategory(operation_result_code));
|
||||
attempt->set_allocated_operation_result(operation_result_proto.release());
|
||||
*current_strategy_session_->add_upgrade_attempt() = *attempt;
|
||||
if (erase_item) {
|
||||
@@ -1462,7 +1461,7 @@ ConnectionsLog::Payload AnalyticsRecorder::PendingPayload::GetProtoPayload(
|
||||
std::make_unique<ConnectionsLog::OperationResult>();
|
||||
operation_result_proto->set_result_code(operation_result_code_);
|
||||
operation_result_proto->set_result_category(
|
||||
ConvertToOperationResultCateory(operation_result_code_));
|
||||
ConvertToOperationResultCategory(operation_result_code_));
|
||||
payload.set_allocated_operation_result(operation_result_proto.release());
|
||||
|
||||
return payload;
|
||||
@@ -1732,9 +1731,9 @@ AnalyticsRecorder::LogicalConnection::GetPendingPayloadResultCodeFromReason(
|
||||
}
|
||||
}
|
||||
|
||||
OperationResultCategory AnalyticsRecorder::GetOperationResultCateory(
|
||||
OperationResultCategory AnalyticsRecorder::GetOperationResultCategory(
|
||||
location::nearby::proto::connections::OperationResultCode result_code) {
|
||||
return ConvertToOperationResultCateory(result_code);
|
||||
return ConvertToOperationResultCategory(result_code);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::Sync() {
|
||||
|
||||
@@ -227,7 +227,7 @@ class AnalyticsRecorder {
|
||||
bool IsSessionLogged();
|
||||
|
||||
location::nearby::proto::connections::OperationResultCategory
|
||||
GetOperationResultCateory(
|
||||
GetOperationResultCategory(
|
||||
location::nearby::proto::connections::OperationResultCode result_code);
|
||||
|
||||
// Waits until all logs are sent to the backend.
|
||||
|
||||
@@ -91,7 +91,7 @@ BaseEndpointChannel::BaseEndpointChannel(const std::string& service_id,
|
||||
service_id, channel_name, reader, writer,
|
||||
// TODO(edwinwu): Below values should be retrieved from a base socket,
|
||||
// the #MediumSocket in Android counterpart, from which all the
|
||||
// derived medium sockets should dervied, and implement the supported
|
||||
// derived medium sockets should derived, and implement the supported
|
||||
// values and leave the default values in base #MediumSocket.
|
||||
/*ConnectionTechnology*/
|
||||
location::nearby::proto::connections::
|
||||
|
||||
@@ -1159,7 +1159,7 @@ BasePcpHandler::GetOperationResultWithMediumByResultCode(
|
||||
operation_result_with_medium->set_medium(medium);
|
||||
operation_result_with_medium->set_result_code(operation_result_code);
|
||||
operation_result_with_medium->set_result_category(
|
||||
client->GetAnalyticsRecorder().GetOperationResultCateory(
|
||||
client->GetAnalyticsRecorder().GetOperationResultCategory(
|
||||
operation_result_code));
|
||||
operation_result_with_medium->set_connection_mode(connection_mode);
|
||||
operation_result_with_medium->set_update_index(update_index);
|
||||
|
||||
@@ -214,11 +214,11 @@ TEST(InternalPayloadFactoryTest,
|
||||
Payload::Id payload_id = Payload::GenerateId();
|
||||
CreateFileWithContents(payload_id, contents);
|
||||
InputFile inputFile(payload_id, contents.size());
|
||||
ErrorOr<std::unique_ptr<InternalPayload>> interal_payload_result =
|
||||
ErrorOr<std::unique_ptr<InternalPayload>> internal_payload_result =
|
||||
CreateOutgoingInternalPayload(Payload{payload_id, std::move(inputFile)});
|
||||
ASSERT_FALSE(interal_payload_result.has_error());
|
||||
ASSERT_FALSE(internal_payload_result.has_error());
|
||||
std::unique_ptr<InternalPayload> internal_payload =
|
||||
std::move(interal_payload_result.value());
|
||||
std::move(internal_payload_result.value());
|
||||
EXPECT_NE(internal_payload, nullptr);
|
||||
|
||||
ExceptionOr<size_t> result = internal_payload->SkipToOffset(kOffset);
|
||||
@@ -236,11 +236,11 @@ TEST(InternalPayloadFactoryTest,
|
||||
ByteArray contents("0123456789");
|
||||
constexpr size_t kOffset = 6;
|
||||
auto [input, output] = CreatePipe();
|
||||
ErrorOr<std::unique_ptr<InternalPayload>> interal_payload_result =
|
||||
ErrorOr<std::unique_ptr<InternalPayload>> internal_payload_result =
|
||||
CreateOutgoingInternalPayload(Payload(std::move(input)));
|
||||
ASSERT_FALSE(interal_payload_result.has_error());
|
||||
ASSERT_FALSE(internal_payload_result.has_error());
|
||||
std::unique_ptr<InternalPayload> internal_payload =
|
||||
std::move(interal_payload_result.value());
|
||||
std::move(internal_payload_result.value());
|
||||
EXPECT_NE(internal_payload, nullptr);
|
||||
output->Write(contents);
|
||||
|
||||
|
||||
@@ -403,8 +403,7 @@ ErrorOr<BleSocket> Ble::Connect(BlePeripheral& peripheral,
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create BLE socket with empty service_id.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
|
||||
@@ -353,8 +353,7 @@ ErrorOr<bool> BleV2::StartScanning(const std::string& service_id,
|
||||
|
||||
if (service_id.empty()) {
|
||||
LOG(INFO) << "Can not start BLE scanning with empty service id.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (IsScanningLocked(service_id)) {
|
||||
@@ -612,8 +611,7 @@ ErrorOr<BleV2Socket> BleV2::Connect(const std::string& service_id,
|
||||
if (service_id.empty()) {
|
||||
LOG(INFO) << "Refusing to create client Ble socket because "
|
||||
"service_id is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
|
||||
@@ -132,9 +132,7 @@ ErrorOr<bool> BluetoothClassic::TurnOnDiscoverability(
|
||||
LOG(INFO) << "Refusing to turn on BT discoverability; new name='"
|
||||
<< device_name << "'; current name='" << adapter_.GetName()
|
||||
<< "'";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(
|
||||
OperationResultCode::CONNECTIVITY_BLUETOOTH_CHANGE_SCAN_MODE_FAILURE)};
|
||||
return {Error(OperationResultCode::CONNECTIVITY_BLUETOOTH_SCAN_FAILURE)};
|
||||
}
|
||||
|
||||
if (!ModifyDeviceName(device_name)) {
|
||||
@@ -233,8 +231,7 @@ ErrorOr<bool> BluetoothClassic::StartDiscovery(
|
||||
|
||||
if (serviceId.empty()) {
|
||||
LOG(INFO) << "Refusing to start discovery; service ID is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
@@ -287,7 +284,6 @@ ErrorOr<bool> BluetoothClassic::StartDiscovery(
|
||||
|
||||
AddDiscoveryCallback(serviceId, std::move(callback));
|
||||
|
||||
// TODO(edwinwu): See if platform code needs to return ErrorOr<bool>
|
||||
if (!medium_->StartDiscovery(std::move(medium_callback))) {
|
||||
LOG(INFO) << "Failed to start discovery of BT devices.";
|
||||
RemoveDiscoveryCallback(serviceId);
|
||||
@@ -344,8 +340,7 @@ ErrorOr<bool> BluetoothClassic::StartAcceptingConnections(
|
||||
if (service_id.empty()) {
|
||||
LOG(INFO)
|
||||
<< "Refusing to start accepting BT connections; service ID is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
@@ -571,8 +566,7 @@ ErrorOr<BluetoothSocket> BluetoothClassic::AttemptToConnect(
|
||||
if (service_id.empty()) {
|
||||
LOG(WARNING)
|
||||
<< "Refusing to create client BT socket because service_id is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
|
||||
@@ -269,8 +269,7 @@ ErrorOr<WifiDirectSocket> WifiDirect::Connect(
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create client WifiDirect socket because "
|
||||
"service_id is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsGCAvailableLocked()) {
|
||||
|
||||
@@ -268,8 +268,7 @@ ErrorOr<WifiHotspotSocket> WifiHotspot::Connect(
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create client WifiHotspot socket because "
|
||||
"service_id is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsClientAvailableLocked()) {
|
||||
|
||||
@@ -176,8 +176,7 @@ ErrorOr<bool> WifiLan::StartDiscovery(const std::string& service_id,
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
<< "Refusing to start WifiLan discovering with empty service_id.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
@@ -244,8 +243,7 @@ ErrorOr<bool> WifiLan::StartAcceptingConnections(
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to start accepting WifiLan connections; "
|
||||
"service_id is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
@@ -438,8 +436,7 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create client WifiLan socket because "
|
||||
"service_id is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
@@ -493,8 +490,7 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create client WifiLan socket because "
|
||||
"service_id is empty.";
|
||||
// TODO(edwinwu): Modify new OperationResultCode
|
||||
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
|
||||
Reference in New Issue
Block a user