Skip to content
Snippets Groups Projects
Commit 7b40aa36 authored by Xinyi Zhou's avatar Xinyi Zhou
Browse files

[nearby] Returns error code for startBroadcast if there is an existing broadcast

Fix: 294461081
Test: -m
Ignore-AOSP-First: nearby_not_in_aosp_yet
Change-Id: Icc3227ec5aa7d0ea7d33b7100ef131928577b5a7
parent 860f2ac0
No related branches found
No related tags found
No related merge requests found
......@@ -79,6 +79,12 @@ public class BroadcastProviderManager implements BleBroadcastProvider.BroadcastL
if (listener == null) {
return;
}
if (mBroadcastListener != null) {
Log.i(TAG, "We do not support multi clients yet,"
+ " please stop previous broadcast first.");
reportBroadcastStatus(listener, BroadcastCallback.STATUS_FAILURE);
return;
}
if (!mNearbyConfiguration.isTestAppSupported()) {
NearbyConfiguration configuration = new NearbyConfiguration();
if (!configuration.isPresenceBroadcastLegacyEnabled()) {
......
......@@ -24,6 +24,7 @@ import static com.android.server.nearby.NearbyConfiguration.NEARBY_SUPPORT_TEST_
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
......@@ -125,6 +126,16 @@ public class BroadcastProviderManagerTest {
verify(mBinder).unlinkToDeath(any(), eq(0));
}
@Test
public void testRegisterAdvertising_twoTimes_fail() throws Exception {
IBroadcastListener newListener = mock(IBroadcastListener.class);
IBinder newBinder = mock(IBinder.class);
when(newListener.asBinder()).thenReturn(newBinder);
mBroadcastProviderManager.startBroadcast(mBroadcastRequest, mBroadcastListener);
mBroadcastProviderManager.startBroadcast(mBroadcastRequest, newListener);
verify(newListener).onStatusChanged(eq(BroadcastCallback.STATUS_FAILURE));
}
@Test
public void testStartAdvertising_featureDisabled() throws Exception {
DeviceConfig.setProperty(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment