mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Remove legacy log macros.
PiperOrigin-RevId: 735161065
This commit is contained in:
committed by
Copybara-Service
parent
5038280159
commit
b8815f5229
+20
-22
@@ -127,25 +127,25 @@ std::unique_ptr<Advertisement> Advertisement::NewInstance(
|
||||
ShareTargetType device_type, std::optional<std::string> device_name,
|
||||
uint8_t vendor_id) {
|
||||
if (salt.size() != Advertisement::kSaltSize) {
|
||||
NL_LOG(ERROR) << "Failed to create advertisement because the salt did "
|
||||
"not match the expected length "
|
||||
<< salt.size();
|
||||
LOG(ERROR) << "Failed to create advertisement because the salt did "
|
||||
"not match the expected length "
|
||||
<< salt.size();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (encrypted_metadata_key.size() !=
|
||||
Advertisement::kMetadataEncryptionKeyHashByteSize) {
|
||||
NL_LOG(ERROR) << "Failed to create advertisement because the encrypted "
|
||||
"metadata key did "
|
||||
"not match the expected length "
|
||||
<< encrypted_metadata_key.size();
|
||||
LOG(ERROR) << "Failed to create advertisement because the encrypted "
|
||||
"metadata key did "
|
||||
"not match the expected length "
|
||||
<< encrypted_metadata_key.size();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (device_name.has_value() && device_name->size() > UINT8_MAX) {
|
||||
NL_LOG(ERROR) << "Failed to create advertisement because device name "
|
||||
"was over UINT8_MAX: "
|
||||
<< device_name->size();
|
||||
LOG(ERROR) << "Failed to create advertisement because device name "
|
||||
"was over UINT8_MAX: "
|
||||
<< device_name->size();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ std::unique_ptr<Advertisement> Advertisement::FromEndpointInfo(
|
||||
// name.
|
||||
// LINT.IfChange
|
||||
if (endpoint_info.size() < kMinimumSize) {
|
||||
NL_LOG(ERROR) << "Failed to parse advertisement because it was too short.";
|
||||
LOG(ERROR) << "Failed to parse advertisement because it was too short.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -208,9 +208,8 @@ std::unique_ptr<Advertisement> Advertisement::FromEndpointInfo(
|
||||
|
||||
int version = ParseVersion(first_byte);
|
||||
if (version < 0 || version > kMaxSupportedAdvertisementParsedVersionNumber) {
|
||||
NL_LOG(ERROR)
|
||||
<< "Failed to parse advertisement; unsupported version number "
|
||||
<< version;
|
||||
LOG(ERROR) << "Failed to parse advertisement; unsupported version number "
|
||||
<< version;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -231,10 +230,9 @@ std::unique_ptr<Advertisement> Advertisement::FromEndpointInfo(
|
||||
|
||||
if (device_name_length == 0 ||
|
||||
(endpoint_info.end() - iter < device_name_length)) {
|
||||
NL_LOG(ERROR)
|
||||
<< "Failed to parse advertisement because the device name did "
|
||||
"not match the expected length "
|
||||
<< device_name_length;
|
||||
LOG(ERROR) << "Failed to parse advertisement because the device name did "
|
||||
"not match the expected length "
|
||||
<< device_name_length;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -248,24 +246,24 @@ std::unique_ptr<Advertisement> Advertisement::FromEndpointInfo(
|
||||
TlvTypes type = static_cast<TlvTypes>(*iter++);
|
||||
uint8_t value_len = *iter++;
|
||||
if (endpoint_info.end() - iter < value_len) {
|
||||
NL_LOG(ERROR) << "Invalid length when parsing TLV element: " << value_len;
|
||||
LOG(ERROR) << "Invalid length when parsing TLV element: " << value_len;
|
||||
return nullptr;
|
||||
}
|
||||
switch (type) {
|
||||
case TlvTypes::kVendorId:
|
||||
if (value_len != kVendorIdLength) {
|
||||
NL_LOG(ERROR) << "Invalid vendor_id_len: " << value_len;
|
||||
LOG(ERROR) << "Invalid vendor_id_len: " << value_len;
|
||||
return nullptr;
|
||||
}
|
||||
vendor_id = ConvertVendorId(*iter++);
|
||||
break;
|
||||
case TlvTypes::kQrCode:
|
||||
NL_LOG(INFO) << "Found QR code data, skipping.";
|
||||
LOG(INFO) << "Found QR code data, skipping.";
|
||||
// TODO: b/341984671 - Implement handling for this TLV type.
|
||||
iter += value_len;
|
||||
break;
|
||||
default:
|
||||
NL_LOG(ERROR) << "Unknown TLV type: " << static_cast<uint8_t>(type);
|
||||
LOG(ERROR) << "Unknown TLV type: " << static_cast<uint8_t>(type);
|
||||
iter += value_len;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void NearbyShareCertificateStorage::UpdatePrivateCertificate(
|
||||
std::optional<std::vector<NearbySharePrivateCertificate>> certs =
|
||||
GetPrivateCertificates();
|
||||
if (!certs) {
|
||||
NL_LOG(WARNING) << __func__ << ": No private certificates to update.";
|
||||
LOG(WARNING) << __func__ << ": No private certificates to update.";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,12 +63,12 @@ void NearbyShareCertificateStorage::UpdatePrivateCertificate(
|
||||
return cert.id() == private_certificate.id();
|
||||
});
|
||||
if (it == certs->end()) {
|
||||
NL_VLOG(1) << __func__ << ": No private certificate with id="
|
||||
VLOG(1) << __func__ << ": No private certificate with id="
|
||||
<< nearby::utils::HexEncode(private_certificate.id());
|
||||
return;
|
||||
}
|
||||
|
||||
NL_VLOG(1) << __func__ << ": Updating private certificate id="
|
||||
VLOG(1) << __func__ << ": Updating private certificate id="
|
||||
<< nearby::utils::HexEncode(private_certificate.id());
|
||||
*it = private_certificate;
|
||||
ReplacePrivateCertificates(*certs);
|
||||
@@ -92,13 +92,13 @@ void NearbyShareCertificateStorage::RemoveExpiredPrivateCertificates(
|
||||
size_t num_removed = certs->size() - unexpired_certs.size();
|
||||
if (num_removed == 0) return;
|
||||
|
||||
NL_VLOG(1) << __func__ << ": Removing " << num_removed
|
||||
<< " expired private certificates.";
|
||||
VLOG(1) << __func__ << ": Removing " << num_removed
|
||||
<< " expired private certificates.";
|
||||
ReplacePrivateCertificates(unexpired_certs);
|
||||
}
|
||||
|
||||
void NearbyShareCertificateStorage::ClearPrivateCertificates() {
|
||||
NL_VLOG(1) << __func__ << ": Removing all private certificates.";
|
||||
VLOG(1) << __func__ << ": Removing all private certificates.";
|
||||
ReplacePrivateCertificates({});
|
||||
}
|
||||
|
||||
@@ -119,9 +119,8 @@ void NearbyShareCertificateStorage::ClearPrivateCertificatesOfVisibility(
|
||||
}
|
||||
|
||||
if (were_certs_removed) {
|
||||
NL_VLOG(1) << __func__
|
||||
<< ": Removing all private certificates of visibility "
|
||||
<< static_cast<int>(visibility);
|
||||
VLOG(1) << __func__ << ": Removing all private certificates of visibility "
|
||||
<< static_cast<int>(visibility);
|
||||
ReplacePrivateCertificates(new_certs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ std::optional<std::vector<uint8_t>> DecryptMetadataKey(
|
||||
std::unique_ptr<crypto::Encryptor> encryptor =
|
||||
CreateNearbyShareCtrEncryptor(secret_key, encrypted_metadata_key.salt());
|
||||
if (!encryptor) {
|
||||
NL_LOG(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Cannot decrypt metadata key: Could not create CTR encryptor.";
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -172,16 +172,16 @@ NearbyShareDecryptedPublicCertificate::DecryptPublicCertificate(
|
||||
auto decrypted_metadata_bytes = DecryptMetadataPayload(
|
||||
encrypted_metadata, *decrypted_metadata_key, secret_key.get());
|
||||
if (!decrypted_metadata_bytes) {
|
||||
NL_LOG(ERROR) << "Metadata decryption failed: Failed to decrypt metadata"
|
||||
<< "payload.";
|
||||
LOG(ERROR) << "Metadata decryption failed: Failed to decrypt metadata"
|
||||
<< "payload.";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
nearby::sharing::proto::EncryptedMetadata unencrypted_metadata;
|
||||
if (!unencrypted_metadata.ParseFromArray(decrypted_metadata_bytes->data(),
|
||||
decrypted_metadata_bytes->size())) {
|
||||
NL_LOG(ERROR) << "Metadata decryption failed: Failed to parse decrypted "
|
||||
<< "metadata payload.";
|
||||
LOG(ERROR) << "Metadata decryption failed: Failed to parse decrypted "
|
||||
<< "metadata payload.";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ bool NearbyShareDecryptedPublicCertificate::VerifySignature(
|
||||
crypto::SignatureVerifier verifier;
|
||||
if (!verifier.VerifyInit(crypto::SignatureVerifier::ECDSA_SHA256, signature,
|
||||
public_key_)) {
|
||||
NL_LOG(ERROR) << "Verification failed: Initialization unsuccessful.";
|
||||
LOG(ERROR) << "Verification failed: Initialization unsuccessful.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,9 +114,8 @@ IncomingShareSession::ProcessIntroduction(
|
||||
|
||||
for (const AppMetadata& apk : introduction_frame.app_metadata()) {
|
||||
if (apk.size() <= 0) {
|
||||
NL_LOG(WARNING)
|
||||
<< __func__
|
||||
<< ": Ignore introduction, due to invalid attachment size";
|
||||
LOG(WARNING) << __func__
|
||||
<< ": Ignore introduction, due to invalid attachment size";
|
||||
return TransferMetadata::Status::kUnsupportedAttachmentType;
|
||||
}
|
||||
|
||||
@@ -125,9 +124,9 @@ IncomingShareSession::ProcessIntroduction(
|
||||
<< ", package_name=" << apk.package_name()
|
||||
<< ", size=" << apk.size();
|
||||
if (std::numeric_limits<int64_t>::max() - apk.size() < file_size_sum) {
|
||||
NL_LOG(WARNING) << __func__
|
||||
<< ": Ignoring introduction, total file size overflowed "
|
||||
"64 bit integer.";
|
||||
LOG(WARNING) << __func__
|
||||
<< ": Ignoring introduction, total file size overflowed "
|
||||
"64 bit integer.";
|
||||
container.Clear();
|
||||
return TransferMetadata::Status::kNotEnoughSpace;
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ ConnectivityManagerImpl::ConnectivityManagerImpl(SharingPlatform& platform)
|
||||
bool is_lan_connected) {
|
||||
ConnectionType new_connection_type =
|
||||
static_cast<ConnectionType>(connection_type);
|
||||
NL_VLOG(1) << ": New connection type:"
|
||||
<< GetConnectionTypeString(new_connection_type);
|
||||
VLOG(1) << ": New connection type:"
|
||||
<< GetConnectionTypeString(new_connection_type);
|
||||
for (auto& listener : listeners_) {
|
||||
listener.second(new_connection_type, is_lan_connected);
|
||||
}
|
||||
|
||||
@@ -27,9 +27,4 @@
|
||||
// IWYU pragma: end_exports
|
||||
#endif // defined(NEARBY_CHROMIUM)
|
||||
|
||||
// Public APIs
|
||||
// The stream statement must come last, or it won't compile.
|
||||
#define NL_VLOG(level) VLOG(level)
|
||||
#define NL_LOG(severity) LOG(severity)
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_INTERNAL_PUBLIC_LOGGING_H_
|
||||
|
||||
@@ -58,11 +58,11 @@ void NearbyShareLocalDeviceDataManager::Stop() {
|
||||
void NearbyShareLocalDeviceDataManager::NotifyLocalDeviceDataChanged(
|
||||
bool did_device_name_change, bool did_full_name_change,
|
||||
bool did_icon_change) {
|
||||
NL_LOG(INFO) << __func__ << ": did_device_name_change="
|
||||
<< (did_device_name_change ? "true" : "false")
|
||||
<< ", did_full_name_change="
|
||||
<< (did_full_name_change ? "true" : "false")
|
||||
<< ", did_icon_change=" << (did_icon_change ? "true" : "false");
|
||||
LOG(INFO) << __func__ << ": did_device_name_change="
|
||||
<< (did_device_name_change ? "true" : "false")
|
||||
<< ", did_full_name_change="
|
||||
<< (did_full_name_change ? "true" : "false")
|
||||
<< ", did_icon_change=" << (did_icon_change ? "true" : "false");
|
||||
for (auto& observer : observers_.GetObservers()) {
|
||||
observer->OnLocalDeviceDataChanged(did_device_name_change,
|
||||
did_full_name_change, did_icon_change);
|
||||
|
||||
@@ -45,8 +45,8 @@ Payload ConvertToPayload(NcPayload payload) {
|
||||
case NcPayloadType::kFile: {
|
||||
std::string file_path = payload.AsFile()->GetFilePath();
|
||||
std::string parent_folder = payload.GetParentFolder();
|
||||
NL_VLOG(1) << __func__ << ": Payload file_path=" << file_path
|
||||
<< ", parent_folder = " << parent_folder;
|
||||
VLOG(1) << __func__ << ": Payload file_path=" << file_path
|
||||
<< ", parent_folder = " << parent_folder;
|
||||
return Payload(payload.GetId(), InputFile(file_path), parent_folder);
|
||||
}
|
||||
default:
|
||||
@@ -64,8 +64,8 @@ NcPayload ConvertToServicePayload(Payload payload) {
|
||||
payload.content.file_payload.file.path.filename().u8string());
|
||||
std::string parent_folder = payload.content.file_payload.parent_folder;
|
||||
std::replace(parent_folder.begin(), parent_folder.end(), '\\', '/');
|
||||
NL_VLOG(1) << __func__ << ": NC Payload file_path=" << file_path
|
||||
<< ", parent_folder = " << parent_folder;
|
||||
VLOG(1) << __func__ << ": NC Payload file_path=" << file_path
|
||||
<< ", parent_folder = " << parent_folder;
|
||||
nearby::InputFile input_file(file_path, file_size);
|
||||
NcPayload nc_payload(payload.id, parent_folder, file_name,
|
||||
std::move(input_file));
|
||||
|
||||
@@ -45,8 +45,8 @@ std::vector<NearbyFileHandler::FileInfo> DoOpenFiles(
|
||||
for (const auto& file_path : file_paths) {
|
||||
std::optional<uintmax_t> size = GetFileSize(file_path);
|
||||
if (!size.has_value()) {
|
||||
NL_LOG(ERROR) << __func__ << ": Failed to open file. File="
|
||||
<< GetCompatibleU8String(file_path.u8string());
|
||||
LOG(ERROR) << __func__ << ": Failed to open file. File="
|
||||
<< GetCompatibleU8String(file_path.u8string());
|
||||
return {};
|
||||
}
|
||||
files.push_back({*size, file_path});
|
||||
@@ -84,18 +84,18 @@ void NearbyFileHandler::DeleteFilesFromDisk(
|
||||
continue;
|
||||
}
|
||||
if (RemoveFile(file_path)) {
|
||||
NL_VLOG(1) << __func__ << ": Removed partial file. File="
|
||||
<< GetCompatibleU8String(file_path.u8string());
|
||||
VLOG(1) << __func__ << ": Removed partial file. File="
|
||||
<< GetCompatibleU8String(file_path.u8string());
|
||||
} else {
|
||||
// Try once more after 3 seconds.
|
||||
absl::SleepFor(absl::Seconds(3));
|
||||
if (RemoveFile(file_path)) {
|
||||
NL_VLOG(1) << __func__
|
||||
<< ": Removed partial file after additional delay. File="
|
||||
<< GetCompatibleU8String(file_path.u8string());
|
||||
VLOG(1) << __func__
|
||||
<< ": Removed partial file after additional delay. File="
|
||||
<< GetCompatibleU8String(file_path.u8string());
|
||||
} else {
|
||||
NL_LOG(ERROR) << __func__ << "Can't remove file: "
|
||||
<< GetCompatibleU8String(file_path.u8string());
|
||||
LOG(ERROR) << __func__ << "Can't remove file: "
|
||||
<< GetCompatibleU8String(file_path.u8string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ std::string NearbySharingService::StatusCodeToString(StatusCodes status_code) {
|
||||
case StatusCodes::kInvalidArgument:
|
||||
return "kInvalidArgument";
|
||||
}
|
||||
NL_LOG(ERROR) << "Unexpected value for StatusCodes: "
|
||||
<< static_cast<int>(status_code);
|
||||
LOG(ERROR) << "Unexpected value for StatusCodes: "
|
||||
<< static_cast<int>(status_code);
|
||||
return kUnknownStatusCodesString;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ NearbyShareSettings::NearbyShareSettings(
|
||||
std::weak_ptr<bool>(is_desctructing_)](absl::string_view key) {
|
||||
std::shared_ptr<bool> is_desctructing = desctructing.lock();
|
||||
if (is_desctructing == nullptr || *is_desctructing) {
|
||||
NL_LOG(WARNING) << ": Ignore the preferences change callback.";
|
||||
LOG(WARNING) << ": Ignore the preferences change callback.";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -140,12 +140,12 @@ DataUsage NearbyShareSettings::GetDataUsage() const {
|
||||
|
||||
void NearbyShareSettings::StartVisibilityTimer(
|
||||
absl::Duration expiration) {
|
||||
NL_LOG(INFO) << __func__
|
||||
<< ": start visibility timer. expiration=" << expiration;
|
||||
LOG(INFO) << __func__
|
||||
<< ": start visibility timer. expiration=" << expiration;
|
||||
visibility_expiration_timer_ = std::make_unique<ThreadTimer>(
|
||||
*context_->GetTaskRunner(), "nearby_share_settings_visibility_timer",
|
||||
expiration, [this]() {
|
||||
NL_LOG(INFO) << __func__ << ": visibility timer expired.";
|
||||
LOG(INFO) << __func__ << ": visibility timer expired.";
|
||||
proto::DeviceVisibility visibility;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
@@ -167,18 +167,18 @@ void NearbyShareSettings::RestoreFallbackVisibility() {
|
||||
int64_t now_seconds = absl::ToUnixSeconds(clock_->Now());
|
||||
int64_t remaining_seconds = expiration_seconds - now_seconds;
|
||||
int64_t diff = kMaxVisibilityExpirationSeconds - remaining_seconds;
|
||||
NL_LOG(INFO) << __func__ << ": diff=" << diff << ", now=" << now_seconds
|
||||
<< ", expiration=" << expiration_seconds
|
||||
<< ", max=" << kMaxVisibilityExpirationSeconds;
|
||||
LOG(INFO) << __func__ << ": diff=" << diff << ", now=" << now_seconds
|
||||
<< ", expiration=" << expiration_seconds
|
||||
<< ", max=" << kMaxVisibilityExpirationSeconds;
|
||||
if (remaining_seconds > 0 &&
|
||||
remaining_seconds <= kMaxVisibilityExpirationSeconds) { // Not expired
|
||||
StartVisibilityTimer(absl::Seconds(remaining_seconds));
|
||||
} else if (expiration_seconds != 0) { // Expired.
|
||||
NL_LOG(INFO) << __func__
|
||||
<< ": timer is already expired. Restore fallback visibility.";
|
||||
LOG(INFO) << __func__
|
||||
<< ": timer is already expired. Restore fallback visibility.";
|
||||
SetVisibility(static_cast<DeviceVisibility>(fallback_visibility));
|
||||
} else {
|
||||
NL_LOG(INFO) << __func__ << ": No running fallback Visibility.";
|
||||
LOG(INFO) << __func__ << ": No running fallback Visibility.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,15 +270,15 @@ void NearbyShareSettings::SetVisibility(DeviceVisibility visibility,
|
||||
last_visibility, visibility, absl::ToInt64Milliseconds(expiration));
|
||||
}
|
||||
|
||||
NL_VLOG(1) << __func__
|
||||
<< ": set visibility. visibility=" << static_cast<int>(visibility)
|
||||
<< ", expiration=" << expiration;
|
||||
VLOG(1) << __func__
|
||||
<< ": set visibility. visibility=" << static_cast<int>(visibility)
|
||||
<< ", expiration=" << expiration;
|
||||
visibility_expiration_timer_.reset();
|
||||
|
||||
SetFallbackVisibility(last_visibility);
|
||||
absl::Time now = clock_->Now();
|
||||
if (expiration != absl::ZeroDuration()) {
|
||||
NL_VLOG(1) << __func__ << ": temporary visibility timer starts.";
|
||||
VLOG(1) << __func__ << ": temporary visibility timer starts.";
|
||||
absl::Time fallback_visibility_timestamp = now + expiration;
|
||||
preference_manager_.SetInteger(
|
||||
prefs::kNearbySharingBackgroundVisibilityExpirationSeconds,
|
||||
@@ -326,17 +326,17 @@ NearbyShareSettings::GetFallbackVisibility() const {
|
||||
visibility_expiration_timer_->IsRunning()) {
|
||||
result = GetRawFallbackVisibility();
|
||||
}
|
||||
NL_VLOG(1) << __func__ << ": get fallback visibility "
|
||||
<< static_cast<int>(result.visibility)
|
||||
<< " expiration: " << result.fallback_time;
|
||||
VLOG(1) << __func__ << ": get fallback visibility "
|
||||
<< static_cast<int>(result.visibility)
|
||||
<< " expiration: " << result.fallback_time;
|
||||
return result;
|
||||
}
|
||||
|
||||
void NearbyShareSettings::SetFallbackVisibility(DeviceVisibility visibility) {
|
||||
NL_VLOG(1) << __func__ << ": set fallback visibility. visibility="
|
||||
<< static_cast<int>(visibility);
|
||||
VLOG(1) << __func__ << ": set fallback visibility. visibility="
|
||||
<< static_cast<int>(visibility);
|
||||
if (visibility == DeviceVisibility::DEVICE_VISIBILITY_EVERYONE) {
|
||||
NL_VLOG(1) << __func__ << ": visibility is everyone. Skip.";
|
||||
VLOG(1) << __func__ << ": visibility is everyone. Skip.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class NearbyShareSettings
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NL_LOG(FATAL) << "Invalid tag: " << this->tag;
|
||||
LOG(FATAL) << "Invalid tag: " << this->tag;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -77,17 +77,17 @@ std::string PowerLevelToString(PowerLevel level) {
|
||||
std::optional<std::vector<uint8_t>> GetBluetoothMacAddressFromCertificate(
|
||||
const NearbyShareDecryptedPublicCertificate& certificate) {
|
||||
if (!certificate.unencrypted_metadata().has_bluetooth_mac_address()) {
|
||||
NL_LOG(WARNING) << __func__ << ": Public certificate "
|
||||
<< nearby::utils::HexEncode(certificate.id())
|
||||
<< " did not contain a Bluetooth mac address.";
|
||||
LOG(WARNING) << __func__ << ": Public certificate "
|
||||
<< nearby::utils::HexEncode(certificate.id())
|
||||
<< " did not contain a Bluetooth mac address.";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string mac_address =
|
||||
certificate.unencrypted_metadata().bluetooth_mac_address();
|
||||
if (mac_address.size() != 6) {
|
||||
NL_LOG(ERROR) << __func__ << ": Invalid bluetooth mac address: '"
|
||||
<< mac_address << "'";
|
||||
LOG(ERROR) << __func__ << ": Invalid bluetooth mac address: '"
|
||||
<< mac_address << "'";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@ ThreadTimer::ThreadTimer(TaskRunner& task_runner, std::string name,
|
||||
name = name_]() mutable {
|
||||
if (run_cnt->fetch_add(1) == 0) {
|
||||
// Timer has not been cancelled, run the task.
|
||||
NL_LOG(INFO) << "Timer " << name << " fired.";
|
||||
LOG(INFO) << "Timer " << name << " fired.";
|
||||
std::move(task)();
|
||||
} else {
|
||||
// Timer has been cancelled, need to delete the run_cnt.
|
||||
NL_VLOG(1) << "Timer " << name << " expired but was cancelled.";
|
||||
VLOG(1) << "Timer " << name << " expired but was cancelled.";
|
||||
delete run_cnt;
|
||||
}
|
||||
})) {
|
||||
@@ -57,7 +57,7 @@ ThreadTimer::~ThreadTimer() { Cancel(); }
|
||||
|
||||
void ThreadTimer::Cancel() {
|
||||
if (run_cnt_ != nullptr) {
|
||||
NL_LOG(INFO) << "Timer " << name_ << " cancelled.";
|
||||
LOG(INFO) << "Timer " << name_ << " cancelled.";
|
||||
if (run_cnt_->fetch_add(1) > 0) {
|
||||
// Timer has already fired, delete the run_cnt.
|
||||
delete run_cnt_;
|
||||
|
||||
+19
-19
@@ -57,7 +57,7 @@ void TransferManager::Send(std::function<void()> task) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
if (is_waiting_for_high_quality_medium_) {
|
||||
NL_LOG(INFO)
|
||||
LOG(INFO)
|
||||
<< "Connection to endpoint " << endpoint_id_
|
||||
<< " is waiting for a high quality medium, delaying payload transfer.";
|
||||
pending_tasks_.push_back(task);
|
||||
@@ -71,19 +71,19 @@ void TransferManager::OnMediumQualityChanged(Medium current_medium) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
if (!is_waiting_for_high_quality_medium_) {
|
||||
NL_LOG(WARNING) << "It is not waiting for high quality medium.";
|
||||
LOG(WARNING) << "It is not waiting for high quality medium.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsHighQualityMedium(current_medium)) {
|
||||
NL_LOG(WARNING) << "medium switched to low quality Medium: "
|
||||
<< static_cast<int>(current_medium);
|
||||
LOG(WARNING) << "medium switched to low quality Medium: "
|
||||
<< static_cast<int>(current_medium);
|
||||
return;
|
||||
}
|
||||
|
||||
NL_LOG(INFO) << "Connection to endpoint " << endpoint_id_
|
||||
<< " has changed to a high quality medium: "
|
||||
<< static_cast<int>(current_medium);
|
||||
LOG(INFO) << "Connection to endpoint " << endpoint_id_
|
||||
<< " has changed to a high quality medium: "
|
||||
<< static_cast<int>(current_medium);
|
||||
StopWaitingForHighQualityMedium();
|
||||
}
|
||||
|
||||
@@ -91,12 +91,12 @@ bool TransferManager::StartTransfer() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
if (!is_waiting_for_high_quality_medium_) {
|
||||
NL_LOG(WARNING) << "No need to wait for high quality medium.";
|
||||
LOG(WARNING) << "No need to wait for high quality medium.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (timeout_timer_ != nullptr) {
|
||||
NL_LOG(WARNING) << "transfer already started.";
|
||||
LOG(WARNING) << "transfer already started.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,16 +105,16 @@ bool TransferManager::StartTransfer() {
|
||||
kMediumUpgradeTimeout, [this]() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NL_LOG(INFO) << "Timed out for endpoint " << endpoint_id_ << " after "
|
||||
<< kMediumUpgradeTimeout;
|
||||
LOG(INFO) << "Timed out for endpoint " << endpoint_id_ << " after "
|
||||
<< kMediumUpgradeTimeout;
|
||||
StopWaitingForHighQualityMedium();
|
||||
});
|
||||
|
||||
NL_LOG(INFO) << "Attempting to upgrade the bandwidth for endpoint " +
|
||||
endpoint_id_ + ". Large payloads will be delayed" +
|
||||
" until either bandwidth is upgraded or a timeout of "
|
||||
<< (kMediumUpgradeTimeout / absl::Milliseconds(1))
|
||||
<< " milliseconds is reached";
|
||||
LOG(INFO) << "Attempting to upgrade the bandwidth for endpoint " +
|
||||
endpoint_id_ + ". Large payloads will be delayed" +
|
||||
" until either bandwidth is upgraded or a timeout of "
|
||||
<< (kMediumUpgradeTimeout / absl::Milliseconds(1))
|
||||
<< " milliseconds is reached";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -122,12 +122,12 @@ bool TransferManager::CancelTransfer() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
if (timeout_timer_ == nullptr) {
|
||||
NL_LOG(WARNING) << "No running transfer.";
|
||||
LOG(WARNING) << "No running transfer.";
|
||||
return false;
|
||||
}
|
||||
|
||||
timeout_timer_.reset();
|
||||
NL_LOG(INFO) << __func__ << "Transfer is canceled";
|
||||
LOG(INFO) << __func__ << "Transfer is canceled";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ void TransferManager::StopWaitingForHighQualityMedium() {
|
||||
is_waiting_for_high_quality_medium_ = false;
|
||||
|
||||
for (const auto& task : pending_tasks_) {
|
||||
NL_LOG(INFO) << "Sending delayed payload to endpoint " << endpoint_id_;
|
||||
LOG(INFO) << "Sending delayed payload to endpoint " << endpoint_id_;
|
||||
task();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ bool WrappedShareTargetDiscoveredCallback::ShouldBlockShareTarget(
|
||||
void WrappedShareTargetDiscoveredCallback::OnShareTargetDiscovered(
|
||||
const ShareTarget& share_target) {
|
||||
if (ShouldBlockShareTarget(share_target)) {
|
||||
NL_LOG(INFO) << "Skipping share target discovered for vendor id "
|
||||
<< static_cast<uint32_t>(blocked_vendor_id_);
|
||||
LOG(INFO) << "Skipping share target discovered for vendor id "
|
||||
<< static_cast<uint32_t>(blocked_vendor_id_);
|
||||
return;
|
||||
}
|
||||
if (callback_ != nullptr) {
|
||||
@@ -44,8 +44,8 @@ void WrappedShareTargetDiscoveredCallback::OnShareTargetDiscovered(
|
||||
void WrappedShareTargetDiscoveredCallback::OnShareTargetUpdated(
|
||||
const ShareTarget& share_target) {
|
||||
if (ShouldBlockShareTarget(share_target)) {
|
||||
NL_LOG(INFO) << "Skipping share target updated for vendor id "
|
||||
<< static_cast<uint32_t>(blocked_vendor_id_);
|
||||
LOG(INFO) << "Skipping share target updated for vendor id "
|
||||
<< static_cast<uint32_t>(blocked_vendor_id_);
|
||||
return;
|
||||
}
|
||||
if (callback_ != nullptr) {
|
||||
@@ -56,8 +56,8 @@ void WrappedShareTargetDiscoveredCallback::OnShareTargetUpdated(
|
||||
void WrappedShareTargetDiscoveredCallback::OnShareTargetLost(
|
||||
const ShareTarget& share_target) {
|
||||
if (ShouldBlockShareTarget(share_target)) {
|
||||
NL_LOG(INFO) << "Skipping share target lost for vendor id "
|
||||
<< static_cast<uint32_t>(blocked_vendor_id_);
|
||||
LOG(INFO) << "Skipping share target lost for vendor id "
|
||||
<< static_cast<uint32_t>(blocked_vendor_id_);
|
||||
return;
|
||||
}
|
||||
if (callback_ != nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user