Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace NEARBY_LOGS(VERBOSE) with VLOG(1) #3058

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fastpair/handshake/fast_pair_data_encryptor_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ FastPairDataEncryptorImpl::Factory* g_test_factory_ = nullptr;

bool ValidateInputSize(const std::vector<uint8_t>& encrypted_bytes) {
if (encrypted_bytes.size() != kAesBlockByteSize) {
NEARBY_LOGS(VERBOSE) << __func__ << ": Encrypted bytes should have size = "
VLOG(1) << __func__ << ": Encrypted bytes should have size = "
<< kAesBlockByteSize
<< ", actual = " << encrypted_bytes.size();
return false;
Expand Down Expand Up @@ -88,7 +88,7 @@ void FastPairDataEncryptorImpl::Factory::CreateAsyncWithKeyExchange(
const FastPairDevice& device,
absl::AnyInvocable<void(std::unique_ptr<FastPairDataEncryptor>)>
on_get_instance_callback) {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
auto& metadata = device.GetMetadata();
DCHECK(metadata);
std::optional<KeyPair> key_pair =
Expand Down
10 changes: 5 additions & 5 deletions fastpair/handshake/fast_pair_gatt_service_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,20 @@ void FastPairGattServiceClientImpl::WriteAccountKey(

void FastPairGattServiceClientImpl::NotifyInitializedError(
PairFailure failure) {
NEARBY_LOGS(VERBOSE) << __func__ << failure;
VLOG(1) << __func__ << failure;
ClearCurrentState();

executor_->Execute("init-error", [this, failure]() {
if (on_gatt_initialized_callback_) {
NEARBY_LOGS(VERBOSE) << __func__ << "Executing initialized callback";
VLOG(1) << __func__ << "Executing initialized callback";
std::move(on_gatt_initialized_callback_)(failure);
}
});
}

void FastPairGattServiceClientImpl::NotifyWriteRequestResult(
absl::string_view value, std::optional<PairFailure> failure) {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
executor_->Execute(
"key-based-response", [this, value = std::string(value), failure]() {
if (key_based_write_response_callback_) {
Expand All @@ -367,7 +367,7 @@ void FastPairGattServiceClientImpl::NotifyWriteRequestResult(

void FastPairGattServiceClientImpl::NotifyWritePasskeyResult(
absl::string_view value, std::optional<PairFailure> failure) {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
executor_->Execute(
"passkey-response", [this, value = std::string(value), failure]() {
if (passkey_write_response_callback_) {
Expand All @@ -378,7 +378,7 @@ void FastPairGattServiceClientImpl::NotifyWritePasskeyResult(

void FastPairGattServiceClientImpl::NotifyWriteAccountKeyResult(
std::optional<AccountKey> account_key, std::optional<PairFailure> failure) {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
executor_->Execute("passkey-response", [this, account_key, failure]() {
if (account_key_write_callback_) {
std::move(account_key_write_callback_)(account_key, failure);
Expand Down
18 changes: 9 additions & 9 deletions fastpair/internal/fast_pair_seeker_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void FastPairSeekerImpl::InvalidateScanningState() {
// Stop scanning when screen is off.
if (is_screen_locked_) {
absl::Status status = StopFastPairScan();
NEARBY_LOGS(VERBOSE) << __func__
VLOG(1) << __func__
<< ": Stopping scanning because the screen is locked.";
return;
}
Expand All @@ -271,22 +271,22 @@ void FastPairSeekerImpl::InvalidateScanningState() {
}

void FastPairSeekerImpl::DeviceAdded(BluetoothDevice& device) {
NEARBY_LOGS(VERBOSE) << __func__ << "(" << device.GetMacAddress() << ")";
VLOG(1) << __func__ << "(" << device.GetMacAddress() << ")";
}

void FastPairSeekerImpl::DeviceRemoved(BluetoothDevice& device) {
NEARBY_LOGS(VERBOSE) << __func__ << "(" << device.GetMacAddress() << ")";
VLOG(1) << __func__ << "(" << device.GetMacAddress() << ")";
}

void FastPairSeekerImpl::DeviceAddressChanged(BluetoothDevice& device,
absl::string_view old_address) {
NEARBY_LOGS(VERBOSE) << __func__ << "(" << device.GetMacAddress() << ", "
VLOG(1) << __func__ << "(" << device.GetMacAddress() << ", "
<< old_address << ")";
}

void FastPairSeekerImpl::DevicePairedChanged(BluetoothDevice& device,
bool new_paired_status) {
NEARBY_LOGS(VERBOSE) << __func__ << "(" << device.GetMacAddress() << ", "
VLOG(1) << __func__ << "(" << device.GetMacAddress() << ", "
<< new_paired_status << ")";
// Note, the FP service will be notified about paired events from the
// retroactive pairing path if `device` is an FP device.
Expand All @@ -296,18 +296,18 @@ void FastPairSeekerImpl::DevicePairedChanged(BluetoothDevice& device,

void FastPairSeekerImpl::DeviceConnectedStateChanged(BluetoothDevice& device,
bool connected) {
NEARBY_LOGS(VERBOSE) << __func__ << "(" << device.GetMacAddress() << ", "
VLOG(1) << __func__ << "(" << device.GetMacAddress() << ", "
<< connected << ")";
}

void FastPairSeekerImpl::OnRetroactivePairFound(FastPairDevice& device) {
NEARBY_LOGS(VERBOSE) << __func__ << ": " << device;
VLOG(1) << __func__ << ": " << device;
callbacks_.on_pair_event(device, PairEvent{.is_paired = true});
}

void FastPairSeekerImpl::ForgetDeviceByAccountKey(
const AccountKey& account_key) {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
auto opt_device = devices_->FindDevice(account_key);
if (!opt_device.has_value()) {
NEARBY_LOGS(INFO) << __func__ << "No FP device matching the account key.";
Expand All @@ -318,7 +318,7 @@ void FastPairSeekerImpl::ForgetDeviceByAccountKey(
repository_->DeleteAssociatedDeviceByAccountKey(
account_key, [&](absl::Status success) {
if (!success.ok()) return;
NEARBY_LOGS(VERBOSE) << "Deleted associated devcie by account key";
VLOG(1) << "Deleted associated devcie by account key";
// Temporary solution to refresh the saved_devices_sheet.
repository_->GetUserSavedDevices();
});
Expand Down
2 changes: 1 addition & 1 deletion fastpair/internal/mediums/ble_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ std::unique_ptr<RobustGattClient> BleV2::ConnectToGattServer(
return nullptr;
}
if (!IsAvailableLocked()) {
NEARBY_LOGS(VERBOSE)
VLOG(1)
<< __func__
<< "Can't connect to GattServer because BleV2 isn't available.";
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion fastpair/internal/mediums/bluetooth_classic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ std::unique_ptr<BluetoothPairing> BluetoothClassic::CreatePairing(
return nullptr;
}
if (!IsAvailableLocked()) {
NEARBY_LOGS(VERBOSE) << __func__
VLOG(1) << __func__
<< "Can't create bluetooth pairing because "
"BluetoothClassic isn't available.";
return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions fastpair/internal/mediums/bluetooth_radio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ BluetoothRadio::BluetoothRadio() {
}

BluetoothRadio::~BluetoothRadio() {
NEARBY_LOGS(VERBOSE) << "~BluetoothRadio start";
VLOG(1) << "~BluetoothRadio start";
// We never enabled Bluetooth, nothing to do.
if (!ever_saved_state_.Get()) {
NEARBY_LOGS(INFO) << "BT adapter was not used. Not touching HW.";
Expand All @@ -36,7 +36,7 @@ BluetoothRadio::~BluetoothRadio() {
if (!SetBluetoothState(originally_enabled_.Get())) {
NEARBY_LOGS(INFO) << "Failed to restore BT adapter original state.";
}
NEARBY_LOGS(VERBOSE) << "~BluetoothRadio done";
VLOG(1) << "~BluetoothRadio done";
}

bool BluetoothRadio::Enable() {
Expand Down
2 changes: 1 addition & 1 deletion fastpair/internal/mediums/robust_gatt_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void RobustGattClient::Unsubscribe(int uuid_pair_index) {
MutexLock lock(&mutex_);
int removed = notify_callbacks_.erase(uuid_pair_index);
if (removed == 0) {
NEARBY_LOGS(VERBOSE) << "Not subscribed for characteristic no: "
VLOG(1) << "Not subscribed for characteristic no: "
<< uuid_pair_index;
}
UnsubscribeInternal(uuid_pair_index);
Expand Down
35 changes: 15 additions & 20 deletions fastpair/message_stream/fake_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,14 @@ void FakeProvider::LoadAntiSpoofingKey(absl::string_view private_key,
}

std::string FakeProvider::DecryptKbpRequest(absl::string_view request) {
NEARBY_LOGS(VERBOSE) << "Encrypted KBP request "
<< absl::BytesToHexString(request);
VLOG(1) << "Encrypted KBP request " << absl::BytesToHexString(request);
CHECK_EQ(request.size(), kEncryptedDataByteSize + kPublicKeyByteSize);
absl::string_view encrypted = request.substr(0, kEncryptedDataByteSize);
absl::string_view remote_public_key =
request.substr(kEncryptedDataByteSize, kPublicKeyByteSize);
std::string shared_secret = CreateSharedSecret(remote_public_key);
std::string decrypted = Aes128Decrypt(encrypted, shared_secret);
NEARBY_LOGS(VERBOSE) << "Decrypted KBP request "
<< absl::BytesToHexString(decrypted);
VLOG(1) << "Decrypted KBP request " << absl::BytesToHexString(decrypted);
shared_secret_ = shared_secret;
return decrypted;
}
Expand Down Expand Up @@ -246,19 +244,18 @@ void FakeProvider::SetKeyBasedPairingCallback() {
CHECK(key_based_characteristic_.has_value());
fake_gatt_callbacks_->characteristics_[*key_based_characteristic_]
.write_callback = [this](absl::string_view request) {
NEARBY_LOGS(VERBOSE) << "Encrypted request: "
<< absl::BytesToHexString(request);
VLOG(1) << "Encrypted request: " << absl::BytesToHexString(request);
std::string decrypted_request = DecryptKbpRequest(request);
NEARBY_LOGS(VERBOSE) << "KBP decrypted request "
<< absl::BytesToHexString(decrypted_request);
VLOG(1) << "KBP decrypted request "
<< absl::BytesToHexString(decrypted_request);
fake_gatt_callbacks_->characteristics_[*key_based_characteristic_]
.write_value.Set(std::string(decrypted_request));
std::string response;
response.push_back(kKeyBasedPairingResponseCode);
response.append(GetMacAddressAsBytes());
response.resize(kEncryptedDataByteSize, 0);
absl::Status status = NotifyKeyBasedPairing(ByteArray(Encrypt(response)));
NEARBY_LOGS(VERBOSE) << "KBP notify result: " << status;
VLOG(1) << "KBP notify result: " << status;
return absl::OkStatus();
};
}
Expand All @@ -268,11 +265,10 @@ void FakeProvider::SetPasskeyCallback() {
CHECK(passkey_characteristic_.has_value());
fake_gatt_callbacks_->characteristics_[*passkey_characteristic_]
.write_callback = [this](absl::string_view request) {
NEARBY_LOGS(VERBOSE) << "Passkey Encrypted request: "
<< absl::BytesToHexString(request);
VLOG(1) << "Passkey Encrypted request: " << absl::BytesToHexString(request);
std::string decrypted = Aes128Decrypt(request, shared_secret_);
NEARBY_LOGS(VERBOSE) << "Passkey decrypted request "
<< absl::BytesToHexString(decrypted);
VLOG(1) << "Passkey decrypted request "
<< absl::BytesToHexString(decrypted);
fake_gatt_callbacks_->characteristics_[*passkey_characteristic_]
.write_value.Set(std::string(decrypted));
if (decrypted[0] != kSeekerPasskeyResponseCode) {
Expand All @@ -287,7 +283,7 @@ void FakeProvider::SetPasskeyCallback() {
response.push_back(pass_key_);
response.resize(kEncryptedDataByteSize, 0);
absl::Status status = NotifyPasskey(ByteArray(Encrypt(response)));
NEARBY_LOGS(VERBOSE) << "Passkey notify result: " << status;
VLOG(1) << "Passkey notify result: " << status;
return absl::OkStatus();
};
}
Expand All @@ -297,11 +293,11 @@ void FakeProvider::SetAccountkeyCallback() {
CHECK(accountkey_characteristic_.has_value());
fake_gatt_callbacks_->characteristics_[*accountkey_characteristic_]
.write_callback = [this](absl::string_view request) {
NEARBY_LOGS(VERBOSE) << "Account key encrypted request: "
<< absl::BytesToHexString(request);
VLOG(1) << "Account key encrypted request: "
<< absl::BytesToHexString(request);
std::string decrypted = Aes128Decrypt(request, shared_secret_);
NEARBY_LOGS(VERBOSE) << "Account key decrypted request "
<< absl::BytesToHexString(decrypted);
VLOG(1) << "Account key decrypted request "
<< absl::BytesToHexString(decrypted);
fake_gatt_callbacks_->characteristics_[*accountkey_characteristic_]
.write_value.Set(std::string(decrypted));

Expand Down Expand Up @@ -366,8 +362,7 @@ void FakeProvider::EnableProviderRfcommForRetro(PairingConfig &config) {
provider_thread_.Execute([this]() {
provider_socket_ = provider_server_socket_.Accept();
if (provider_server_socket_.IsValid()) {
NEARBY_LOGS(VERBOSE)
<< "Message stream connected. Sending Model Id and BLE address";
VLOG(1) << "Message stream connected. Sending Model Id and BLE address";
provider_socket_.GetOutputStream().Write(GetModelIdMessage(model_id_));
provider_socket_.GetOutputStream().Write(GetBleAddressMessage());
}
Expand Down
4 changes: 2 additions & 2 deletions fastpair/pairing/fastpair/fast_pair_pairer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void FastPairPairerImpl::AttemptSendAccountKey() {
// pairing. For subsequent pairing, we have to save the account key
// locally so that we can refer to it in API calls to the server.
if (device_.GetProtocol() == Protocol::kFastPairSubsequentPairing) {
NEARBY_LOGS(VERBOSE) << __func__
VLOG(1) << __func__
<< ": Saving Account Key locally for subsequent pair";
// TODO(b/278807993): Saving Account Key locally for subsequent pair
NotifyPairingCompleted();
Expand All @@ -297,7 +297,7 @@ void FastPairPairerImpl::AttemptSendAccountKey() {
FastPairRepository::Get()->IsDeviceSavedToAccount(
device_.GetPublicAddress().value(), [this](absl::Status status) {
if (status.ok()) {
NEARBY_LOGS(VERBOSE)
VLOG(1)
<< __func__
<< ": Device is already saved, skipping write account key. "
"Pairing procedure complete.";
Expand Down
2 changes: 1 addition & 1 deletion fastpair/plugins/windows_admin_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void WindowsAdminPlugin::OnInitialDiscoveryEvent(
return;
}
if (state_->foreground_currently_showing_notification) {
NEARBY_LOGS(VERBOSE) << __func__
VLOG(1) << __func__
<< ": Already showing a notification for a device";
return;
}
Expand Down
2 changes: 1 addition & 1 deletion fastpair/proto/proto_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace fastpair {

void BuildFastPairInfo(::nearby::fastpair::proto::FastPairInfo* fast_pair_info,
const FastPairDevice& fast_pair_device) {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
const AccountKey& account_key = fast_pair_device.GetAccountKey();
auto& metadata = fast_pair_device.GetMetadata();
DCHECK(metadata);
Expand Down
2 changes: 1 addition & 1 deletion fastpair/repository/fast_pair_device_repository.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void FastPairDeviceRepository::RemoveDevice(const FastPairDevice* device) {
for (auto* callback : observers_.GetObservers()) {
(*callback)(*fast_pair_device);
}
NEARBY_LOGS(VERBOSE) << "Destroyed FP device: " << *fast_pair_device;
VLOG(1) << "Destroyed FP device: " << *fast_pair_device;
});
}

Expand Down
2 changes: 1 addition & 1 deletion fastpair/repository/fast_pair_repository_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void FastPairRepositoryImpl::IsDeviceSavedToAccount(
for (const auto& info : response->fast_pair_info()) {
if (info.has_device() &&
IsDeviceSha256Matched(info.device(), mac_address)) {
NEARBY_LOGS(VERBOSE)
VLOG(1)
<< __func__ << ": found a SHA256 match for device at address = "
<< mac_address;
std::move(callback)(absl::OkStatus());
Expand Down
4 changes: 2 additions & 2 deletions fastpair/retroactive/retroactive_pairing_detector_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void RetroactivePairingDetectorImpl::DevicePairedChanged(
device.GetMacAddress(),
[this, mac_address = device.GetMacAddress()](absl::Status status) {
if (status.ok()) {
NEARBY_LOGS(VERBOSE) << __func__
VLOG(1) << __func__
<< ": Ignoring because device is already saved "
"to the current account.";
return;
Expand All @@ -102,7 +102,7 @@ void RetroactivePairingDetectorImpl::DevicePairedChanged(

void RetroactivePairingDetectorImpl::NotifyRetroactiveDeviceFound(
absl::string_view mac_address) {
NEARBY_LOGS(VERBOSE) << __func__ << ": mac_address = " << mac_address;
VLOG(1) << __func__ << ": mac_address = " << mac_address;
auto fast_pair_device =
std::make_unique<FastPairDevice>(Protocol::kFastPairRetroactivePairing);
fast_pair_device->SetPublicAddress(mac_address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void FastPairDiscoverableScanner::OnDeviceMetadataRetrieved(
}

void FastPairDiscoverableScanner::NotifyDeviceFound(FastPairDevice& device) {
NEARBY_LOGS(VERBOSE) << "Notify Device found:"
VLOG(1) << "Notify Device found:"
<< "BluetoothAddress = " << device.GetBleAddress()
<< ", Model id = " << device.GetModelId();
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void FastPairNonDiscoverableScanner::OnDeviceMetadataRetrieved(
}

void FastPairNonDiscoverableScanner::NotifyDeviceFound(FastPairDevice& device) {
NEARBY_LOGS(VERBOSE) << "Notify Device found:"
VLOG(1) << "Notify Device found:"
<< "BluetoothAddress = " << device.GetBleAddress()
<< ", Model id = " << device.GetModelId();
{
Expand Down
10 changes: 5 additions & 5 deletions fastpair/scanning/fastpair/fast_pair_scanner_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ScanningSessionImpl : public FastPairScanner::ScanningSession {
explicit ScanningSessionImpl(FastPairScannerImpl* scanner)
: scanner_(scanner) {}
~ScanningSessionImpl() override {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
scanner_->StopScanning();
}

Expand All @@ -61,14 +61,14 @@ void FastPairScannerImpl::RemoveObserver(FastPairScanner::Observer* observer) {

std::unique_ptr<FastPairScanner::ScanningSession>
FastPairScannerImpl::StartScanning() {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
executor_->Execute("scanning", [this]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(
*executor_) { StartScanningInternal(); });
return std::make_unique<ScanningSessionImpl>(this);
}

void FastPairScannerImpl::StartScanningInternal() {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
if (mediums_.GetBluetoothRadio().Enable() &&
mediums_.GetBle().IsAvailable() &&
mediums_.GetBle().StartScanning(
Expand Down Expand Up @@ -108,10 +108,10 @@ void FastPairScannerImpl::StartScanningInternal() {
}

void FastPairScannerImpl::StopScanning() {
NEARBY_LOGS(VERBOSE) << __func__;
VLOG(1) << __func__;
executor_->Execute("stop-scan",
[this]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(*executor_) {
NEARBY_LOGS(VERBOSE) << __func__ << " in background";
VLOG(1) << __func__ << " in background";
timer_.reset();
mediums_.GetBle().StopScanning(kServiceId);
});
Expand Down
Loading
Loading