Remove unused methods.

PiperOrigin-RevId: 657249809
This commit is contained in:
Francis Tsui
2024-07-29 10:37:15 -07:00
committed by Copybara-Service
parent 9413448e6e
commit 861ed1b64b
6 changed files with 19 additions and 67 deletions
-13
View File
@@ -115,22 +115,9 @@ void FakeNearbySharingService::ClearForegroundReceiveSurfaces(
status_codes_callback(StatusCodes::kOk);
}
// Returns true if a foreground receive surface is registered.
bool FakeNearbySharingService::IsInHighVisibility() const { return false; }
// Returns true if there is an ongoing file transfer.
bool FakeNearbySharingService::IsTransferring() const { return false; }
// Returns true if we're currently receiving a file.
bool FakeNearbySharingService::IsReceivingFile() const { return false; }
// Returns true if we're currently sending a file.
bool FakeNearbySharingService::IsSendingFile() const { return false; }
// Returns true if we're currently attempting to connect to a
// remote device.
bool FakeNearbySharingService::IsConnecting() const { return false; }
// Returns true if we are currently scanning for remote devices.
bool FakeNearbySharingService::IsScanning() const { return false; }
-13
View File
@@ -75,22 +75,9 @@ class FakeNearbySharingService : public NearbySharingService {
void ClearForegroundReceiveSurfaces(
std::function<void(StatusCodes)> status_codes_callback) override;
// Returns true if a foreground receive surface is registered.
bool IsInHighVisibility() const override;
// Returns true if there is an ongoing file transfer.
bool IsTransferring() const override;
// Returns true if we're currently receiving a file.
bool IsReceivingFile() const override;
// Returns true if we're currently sending a file.
bool IsSendingFile() const override;
// Returns true if we're currently attempting to connect to a
// remote device.
bool IsConnecting() const override;
// Returns true if we are currently scanning for remote devices.
bool IsScanning() const override;
+2 -13
View File
@@ -20,8 +20,10 @@
#include <memory>
#include <string>
#include "absl/base/attributes.h"
#include "absl/functional/any_invocable.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "internal/network/url.h"
#include "sharing/advertisement.h"
#include "sharing/attachment_container.h"
@@ -179,22 +181,9 @@ class NearbySharingService {
virtual void ClearForegroundReceiveSurfaces(
std::function<void(StatusCodes)> status_codes_callback) = 0;
// Returns true if a foreground receive surface is registered.
virtual bool IsInHighVisibility() const = 0;
// Returns true if there is an ongoing file transfer.
virtual bool IsTransferring() const = 0;
// Returns true if we're currently receiving a file.
virtual bool IsReceivingFile() const = 0;
// Returns true if we're currently sending a file.
virtual bool IsSendingFile() const = 0;
// Returns true if we're currently attempting to connect to a
// remote device.
virtual bool IsConnecting() const = 0;
// Returns true if we are currently scanning for remote devices.
virtual bool IsScanning() const = 0;
+4 -18
View File
@@ -696,26 +696,12 @@ void NearbySharingServiceImpl::ClearForegroundReceiveSurfaces(
});
}
bool NearbySharingServiceImpl::IsInHighVisibility() const {
return in_high_visibility_;
}
bool NearbySharingServiceImpl::IsTransferring() const {
return is_transferring_;
}
bool NearbySharingServiceImpl::IsReceivingFile() const {
return is_receiving_files_;
}
bool NearbySharingServiceImpl::IsSendingFile() const {
return is_sending_files_;
}
bool NearbySharingServiceImpl::IsScanning() const { return is_scanning_; }
bool NearbySharingServiceImpl::IsConnecting() const { return is_connecting_; }
std::string NearbySharingServiceImpl::GetQrCodeUrl() const {
return service_extension_->GetQrCodeUrl();
}
@@ -1230,10 +1216,10 @@ std::string NearbySharingServiceImpl::Dump() const {
sstream << std::boolalpha;
sstream << "Nearby Sharing Service State" << std::endl;
sstream << " IsScanning: " << IsScanning() << std::endl;
sstream << " IsConnecting: " << IsConnecting() << std::endl;
sstream << " IsTransferring: " << IsTransferring() << std::endl;
sstream << " IsSendingFile: " << IsSendingFile() << std::endl;
sstream << " IsReceivingFile: " << IsReceivingFile() << std::endl;
sstream << " IsConnecting: " << is_connecting_ << std::endl;
sstream << " IsTransferring: " << is_transferring_ << std::endl;
sstream << " IsSendingFile: " << is_sending_files_ << std::endl;
sstream << " IsReceivingFile: " << is_receiving_files_ << std::endl;
sstream << " IsScreenLocked: " << device_info_.IsScreenLocked() << std::endl;
sstream << " IsBluetoothPresent: " << IsBluetoothPresent() << std::endl;
-4
View File
@@ -143,12 +143,8 @@ class NearbySharingServiceImpl
std::function<void(StatusCodes)> status_codes_callback) override;
void ClearForegroundReceiveSurfaces(
std::function<void(StatusCodes)> status_codes_callback) override;
bool IsInHighVisibility() const override;
bool IsTransferring() const override;
bool IsReceivingFile() const override;
bool IsSendingFile() const override;
bool IsScanning() const override;
bool IsConnecting() const override;
bool IsBluetoothPresent() const override;
bool IsBluetoothPowered() const override;
bool IsExtendedAdvertisingSupported() const override;
+13 -6
View File
@@ -1349,6 +1349,13 @@ class TestObserver : public NearbySharingService::Observer {
service_->AddObserver(this);
}
~TestObserver() override {
// Check if Shutdown has been called.
if (service_ != nullptr) {
service_->RemoveObserver(this);
}
}
void OnHighVisibilityChanged(bool in_high_visibility) override {
in_high_visibility_ = in_high_visibility;
}
@@ -1378,6 +1385,7 @@ class TestObserver : public NearbySharingService::Observer {
void OnShutdown() override {
shutdown_called_ = true;
service_->RemoveObserver(this);
service_ = nullptr;
}
bool in_high_visibility_ = false;
@@ -1946,6 +1954,7 @@ TEST_F(NearbySharingServiceImplTest,
TEST_F(
NearbySharingServiceImplTest,
UnregisterForegroundReceiveSurfaceVisibilityAllContactsRestartAdvertising) {
TestObserver observer(service_.get());
SetConnectionType(ConnectionType::kWifi);
preference_manager().SetInteger(
prefs::kNearbySharingBackgroundVisibilityName,
@@ -1977,15 +1986,15 @@ TEST_F(
result = UnregisterReceiveSurface(&foreground_transfer_callback);
EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
EXPECT_FALSE(service_->IsInHighVisibility());
EXPECT_FALSE(observer.in_high_visibility_);
std::move(stop_advertising_callback)(ConnectionsStatus::kSuccess);
EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
EXPECT_FALSE(service_->IsInHighVisibility());
EXPECT_FALSE(observer.in_high_visibility_);
std::move(start_advertising_callback)(ConnectionsStatus::kSuccess);
EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
EXPECT_FALSE(service_->IsInHighVisibility());
EXPECT_FALSE(observer.in_high_visibility_);
}
TEST_F(NearbySharingServiceImplTest,
@@ -4010,7 +4019,7 @@ TEST_F(NearbySharingServiceImplTest,
local_device_data_manager()->SetDeviceName(kDeviceName);
// To start, we should not be in high visibility state.
EXPECT_FALSE(service_->IsInHighVisibility());
EXPECT_FALSE(observer.in_high_visibility_);
EXPECT_FALSE(observer.on_start_advertising_failure_called_);
// If we register a foreground surface we should end up in high visibility
@@ -4019,7 +4028,6 @@ TEST_F(NearbySharingServiceImplTest,
// At this point we should have a new high visibility state and the observer
// should have been called as well.
EXPECT_TRUE(service_->IsInHighVisibility());
EXPECT_TRUE(observer.in_high_visibility_);
EXPECT_FALSE(observer.on_start_advertising_failure_called_);
@@ -4027,7 +4035,6 @@ TEST_F(NearbySharingServiceImplTest,
// high visibility and the observer should be notified.
EXPECT_EQ(UnregisterReceiveSurface(&callback),
NearbySharingService::StatusCodes::kOk);
EXPECT_FALSE(service_->IsInHighVisibility());
EXPECT_FALSE(observer.in_high_visibility_);
// Remove the observer before it goes out of scope.