Loading android/app/src/com/android/bluetooth/bass_client/BassClientService.java +5 −5 Original line number Diff line number Diff line Loading @@ -1958,13 +1958,13 @@ public class BassClientService extends ProfileService { log("No PA record found"); return; } if (!result.isNotified()) { result.setNotified(true); BaseData baseData = getBase(syncHandle); if (baseData == null) { log("No BaseData found"); return; } if (!result.isNotified()) { result.setNotified(true); BluetoothLeBroadcastMetadata metaData = getBroadcastMetadataFromBaseData( baseData, srcDevice, syncHandle, encrypted); Loading android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientServiceTest.java +120 −3 Original line number Diff line number Diff line Loading @@ -4520,7 +4520,7 @@ public class BassClientServiceTest { } @Test public void onBigInfoAdvertisingReport_updateRssi_notifySourceFound_once() { public void notifySourceFound_once_updateRssi() { mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_MONITOR_SOURCE_SYNC_STATUS); Loading Loading @@ -4630,14 +4630,131 @@ public class BassClientServiceTest { // Not notified second time TestUtils.waitForLooperToFinishScheduledTask(mBassClientService.getCallbacks().getLooper()); try { inOrder.verify(mCallback, never()).onSourceFound(metaData.capture()); inOrder.verify(mCallback, never()).onSourceFound(any()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @Test public void onBigInfoAdvertisingReport_notifySourceFound_alreadySynced_clearFlag() { public void notifySourceFound_periodic_after_big() { mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_MONITOR_SOURCE_SYNC_STATUS); prepareConnectedDeviceGroup(); startSearchingForSources(); onScanResult(mSourceDevice, TEST_BROADCAST_ID); onSyncEstablished(mSourceDevice, TEST_SYNC_HANDLE); assertThat(mBassClientService.getActiveSyncedSources().size()).isEqualTo(1); assertThat(mBassClientService.getActiveSyncedSources().contains(TEST_SYNC_HANDLE)).isTrue(); assertThat(mBassClientService.getDeviceForSyncHandle(TEST_SYNC_HANDLE)) .isEqualTo(mSourceDevice); assertThat(mBassClientService.getBroadcastIdForSyncHandle(TEST_SYNC_HANDLE)) .isEqualTo(TEST_BROADCAST_ID); assertThat(mBassClientService.getBase(TEST_SYNC_HANDLE)).isEqualTo(null); byte[] scanRecord = new byte[] { (byte) 0x02, (byte) 0x01, (byte) 0x1a, // advertising flags (byte) 0x05, (byte) 0x02, (byte) 0x51, (byte) 0x18, (byte) 0x0a, (byte) 0x11, // 16 bit service uuids (byte) 0x04, (byte) 0x09, (byte) 0x50, (byte) 0x65, (byte) 0x64, // name (byte) 0x02, (byte) 0x0A, (byte) 0xec, // tx power level (byte) 0x19, (byte) 0x16, (byte) 0x51, (byte) 0x18, // service data (base data with 18 bytes) // LEVEL 1 (byte) 0x01, (byte) 0x02, (byte) 0x03, // presentationDelay (byte) 0x01, // numSubGroups // LEVEL 2 (byte) 0x01, // numSubGroups (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, // UNKNOWN_CODEC (byte) 0x02, // codecConfigLength (byte) 0x01, (byte) 'A', // codecConfigInfo (byte) 0x03, // metaDataLength (byte) 0x06, (byte) 0x07, (byte) 0x08, // metaData // LEVEL 3 (byte) 0x04, // index (byte) 0x03, // codecConfigLength (byte) 0x02, (byte) 'B', (byte) 'C', // codecConfigInfo (byte) 0x05, (byte) 0xff, (byte) 0xe0, (byte) 0x00, (byte) 0x02, (byte) 0x15, // manufacturer specific data (byte) 0x03, (byte) 0x50, (byte) 0x01, (byte) 0x02, // an unknown data type won't cause trouble }; PeriodicAdvertisingReport report = new PeriodicAdvertisingReport( TEST_SYNC_HANDLE, 0, 0, 0, ScanRecord.parseFromBytes(scanRecord)); BassClientService.PACallback callback = mBassClientService.new PACallback(); // Big report before periodic so before base update callback.onBigInfoAdvertisingReport(TEST_SYNC_HANDLE, true); // Not notified TestUtils.waitForLooperToFinishScheduledTask(mBassClientService.getCallbacks().getLooper()); InOrder inOrder = inOrder(mCallback); try { inOrder.verify(mCallback, never()).onSourceFound(any()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } callback.onPeriodicAdvertisingReport(report); // Not canceled, updated base assertThat(mBassClientService.getActiveSyncedSources().size()).isEqualTo(1); assertThat(mBassClientService.getActiveSyncedSources().contains(TEST_SYNC_HANDLE)).isTrue(); assertThat(mBassClientService.getDeviceForSyncHandle(TEST_SYNC_HANDLE)) .isEqualTo(mSourceDevice); assertThat(mBassClientService.getBroadcastIdForSyncHandle(TEST_SYNC_HANDLE)) .isEqualTo(TEST_BROADCAST_ID); assertThat(mBassClientService.getBase(TEST_SYNC_HANDLE)).isNotEqualTo(null); // Next big report, should notified callback.onBigInfoAdvertisingReport(TEST_SYNC_HANDLE, true); // Notified TestUtils.waitForLooperToFinishScheduledTask(mBassClientService.getCallbacks().getLooper()); try { inOrder.verify(mCallback).onSourceFound(any()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @Test public void notifySourceFound_alreadySynced_clearFlag() { mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_MONITOR_SOURCE_SYNC_STATUS); Loading Loading
android/app/src/com/android/bluetooth/bass_client/BassClientService.java +5 −5 Original line number Diff line number Diff line Loading @@ -1958,13 +1958,13 @@ public class BassClientService extends ProfileService { log("No PA record found"); return; } if (!result.isNotified()) { result.setNotified(true); BaseData baseData = getBase(syncHandle); if (baseData == null) { log("No BaseData found"); return; } if (!result.isNotified()) { result.setNotified(true); BluetoothLeBroadcastMetadata metaData = getBroadcastMetadataFromBaseData( baseData, srcDevice, syncHandle, encrypted); Loading
android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientServiceTest.java +120 −3 Original line number Diff line number Diff line Loading @@ -4520,7 +4520,7 @@ public class BassClientServiceTest { } @Test public void onBigInfoAdvertisingReport_updateRssi_notifySourceFound_once() { public void notifySourceFound_once_updateRssi() { mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_MONITOR_SOURCE_SYNC_STATUS); Loading Loading @@ -4630,14 +4630,131 @@ public class BassClientServiceTest { // Not notified second time TestUtils.waitForLooperToFinishScheduledTask(mBassClientService.getCallbacks().getLooper()); try { inOrder.verify(mCallback, never()).onSourceFound(metaData.capture()); inOrder.verify(mCallback, never()).onSourceFound(any()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @Test public void onBigInfoAdvertisingReport_notifySourceFound_alreadySynced_clearFlag() { public void notifySourceFound_periodic_after_big() { mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_MONITOR_SOURCE_SYNC_STATUS); prepareConnectedDeviceGroup(); startSearchingForSources(); onScanResult(mSourceDevice, TEST_BROADCAST_ID); onSyncEstablished(mSourceDevice, TEST_SYNC_HANDLE); assertThat(mBassClientService.getActiveSyncedSources().size()).isEqualTo(1); assertThat(mBassClientService.getActiveSyncedSources().contains(TEST_SYNC_HANDLE)).isTrue(); assertThat(mBassClientService.getDeviceForSyncHandle(TEST_SYNC_HANDLE)) .isEqualTo(mSourceDevice); assertThat(mBassClientService.getBroadcastIdForSyncHandle(TEST_SYNC_HANDLE)) .isEqualTo(TEST_BROADCAST_ID); assertThat(mBassClientService.getBase(TEST_SYNC_HANDLE)).isEqualTo(null); byte[] scanRecord = new byte[] { (byte) 0x02, (byte) 0x01, (byte) 0x1a, // advertising flags (byte) 0x05, (byte) 0x02, (byte) 0x51, (byte) 0x18, (byte) 0x0a, (byte) 0x11, // 16 bit service uuids (byte) 0x04, (byte) 0x09, (byte) 0x50, (byte) 0x65, (byte) 0x64, // name (byte) 0x02, (byte) 0x0A, (byte) 0xec, // tx power level (byte) 0x19, (byte) 0x16, (byte) 0x51, (byte) 0x18, // service data (base data with 18 bytes) // LEVEL 1 (byte) 0x01, (byte) 0x02, (byte) 0x03, // presentationDelay (byte) 0x01, // numSubGroups // LEVEL 2 (byte) 0x01, // numSubGroups (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, // UNKNOWN_CODEC (byte) 0x02, // codecConfigLength (byte) 0x01, (byte) 'A', // codecConfigInfo (byte) 0x03, // metaDataLength (byte) 0x06, (byte) 0x07, (byte) 0x08, // metaData // LEVEL 3 (byte) 0x04, // index (byte) 0x03, // codecConfigLength (byte) 0x02, (byte) 'B', (byte) 'C', // codecConfigInfo (byte) 0x05, (byte) 0xff, (byte) 0xe0, (byte) 0x00, (byte) 0x02, (byte) 0x15, // manufacturer specific data (byte) 0x03, (byte) 0x50, (byte) 0x01, (byte) 0x02, // an unknown data type won't cause trouble }; PeriodicAdvertisingReport report = new PeriodicAdvertisingReport( TEST_SYNC_HANDLE, 0, 0, 0, ScanRecord.parseFromBytes(scanRecord)); BassClientService.PACallback callback = mBassClientService.new PACallback(); // Big report before periodic so before base update callback.onBigInfoAdvertisingReport(TEST_SYNC_HANDLE, true); // Not notified TestUtils.waitForLooperToFinishScheduledTask(mBassClientService.getCallbacks().getLooper()); InOrder inOrder = inOrder(mCallback); try { inOrder.verify(mCallback, never()).onSourceFound(any()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } callback.onPeriodicAdvertisingReport(report); // Not canceled, updated base assertThat(mBassClientService.getActiveSyncedSources().size()).isEqualTo(1); assertThat(mBassClientService.getActiveSyncedSources().contains(TEST_SYNC_HANDLE)).isTrue(); assertThat(mBassClientService.getDeviceForSyncHandle(TEST_SYNC_HANDLE)) .isEqualTo(mSourceDevice); assertThat(mBassClientService.getBroadcastIdForSyncHandle(TEST_SYNC_HANDLE)) .isEqualTo(TEST_BROADCAST_ID); assertThat(mBassClientService.getBase(TEST_SYNC_HANDLE)).isNotEqualTo(null); // Next big report, should notified callback.onBigInfoAdvertisingReport(TEST_SYNC_HANDLE, true); // Notified TestUtils.waitForLooperToFinishScheduledTask(mBassClientService.getCallbacks().getLooper()); try { inOrder.verify(mCallback).onSourceFound(any()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @Test public void notifySourceFound_alreadySynced_clearFlag() { mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_MONITOR_SOURCE_SYNC_STATUS); Loading