Loading framework/tests/bumble/Android.bp +25 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,31 @@ java_test_host { ], } // Runs the Bumble Bluetooth tests on a USB Bluetooth dongle. java_test_host { name: "BumbleBluetoothTestsPhy", test_config: "AndroidPhyTest.xml", libs: [ "tradefed", ], data: [ ":BumbleBluetoothTestsApp", "bumble_config.json", ], data_native_bins: [ "bumble_pandora_server", ], required: ["bumble_pandora_server"], test_suites: [ "general-tests", ], } python_binary_host { name: "bumble_pandora_server", main: "src/bumble_server.py", Loading framework/tests/bumble/AndroidPhyTest.xml 0 → 100644 +61 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <configuration description="Bumble bluetooth tests."> <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"> <option name="force-root" value="true"/> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <option name="cleanup-apks" value="true" /> <option name="test-file-name" value="BumbleBluetoothTestsApp.apk" /> <option name="install-arg" value="-g" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.PythonVirtualenvPreparer"> <option name="dep-module" value="grpcio==1.51.1" /> <option name="dep-module" value="cryptography==35" /> <option name="dep-module" value="libusb1>=2.0.1" /> <option name="dep-module" value="libusb-package==1.0.26.1" /> <option name="dep-module" value="pyusb>=1.2" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunHostCommandTargetPreparer"> <option name="python-virtualenv" value="true"/> <option name="host-setup-command" value="adb -s $SERIAL reverse tcp:7999 tcp:7999" /> <option name="host-background-command" value="$EXTRA_FILE(host_testcases)/BumbleBluetoothTests/bumble_pandora_server --transport pyusb:8087:0036 --config $EXTRA_FILE(host_testcases)/BumbleBluetoothTests/bumble_config.json"/> <option name="host-teardown-command" value="adb -s $SERIAL reverse --remove tcp:7999" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> <option name="throw-if-cmd-fail" value="true" /> <option name="run-command" value="setprop persist.bluetooth.btsnooplogmode full" /> <option name="run-command" value="device_config set_sync_disabled_for_tests persistent" /> <option name="run-command" value="setprop log.tag.bluetooth VERBOSE" /> <option name="run-command" value="settings put global ble_scan_always_enabled 0" /> <option name="run-command" value="cmd bluetooth_manager disable" /> <option name="run-command" value="cmd bluetooth_manager wait-for-state:STATE_OFF" /> <option name="run-command" value="cmd bluetooth_manager enable" /> <option name="run-command" value="cmd bluetooth_manager wait-for-state:STATE_ON" /> </target_preparer> <option name="test-tag" value="BumbleBluetoothTests" /> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="android.bluetooth" /> </test> <!-- Only run if the Bluetooth Mainline module is installed. --> <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController"> <option name="mainline-module-package-name" value="com.android.btservices" /> <option name="mainline-module-package-name" value="com.google.android.btservices" /> </object> <!-- Collect Bluetooth snoop logs for each test run --> <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector"> <option name="directory-keys" value="/data/misc/bluetooth/logs" /> <option name="collect-on-run-ended-only" value="false" /> <option name="clean-up" value="false" /> </metrics_collector> </configuration> framework/tests/bumble/src/android/bluetooth/pairing/PairingTest.java +68 −5 Original line number Diff line number Diff line Loading @@ -170,11 +170,10 @@ public class PairingTest { * <ol> * <li>1. Bumble resets, enables inquiry and page scan, and sets I/O cap to no display no * input * <li>2. Android connects to Bumble via its MAC address * <li>3. Android tries to create bond, emitting bonding intent 4. Android confirms the * pairing via pairing request intent * <li>5. Bumble confirms the pairing internally (optional, added only for test confirmation) * <li>6. Android verifies bonded intent * <li>2. Android tries to create bond via MAC address, emitting bonding intent * <li>3. Android confirms the pairing via pairing request intent * <li>4. Bumble confirms the pairing internally (optional, added only for test confirmation) * <li>5. Android verifies bonded intent * </ol> */ @Test Loading Loading @@ -217,6 +216,70 @@ public class PairingTest { BluetoothDevice.ACTION_BOND_STATE_CHANGED, BluetoothDevice.ACTION_PAIRING_REQUEST); } /** * Test a simple BR/EDR just works pairing flow in the follow steps: * * <ol> * <li>1. Bumble resets, enables inquiry and page scan, and sets I/O cap to no display no * input * <li>2. Android connects to Bumble via its MAC address * <li>3. Android tries to create bond, emitting bonding intent * <li>4. Android confirms the pairing via pairing request intent * <li>5. Bumble confirms the pairing internally (optional, added only for test confirmation) * <li>6. Android verifies bonded intent * </ol> */ @Test public void testBrEdrPairing_phoneInitiatedBrEdrInquiryOnlyJustWorksWhileSdpConnected() { registerIntentActions( BluetoothDevice.ACTION_ACL_CONNECTED, BluetoothDevice.ACTION_BOND_STATE_CHANGED, BluetoothDevice.ACTION_PAIRING_REQUEST); // Start SDP. This will create an ACL connection before the bonding starts. assertThat(mBumbleDevice.fetchUuidsWithSdp(BluetoothDevice.TRANSPORT_BREDR)).isTrue(); verifyIntentReceived( hasAction(BluetoothDevice.ACTION_ACL_CONNECTED), hasExtra(BluetoothDevice.EXTRA_DEVICE, mBumbleDevice)); StreamObserver<PairingEventAnswer> pairingEventAnswerObserver = mBumble.security() .withDeadlineAfter(BOND_INTENT_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS) .onPairing(mPairingEventStreamObserver); assertThat(mBumbleDevice.createBond()).isTrue(); verifyIntentReceived( hasAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED), hasExtra(BluetoothDevice.EXTRA_DEVICE, mBumbleDevice), hasExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_BONDING)); verifyIntentReceived( hasAction(BluetoothDevice.ACTION_PAIRING_REQUEST), hasExtra(BluetoothDevice.EXTRA_DEVICE, mBumbleDevice), hasExtra( BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_CONSENT)); mBumbleDevice.setPairingConfirmation(true); PairingEvent pairingEvent = mPairingEventStreamObserver.iterator().next(); assertThat(pairingEvent.hasJustWorks()).isTrue(); pairingEventAnswerObserver.onNext( PairingEventAnswer.newBuilder().setEvent(pairingEvent).setConfirm(true).build()); verifyIntentReceived( hasAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED), hasExtra(BluetoothDevice.EXTRA_DEVICE, mBumbleDevice), hasExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_BONDED)); verifyNoMoreInteractions(mReceiver); unregisterIntentActions( BluetoothDevice.ACTION_ACL_CONNECTED, BluetoothDevice.ACTION_BOND_STATE_CHANGED, BluetoothDevice.ACTION_PAIRING_REQUEST); } /** * Test if parallel GATT service discovery interrupts cancelling LE pairing * Loading system/gd/hci/acl_manager/le_impl.h +8 −2 Original line number Diff line number Diff line Loading @@ -79,6 +79,10 @@ static const std::string kPropertyConnScanWindow2mFast = "bluetooth.core.le.conn static const std::string kPropertyConnScanWindowCodedFast = "bluetooth.core.le.connection_scan_window_coded_fast"; static const std::string kPropertyConnScanIntervalSlow = "bluetooth.core.le.connection_scan_interval_slow"; static const std::string kPropertyConnScanWindowSlow = "bluetooth.core.le.connection_scan_window_slow"; static const std::string kPropertyConnScanIntervalSystemSuspend = "bluetooth.core.le.connection_scan_interval_system_suspend"; static const std::string kPropertyConnScanWindowSystemSuspend = "bluetooth.core.le.connection_scan_window_system_suspend"; static const std::string kPropertyEnableBlePrivacy = "bluetooth.core.gap.le.privacy.enabled"; static const std::string kPropertyEnableBleOnlyInit1mPhy = "bluetooth.core.gap.le.conn.only_init_1m_phy.enabled"; Loading Loading @@ -829,8 +833,10 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } // Use specific parameters when in system suspend. if (system_suspend_) { le_scan_interval = kScanIntervalSystemSuspend; le_scan_window = kScanWindowSystemSuspend; le_scan_interval = os::GetSystemPropertyUint32( kPropertyConnScanIntervalSystemSuspend, kScanIntervalSystemSuspend); le_scan_window = os::GetSystemPropertyUint32( kPropertyConnScanWindowSystemSuspend, kScanWindowSystemSuspend); le_scan_window_2m = le_scan_window; le_scan_window_coded = le_scan_window; } Loading system/gd/sysprops/sysprops_module.cc +2 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,8 @@ void SyspropsModule::parse_config(std::string file_path) { "bluetooth.core.le.connection_scan_window_coded_fast", "bluetooth.core.le.connection_scan_interval_slow", "bluetooth.core.le.connection_scan_window_slow", "bluetooth.core.le.connection_scan_interval_system_suspend", "bluetooth.core.le.connection_scan_window_system_suspend", "bluetooth.core.le.inquiry_scan_interval", "bluetooth.core.le.inquiry_scan_window", "bluetooth.core.le.adv_mon_scan_interval", Loading Loading
framework/tests/bumble/Android.bp +25 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,31 @@ java_test_host { ], } // Runs the Bumble Bluetooth tests on a USB Bluetooth dongle. java_test_host { name: "BumbleBluetoothTestsPhy", test_config: "AndroidPhyTest.xml", libs: [ "tradefed", ], data: [ ":BumbleBluetoothTestsApp", "bumble_config.json", ], data_native_bins: [ "bumble_pandora_server", ], required: ["bumble_pandora_server"], test_suites: [ "general-tests", ], } python_binary_host { name: "bumble_pandora_server", main: "src/bumble_server.py", Loading
framework/tests/bumble/AndroidPhyTest.xml 0 → 100644 +61 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <configuration description="Bumble bluetooth tests."> <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"> <option name="force-root" value="true"/> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <option name="cleanup-apks" value="true" /> <option name="test-file-name" value="BumbleBluetoothTestsApp.apk" /> <option name="install-arg" value="-g" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.PythonVirtualenvPreparer"> <option name="dep-module" value="grpcio==1.51.1" /> <option name="dep-module" value="cryptography==35" /> <option name="dep-module" value="libusb1>=2.0.1" /> <option name="dep-module" value="libusb-package==1.0.26.1" /> <option name="dep-module" value="pyusb>=1.2" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunHostCommandTargetPreparer"> <option name="python-virtualenv" value="true"/> <option name="host-setup-command" value="adb -s $SERIAL reverse tcp:7999 tcp:7999" /> <option name="host-background-command" value="$EXTRA_FILE(host_testcases)/BumbleBluetoothTests/bumble_pandora_server --transport pyusb:8087:0036 --config $EXTRA_FILE(host_testcases)/BumbleBluetoothTests/bumble_config.json"/> <option name="host-teardown-command" value="adb -s $SERIAL reverse --remove tcp:7999" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> <option name="throw-if-cmd-fail" value="true" /> <option name="run-command" value="setprop persist.bluetooth.btsnooplogmode full" /> <option name="run-command" value="device_config set_sync_disabled_for_tests persistent" /> <option name="run-command" value="setprop log.tag.bluetooth VERBOSE" /> <option name="run-command" value="settings put global ble_scan_always_enabled 0" /> <option name="run-command" value="cmd bluetooth_manager disable" /> <option name="run-command" value="cmd bluetooth_manager wait-for-state:STATE_OFF" /> <option name="run-command" value="cmd bluetooth_manager enable" /> <option name="run-command" value="cmd bluetooth_manager wait-for-state:STATE_ON" /> </target_preparer> <option name="test-tag" value="BumbleBluetoothTests" /> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="android.bluetooth" /> </test> <!-- Only run if the Bluetooth Mainline module is installed. --> <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController"> <option name="mainline-module-package-name" value="com.android.btservices" /> <option name="mainline-module-package-name" value="com.google.android.btservices" /> </object> <!-- Collect Bluetooth snoop logs for each test run --> <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector"> <option name="directory-keys" value="/data/misc/bluetooth/logs" /> <option name="collect-on-run-ended-only" value="false" /> <option name="clean-up" value="false" /> </metrics_collector> </configuration>
framework/tests/bumble/src/android/bluetooth/pairing/PairingTest.java +68 −5 Original line number Diff line number Diff line Loading @@ -170,11 +170,10 @@ public class PairingTest { * <ol> * <li>1. Bumble resets, enables inquiry and page scan, and sets I/O cap to no display no * input * <li>2. Android connects to Bumble via its MAC address * <li>3. Android tries to create bond, emitting bonding intent 4. Android confirms the * pairing via pairing request intent * <li>5. Bumble confirms the pairing internally (optional, added only for test confirmation) * <li>6. Android verifies bonded intent * <li>2. Android tries to create bond via MAC address, emitting bonding intent * <li>3. Android confirms the pairing via pairing request intent * <li>4. Bumble confirms the pairing internally (optional, added only for test confirmation) * <li>5. Android verifies bonded intent * </ol> */ @Test Loading Loading @@ -217,6 +216,70 @@ public class PairingTest { BluetoothDevice.ACTION_BOND_STATE_CHANGED, BluetoothDevice.ACTION_PAIRING_REQUEST); } /** * Test a simple BR/EDR just works pairing flow in the follow steps: * * <ol> * <li>1. Bumble resets, enables inquiry and page scan, and sets I/O cap to no display no * input * <li>2. Android connects to Bumble via its MAC address * <li>3. Android tries to create bond, emitting bonding intent * <li>4. Android confirms the pairing via pairing request intent * <li>5. Bumble confirms the pairing internally (optional, added only for test confirmation) * <li>6. Android verifies bonded intent * </ol> */ @Test public void testBrEdrPairing_phoneInitiatedBrEdrInquiryOnlyJustWorksWhileSdpConnected() { registerIntentActions( BluetoothDevice.ACTION_ACL_CONNECTED, BluetoothDevice.ACTION_BOND_STATE_CHANGED, BluetoothDevice.ACTION_PAIRING_REQUEST); // Start SDP. This will create an ACL connection before the bonding starts. assertThat(mBumbleDevice.fetchUuidsWithSdp(BluetoothDevice.TRANSPORT_BREDR)).isTrue(); verifyIntentReceived( hasAction(BluetoothDevice.ACTION_ACL_CONNECTED), hasExtra(BluetoothDevice.EXTRA_DEVICE, mBumbleDevice)); StreamObserver<PairingEventAnswer> pairingEventAnswerObserver = mBumble.security() .withDeadlineAfter(BOND_INTENT_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS) .onPairing(mPairingEventStreamObserver); assertThat(mBumbleDevice.createBond()).isTrue(); verifyIntentReceived( hasAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED), hasExtra(BluetoothDevice.EXTRA_DEVICE, mBumbleDevice), hasExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_BONDING)); verifyIntentReceived( hasAction(BluetoothDevice.ACTION_PAIRING_REQUEST), hasExtra(BluetoothDevice.EXTRA_DEVICE, mBumbleDevice), hasExtra( BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_CONSENT)); mBumbleDevice.setPairingConfirmation(true); PairingEvent pairingEvent = mPairingEventStreamObserver.iterator().next(); assertThat(pairingEvent.hasJustWorks()).isTrue(); pairingEventAnswerObserver.onNext( PairingEventAnswer.newBuilder().setEvent(pairingEvent).setConfirm(true).build()); verifyIntentReceived( hasAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED), hasExtra(BluetoothDevice.EXTRA_DEVICE, mBumbleDevice), hasExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_BONDED)); verifyNoMoreInteractions(mReceiver); unregisterIntentActions( BluetoothDevice.ACTION_ACL_CONNECTED, BluetoothDevice.ACTION_BOND_STATE_CHANGED, BluetoothDevice.ACTION_PAIRING_REQUEST); } /** * Test if parallel GATT service discovery interrupts cancelling LE pairing * Loading
system/gd/hci/acl_manager/le_impl.h +8 −2 Original line number Diff line number Diff line Loading @@ -79,6 +79,10 @@ static const std::string kPropertyConnScanWindow2mFast = "bluetooth.core.le.conn static const std::string kPropertyConnScanWindowCodedFast = "bluetooth.core.le.connection_scan_window_coded_fast"; static const std::string kPropertyConnScanIntervalSlow = "bluetooth.core.le.connection_scan_interval_slow"; static const std::string kPropertyConnScanWindowSlow = "bluetooth.core.le.connection_scan_window_slow"; static const std::string kPropertyConnScanIntervalSystemSuspend = "bluetooth.core.le.connection_scan_interval_system_suspend"; static const std::string kPropertyConnScanWindowSystemSuspend = "bluetooth.core.le.connection_scan_window_system_suspend"; static const std::string kPropertyEnableBlePrivacy = "bluetooth.core.gap.le.privacy.enabled"; static const std::string kPropertyEnableBleOnlyInit1mPhy = "bluetooth.core.gap.le.conn.only_init_1m_phy.enabled"; Loading Loading @@ -829,8 +833,10 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } // Use specific parameters when in system suspend. if (system_suspend_) { le_scan_interval = kScanIntervalSystemSuspend; le_scan_window = kScanWindowSystemSuspend; le_scan_interval = os::GetSystemPropertyUint32( kPropertyConnScanIntervalSystemSuspend, kScanIntervalSystemSuspend); le_scan_window = os::GetSystemPropertyUint32( kPropertyConnScanWindowSystemSuspend, kScanWindowSystemSuspend); le_scan_window_2m = le_scan_window; le_scan_window_coded = le_scan_window; } Loading
system/gd/sysprops/sysprops_module.cc +2 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,8 @@ void SyspropsModule::parse_config(std::string file_path) { "bluetooth.core.le.connection_scan_window_coded_fast", "bluetooth.core.le.connection_scan_interval_slow", "bluetooth.core.le.connection_scan_window_slow", "bluetooth.core.le.connection_scan_interval_system_suspend", "bluetooth.core.le.connection_scan_window_system_suspend", "bluetooth.core.le.inquiry_scan_interval", "bluetooth.core.le.inquiry_scan_window", "bluetooth.core.le.adv_mon_scan_interval", Loading