Skip to content

Commit

Permalink
analytics: Update analytics version to v1.5.0
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 699470135
  • Loading branch information
edwinwugoog authored and copybara-github committed Dec 11, 2024
1 parent d9b2f1a commit 5270cb6
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 46 deletions.
18 changes: 9 additions & 9 deletions connections/implementation/analytics/analytics_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ namespace nearby {
namespace analytics {

namespace {
const char kVersion[] = "v1.0.0";
// const char kVersion_1_0_0[] = "v1.0.0";
const char kVersion [] = "v1.5.0";
constexpr absl::string_view kOnStartClientSession = "OnStartClientSession";
const absl::Duration kConnectionTokenMaxLife = absl::Hours(24);

Expand Down Expand Up @@ -107,8 +108,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;
Expand Down Expand Up @@ -537,7 +537,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());
Expand Down Expand Up @@ -625,7 +625,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());
Expand Down Expand Up @@ -1359,7 +1359,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) {
Expand Down Expand Up @@ -1462,7 +1462,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;
Expand Down Expand Up @@ -1732,9 +1732,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() {
Expand Down
2 changes: 1 addition & 1 deletion connections/implementation/analytics/analytics_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion connections/implementation/base_endpoint_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
2 changes: 1 addition & 1 deletion connections/implementation/base_pcp_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions connections/implementation/internal_payload_factory_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions connections/implementation/mediums/ble.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 2 additions & 4 deletions connections/implementation/mediums/ble_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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()) {
Expand Down
14 changes: 4 additions & 10 deletions connections/implementation/mediums/bluetooth_classic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down
3 changes: 1 addition & 2 deletions connections/implementation/mediums/wifi_direct.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
3 changes: 1 addition & 2 deletions connections/implementation/mediums/wifi_hotspot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
12 changes: 4 additions & 8 deletions connections/implementation/mediums/wifi_lan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 5270cb6

Please sign in to comment.