Commit 807176b3 authored by James Vecore's avatar James Vecore Committed by Chromium LUCI CQ

[Nearby] Allow Background receive surfaces to register always

This CL: https://crrev.com/c/2594308 introduced new error states to
receive surface registration which was causing the notification manager
to fail registration at startup. We can get around this issue by
allowing background receivers to register regardless of medium or
transfer state.

Change-Id: I50f8b00a0a01ea4bd6eb6b259f6c5c522fa38c07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596062
Commit-Queue: James Vecore <vecore@google.com>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Auto-Submit: James Vecore <vecore@google.com>
Cr-Commit-Position: refs/heads/master@{#837868}
parent 15fbd337
......@@ -520,6 +520,8 @@ NearbySharingServiceImpl::RegisterReceiveSurface(
DCHECK(transfer_callback);
DCHECK_NE(state, ReceiveSurfaceState::kUnknown);
// Only check these errors cases for foreground receivers.
if (state == ReceiveSurfaceState::kForeground) {
if (is_sending_files_) {
UnregisterReceiveSurface(transfer_callback);
NS_LOG(VERBOSE)
......@@ -533,6 +535,7 @@ NearbySharingServiceImpl::RegisterReceiveSurface(
NS_LOG(VERBOSE) << __func__ << ": No available connection medium.";
return StatusCodes::kNoAvailableConnectionMedium;
}
}
// We specifically allow re-registring with out error so it is clear to caller
// that the transfer_callback is currently registered.
......
......@@ -1746,7 +1746,7 @@ TEST_F(NearbySharingServiceImplTest,
}
TEST_F(NearbySharingServiceImplTest,
NoBluetoothNoNetworkRegisterReceiveSurfaceNotAdvertising) {
NoBluetoothNoNetworkRegisterForegroundReceiveSurfaceNotAdvertising) {
is_bluetooth_present_ = false;
MockTransferUpdateCallback callback;
NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
......@@ -1757,6 +1757,16 @@ TEST_F(NearbySharingServiceImplTest,
EXPECT_FALSE(fake_nearby_connections_manager_->is_shutdown());
}
TEST_F(NearbySharingServiceImplTest,
NoBluetoothNoNetworkRegisterBackgroundReceiveSurfaceWorks) {
is_bluetooth_present_ = false;
MockTransferUpdateCallback callback;
NearbySharingService::StatusCodes result = service_->RegisterReceiveSurface(
&callback, NearbySharingService::ReceiveSurfaceState::kBackground);
EXPECT_EQ(result, NearbySharingService::StatusCodes::kOk);
EXPECT_FALSE(fake_nearby_connections_manager_->IsAdvertising());
}
TEST_F(NearbySharingServiceImplTest, WifiRegisterReceiveSurfaceIsAdvertising) {
SetConnectionType(net::NetworkChangeNotifier::CONNECTION_WIFI);
MockTransferUpdateCallback callback;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment