mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Do not return error in RegisterSend/Receive Surface calls in no medium are available.
PiperOrigin-RevId: 800074926
This commit is contained in:
committed by
Copybara-Service
parent
bb1fe70700
commit
cb683e484f
@@ -440,14 +440,6 @@ void NearbySharingServiceImpl::RegisterSendSurface(
|
||||
discovery_callback, blocked_vendor_id, disable_wifi_hotspot);
|
||||
|
||||
if (state == SendSurfaceState::kForeground) {
|
||||
// Only check this error case for foreground senders
|
||||
if (!HasAvailableConnectionMediums()) {
|
||||
VLOG(1) << __func__ << ": No available connection medium.";
|
||||
std::move(status_codes_callback)(
|
||||
StatusCodes::kNoAvailableConnectionMedium);
|
||||
return;
|
||||
}
|
||||
|
||||
foreground_send_surface_map_.insert(
|
||||
{transfer_callback, wrapped_callback});
|
||||
} else {
|
||||
@@ -574,13 +566,6 @@ void NearbySharingServiceImpl::RegisterReceiveSurface(
|
||||
<< ", transfer_callback: " << transfer_callback
|
||||
<< ", vendor_id: " << static_cast<uint32_t>(vendor_id);
|
||||
|
||||
// Check available mediums.
|
||||
if (!HasAvailableConnectionMediums()) {
|
||||
VLOG(1) << __func__ << ": No available connection medium.";
|
||||
std::move(status_codes_callback)(
|
||||
StatusCodes::kNoAvailableConnectionMedium);
|
||||
return;
|
||||
}
|
||||
BlockedVendorId before_registration_vendor_id = GetReceivingVendorId();
|
||||
|
||||
// We specifically allow re-registering without error, so it is clear to
|
||||
|
||||
@@ -1427,28 +1427,6 @@ TEST_F(NearbySharingServiceImplTest,
|
||||
EXPECT_EQ(fast_initiation->StartAdvertisingCount(), 0);
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest,
|
||||
StartFastInitiationAdvertising_BluetoothNotPresent) {
|
||||
SetConnectionType(ConnectionType::kNone);
|
||||
SetBluetoothIsPresent(false);
|
||||
MockTransferUpdateCallback transfer_callback;
|
||||
MockShareTargetDiscoveredCallback discovery_callback;
|
||||
EXPECT_EQ(RegisterSendSurface(&transfer_callback, &discovery_callback,
|
||||
SendSurfaceState::kForeground),
|
||||
NearbySharingService::StatusCodes::kNoAvailableConnectionMedium);
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest,
|
||||
StartFastInitiationAdvertising_BluetoothNotPowered) {
|
||||
SetConnectionType(ConnectionType::kNone);
|
||||
SetBluetoothIsPowered(false);
|
||||
MockTransferUpdateCallback transfer_callback;
|
||||
MockShareTargetDiscoveredCallback discovery_callback;
|
||||
EXPECT_EQ(RegisterSendSurface(&transfer_callback, &discovery_callback,
|
||||
SendSurfaceState::kForeground),
|
||||
NearbySharingService::StatusCodes::kNoAvailableConnectionMedium);
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest, StopFastInitiationAdvertising) {
|
||||
FakeNearbyFastInitiation* fast_initiation =
|
||||
nearby_fast_initiation_factory_->GetNearbyFastInitiation();
|
||||
@@ -2094,33 +2072,6 @@ TEST_F(NearbySharingServiceImplTest,
|
||||
EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest,
|
||||
NoBluetoothNoNetworkRegisterForegroundReceiveSurfaceNotAdvertising) {
|
||||
SetConnectionType(ConnectionType::kNone);
|
||||
SetBluetoothIsPresent(false);
|
||||
|
||||
MockTransferUpdateCallback callback;
|
||||
NearbySharingService::StatusCodes result = RegisterReceiveSurface(
|
||||
&callback, NearbySharingService::ReceiveSurfaceState::kForeground);
|
||||
EXPECT_EQ(result,
|
||||
NearbySharingService::StatusCodes::kNoAvailableConnectionMedium);
|
||||
EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
|
||||
EXPECT_FALSE(fake_nearby_connections_manager_->is_shutdown());
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest,
|
||||
NoBluetoothNoNetworkRegisterBackgroundReceiveSurfaceWorks) {
|
||||
SetConnectionType(ConnectionType::kNone);
|
||||
SetBluetoothIsPresent(false);
|
||||
|
||||
MockTransferUpdateCallback callback;
|
||||
NearbySharingService::StatusCodes result = RegisterReceiveSurface(
|
||||
&callback, NearbySharingService::ReceiveSurfaceState::kBackground);
|
||||
EXPECT_EQ(result,
|
||||
NearbySharingService::StatusCodes::kNoAvailableConnectionMedium);
|
||||
EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest, WifiRegisterReceiveSurfaceIsAdvertising) {
|
||||
SetConnectionType(ConnectionType::kWifi);
|
||||
SetVisibility(DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
@@ -2183,19 +2134,6 @@ TEST_F(NearbySharingServiceImplTest,
|
||||
EXPECT_TRUE(fake_nearby_connections_manager_->IsAdvertising());
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest,
|
||||
NoBluetoothThreeGReceiveSurfaceNotAdvertising) {
|
||||
SetBluetoothIsPresent(false);
|
||||
SetConnectionType(ConnectionType::k3G);
|
||||
MockTransferUpdateCallback callback;
|
||||
NearbySharingService::StatusCodes result = RegisterReceiveSurface(
|
||||
&callback, NearbySharingService::ReceiveSurfaceState::kForeground);
|
||||
EXPECT_EQ(result,
|
||||
NearbySharingService::StatusCodes::kNoAvailableConnectionMedium);
|
||||
EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
|
||||
EXPECT_FALSE(fake_nearby_connections_manager_->is_shutdown());
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest,
|
||||
ForegroundReceiveSurfaceNoOneVisibilityIsAdvertising) {
|
||||
SetConnectionType(ConnectionType::kWifi);
|
||||
|
||||
Reference in New Issue
Block a user