Run multi-device NFC tests

This document explains how to run multi-device NFC tests.

Meet prerequisites

Before you run multi-device NFC tests, do the following:

  1. Prepare a device with your Android 15 implementation.
  2. Follow CTS-V requirements.
  3. Follow CTS-V setup.

Prepare a DUT and a PN532 NFC reader for the test

After you finish the previous steps, follow these steps to run prepare a DUT and a PN532 NFC reader for the test:

  1. Connect the DUT to a host machine over USB.
  2. Grant permissions for the host to access the DUT over ADB.
  3. Install the CTS Verifier app (CtsVerifier.apk) on the DUT:

    extract root/out/host/linux-x86/cts-verifier/android-cts-verifier.zip
    
    cd android-cts-verifier
    
    adb install -r -g CtsVerifier.apk
    
  4. Install the NFC test required APKs:

    cd MultiDevice
    
    adb install -r -g NfcEmulatorTestApp.apk
    

Set up NFC for the DUT

Follow these steps to run set up NFC for the DUT:

  1. On the DUT, go to the Settings menu.
  2. Look for the NFC or Connected Devices section.
  3. Ensure the NFC toggle switch is turned on.
  4. Position an NFC chip on the phone's NFC reader:

    1. Acquire a PN532 NFC chip. We recommend the All-In-One PN532, non-BLE option.
    2. Attach the PN532 NFC chip to the Linux host using a USB cable.
    3. Place the PN532 NFC chip over the phone's NFC reader as shown in the following image:

    NFC chip placement

    Figure 1. NFC chip placement.

Set up the test environment

Follow these steps to run set up the test environment:

  1. Run these commands to set up the test environment:

    cd MultiDevice
    
    source build/envsetup.sh
    

    This command checks the Python and sets up the PYTHONPATH environment variable. If no errors are printed to the terminal, the environment is ready to run the multi-device tests.

    If you see the error message libtinfo.so.6: no version information available (required by /bin/sh) at runtime, run the following command to rename the libtinfo.so.6 file:

    mv $ENV_DIRECTORY/lib/libtinfo.so.6 $ENV_DIRECTORY/lib/libtinfo.so.6.bak
    
  2. Set up the test bed by setting the device serial IDs of the DUT and PN532 NFC reader in MultiDevice/config.yml:

    TestBeds:
      - Name: CtsNfcHceMultiDeviceTestCases-py-ctsv
        Controllers:
          AndroidDevice:
            - serial: "<device-id>"
        TestParams:
          pn532_serial_path: "<pn532-serial-path>"
    

Run the NFC tests

To run the NFC tests:

  1. Open the CTS-V app and tap NFC Tests:

    The CTS-V app

    Figure 2. The CTS-V app.

    The info window with list of test cases appears:

    The CTS-V app test cases

    Figure 3. CTS-V app test cases.

  2. Run the tests on your host:

    MultiDevice$ python3 tools/run_all_tests.py
    

    When the tests are completed, the test results are updated in the CTS-V app. Successful tests are green:

    The CTS-V test results

    Figure 4. CTS-V test results.

  3. If you see any failures marked in red, use the following command to rerun the failed tests:

    python3 tools/run_all_tests.py --test_cases "`TestCaseA`" "`TestCaseB`" --test_files "`TestFileA`"
    

    Where:

    • TestCaseA and TestCaseB are the names of the test cases as displayed in CTS-V.
    • TestFileA is the test file containing the test cases.

    For example:

    python3 tools/run_all_tests.py --test_cases "test_conflicting_non_payment" "test_conflicting_non_payment_prefix" --test_files "CtsNfcHceMultiDeviceTestCases-py-ctsv"