1# Nearby Mainline Fast Pair end-to-end tests 2 3This document refers to the Mainline Fast Pair project source code in the 4packages/modules/Connectivity/nearby. This is not an officially supported Google 5product. 6 7## About the Fast Pair Project 8 9The Connectivity Nearby mainline module is created in the Android T to host 10Better Together related functionality. Fast Pair is one of the main 11functionalities to provide seamless onboarding and integrated experiences for 12peripheral devices (for example, headsets like Google Pixel Buds) in the Nearby 13component. 14 15## Fully automated test 16 17### Prerequisites 18 19The fully automated end-to-end (e2e) tests are host-driven tests (which means 20test logics are in the host test scripts) using Mobly runner in Python. The two 21phones are installed with the test snippet 22`NearbyMultiDevicesClientsSnippets.apk` in the test time to let the host scripts 23control both sides for testing. Here's the overview of the test environment. 24 25Workstation (runs Python test scripts and controls Android devices through USB 26ADB) \ 27├── Phone 1: As Fast Pair seeker role, to scan, pair Fast Pair devices nearby \ 28└── Phone 2: As Fast Pair provider role, to simulate a Fast Pair device (for 29example, a Bluetooth headset) 30 31Note: These two phones need to be physically within 0.3 m of each other. 32 33### Prepare Phone 1 (Fast Pair seeker role) 34 35This is the phone to scan/pair Fast Pair devices nearby using the Nearby 36Mainline module. Test it by flashing with the Android T ROM. 37 38### Prepare Phone 2 (Fast Pair provider role) 39 40This is the phone to simulate a Fast Pair device (for example, a Bluetooth 41headset). Flash it with a customized ROM with the following changes: 42 43* Adjust Bluetooth profile configurations. \ 44 The Fast Pair provider simulator is an opposite role to the seeker. It needs 45 to enable/disable the following Bluetooth profile: 46 * Disable A2DP (profile_supported_a2dp) 47 * Disable the AVRCP controller (profile_supported_avrcp_controller) 48 * Enable A2DP sink (profile_supported_a2dp_sink) 49 * Enable the HFP client connection service (profile_supported_hfpclient, 50 hfp_client_connection_service_enabled) 51 * Enable the AVRCP target (profile_supported_avrcp_target) 52 * Enable the automatic audio focus request 53 (a2dp_sink_automatically_request_audio_focus) 54* Adjust Bluetooth TX power limitation in Bluetooth module and disable the 55 Fast Pair in Google Play service (aka GMS) 56 57```shell 58adb root 59adb shell am broadcast \ 60 -a 'com.google.android.gms.phenotype.FLAG_OVERRIDE' \ 61 --es package "com.google.android.gms.nearby" \ 62 --es user "\*" \ 63 --esa flags "enabled" \ 64 --esa types "boolean" \ 65 --esa values "false" \ 66 com.google.android.gms 67``` 68 69### Running tests 70 71To run the tests, enter: 72 73```shell 74atest -v CtsNearbyMultiDevicesTestSuite 75``` 76 77## Manual testing the seeker side with headsets 78 79Use this testing with headsets such as Google Pixel buds. 80 81The `FastPairTestDataProviderService.apk` is a run-time configurable Fast Pair 82data provider service (`FastPairDataProviderService`): 83 84`packages/modules/Connectivity/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider` 85 86It has a test data manager(`FastPairTestDataManager`) to receive intent 87broadcasts to add or clear the test data cache (`FastPairTestDataCache`). This 88cache provides the data to return to the Fast Pair module for onXXX calls (for 89example, `onLoadFastPairAntispoofKeyDeviceMetadata`) so you can feed the 90metadata for your device. 91 92Here are some sample uses: 93 94* Send FastPairAntispoofKeyDeviceMetadata for PixelBuds-A to 95 FastPairTestDataCache \ 96 `./fast_pair_data_provider_shell.sh -m=718c17 97 -a=../test_data/fastpair/pixelbuds-a_antispoofkey_devicemeta_json.txt` 98* Send FastPairAccountDevicesMetadata for PixelBuds-A to FastPairTestDataCache 99 \ 100 `./fast_pair_data_provider_shell.sh 101 -d=../test_data/fastpair/pixelbuds-a_account_devicemeta_json.txt` 102* Send FastPairAntispoofKeyDeviceMetadata for Provider Simulator to 103 FastPairTestDataCache \ 104 `./fast_pair_data_provider_shell.sh -m=00000c 105 -a=../test_data/fastpair/simulator_antispoofkey_devicemeta_json.txt` 106* Send FastPairAccountDevicesMetadata for Provider Simulator to 107 FastPairTestDataCache \ 108 `./fast_pair_data_provider_shell.sh 109 -d=../test_data/fastpair/simulator_account_devicemeta_json.txt` 110* Clear FastPairTestDataCache \ 111 `./fast_pair_data_provider_shell.sh -c` 112 113See 114[host/tool/fast_pair_data_provider_shell.sh](host/tool/fast_pair_data_provider_shell.sh) 115for more documentation. 116 117To install the data provider as system private app, consider remounting the 118system partition: 119 120``` 121adb root && adb remount 122``` 123 124Push it in: 125 126``` 127adb push ${ANDROID_PRODUCT_OUT}/system/app/NearbyFastPairSeekerDataProvider 128/system/priv-app/ 129``` 130 131Then reboot: 132 133``` 134adb reboot 135``` 136 137## Manual testing the seeker side with provider simulator app 138 139The `NearbyFastPairProviderSimulatorApp.apk` is a simple Android app to let you 140control the state of the Fast Pair provider simulator. Install this app on phone 1412 (Fast Pair provider role) to work correctly. 142 143See 144[clients/test_support/fastpair_provider/simulator_app/Android.bp](clients/test_support/fastpair_provider/simulator_app/Android.bp) 145for more documentation. 146