Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8dc69002 authored by Abel Lucas's avatar Abel Lucas Committed by Gerrit Code Review
Browse files

Merge changes from topics "avatar-update-2", "re-enable-asha-tests" into main

* changes:
  avatar: re-enable skiped ASHA tests
  avatar: update
parents f4bf386b f14fd520
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ python_test_host {
    main: "main.py",
    srcs: [
        "*.py",
        ":avatar-cases",
    ],
    libs: [
        "bumble_services_experimental-python",
+0 −18
Original line number Diff line number Diff line
@@ -86,21 +86,6 @@ class AshaTest(base_test.BaseTestClass): # type: ignore[misc]

    @avatar.asynchronous
    async def setup_test(self) -> None:
        # TODO(b/296927588): Test should pass with a random identity address
        # We have to update the config before the reset otherwise it'll be overridden
        random_identity_address_type_list = [
            "test_auto_connection(1,1)",
            "test_advertising_advertisement_data(1,1)",
            "test_advertising_scan_response",
            "test_auto_connection_dual_device(1,1,0)",
            "test_auto_connection_dual_device(1,1,1)",
        ]
        if self.current_test_info.name in random_identity_address_type_list:
            self.ref_left._bumble.config.update({'server': {'identity_address_type': 'random'}})
            self.ref_right._bumble.config.update({'server': {'identity_address_type': 'random'}})
        else:
            self.ref_left._bumble.config.update({'server': {'identity_address_type': 'public'}})
            self.ref_right._bumble.config.update({'server': {'identity_address_type': 'public'}})
        await asyncio.gather(self.dut.reset(), self.ref_left.reset(), self.ref_right.reset())

        # ASHA hearing aid's IO capability is NO_OUTPUT_NO_INPUT
@@ -698,9 +683,6 @@ class AshaTest(base_test.BaseTestClass): # type: ignore[misc]
           2. The disconnected peripheral starts sending ASHA advertisements.
           3. Verify that DUT auto-connects to the peripheral.
        """
        # This tests need to be reactivated ASAP
        if ref_address_type == PUBLIC:
            raise signals.TestSkip('TODO: b/296927588')

        advertisement_left = await self.ref_advertise_asha(
            ref_device=self.ref_left, ref_address_type=ref_address_type, ear=Ear.LEFT
+7 −6
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ _VENV_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/avatar/venv"
_BT_ROOT="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth"
_TEST_ROOT="${_BT_ROOT}/android/pandora/test"
_PY_SOURCES=(
  "${ANDROID_BUILD_TOP}/external/pandora/avatar/"{avatar,cases}
  "${_BT_ROOT}/pandora/server/bumble_experimental"
  "${_TEST_ROOT}/"*.py
)
@@ -35,6 +34,7 @@ _PANDORA_PYTHON_PATHS=(
  "${ANDROID_BUILD_TOP}/external/python/bumble/"
  "${ANDROID_BUILD_TOP}/external/python/mobly/"
  "${ANDROID_BUILD_TOP}/external/python/pyee/"
  "${ANDROID_BUILD_TOP}/external/python/portpicker/src/"
  "${ANDROID_BUILD_TOP}/out/soong/.intermediates/external/pandora/bt-test-interfaces/python/pandora-python-gen-src/gen/"
  "${ANDROID_BUILD_TOP}/out/soong/.intermediates/packages/modules/Bluetooth/pandora/interfaces/python/pandora_experimental-python-gen-src/gen/"
)
@@ -43,13 +43,14 @@ if [[ "$1" =~ ^('format'|'lint'|'run')$ ]]; then
  [ ! -d "${_VENV_DIR}" ] && python3 -m venv "${_VENV_DIR}"
  source "${_VENV_DIR}"/bin/activate
  pip install \
    'grpcio==1.51.1' \
    'grpcio==1.57' \
    'cryptography==35' \
    'protobuf==4.22.1' \
    'numpy==1.25.2' \
    'protobuf==4.24.2' \
    'mypy==1.5.1' \
    'pyright==1.1.298' \
    'mypy==1.1.1' \
    'types-protobuf==4.22.0.1' \
    'black==22.10.0' \
    'types-protobuf==4.24.0.1' \
    'black==23.7.0' \
    'isort==5.12.0'
  export PYTHONPATH="$(IFS=:; echo "${_PANDORA_PYTHON_PATHS[*]}"):${PYTHONPATH}"
fi
+12 −9
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import logging
from avatar import BumblePandoraDevice, PandoraDevice, PandoraDevices
from bumble import pandora as bumble_server
from bumble.gatt import Characteristic, Service
from bumble.l2cap import L2CAP_Control_Frame
from bumble.pairing import PairingConfig
from bumble_experimental.gatt import GATTService
from mobly import base_test, signals, test_runner
@@ -263,7 +264,8 @@ class GattTest(base_test.BaseTestClass): # type: ignore[misc]
        connection = self.ref.device.lookup_connection(int.from_bytes(ref_dut.cookie.value, 'big'))
        assert connection

        connection_request = (
        connection_request = L2CAP_Control_Frame.from_bytes(
            (
                b"\x17"  # code of L2CAP_CREDIT_BASED_CONNECTION_REQ
                b"\x01"  # identifier
                b"\x0a\x00"  # data length
@@ -273,6 +275,7 @@ class GattTest(base_test.BaseTestClass): # type: ignore[misc]
                b"\x64\x00"  # initial credit
                b"\x40\x00"  # source cid[0]
            )
        )

        fut = asyncio.get_running_loop().create_future()
        setattr(self.ref.device.l2cap_channel_manager, "on_[0x18]", lambda _, _1, frame: fut.set_result(frame))
+12 −10
Original line number Diff line number Diff line
@@ -14,10 +14,12 @@

import asyncio
import avatar
import collections
import logging

from avatar import BumblePandoraDevice, PandoraDevice, PandoraDevices
from avatar.pandora_server import AndroidPandoraServer
from bumble import rfcomm
from bumble.colors import color
from bumble.core import (
    BT_GENERIC_AUDIO_SERVICE,
@@ -25,7 +27,6 @@ from bumble.core import (
    BT_L2CAP_PROTOCOL_ID,
    BT_RFCOMM_PROTOCOL_ID,
)
from bumble import rfcomm
from bumble.rfcomm import DLC, Server as RfcommServer
from bumble.sdp import (
    SDP_BLUETOOTH_PROFILE_DESCRIPTOR_LIST_ATTRIBUTE_ID,
@@ -35,7 +36,6 @@ from bumble.sdp import (
    DataElement,
    ServiceAttribute,
)
import collections
from mobly import base_test, test_runner
from mobly.asserts import assert_equal  # type: ignore
from mobly.asserts import assert_in  # type: ignore
@@ -63,10 +63,12 @@ HFP_VERSION_1_7 = 0x0107
# Stub for Audio Gateway implementation
# TODO: b/296471045
logger = logging.getLogger(__name__)


class HfpProtocol:
    dlc: rfcomm.DLC
    buffer: str
    lines: collections.deque
    lines: collections.deque[str]
    lines_available: asyncio.Event

    def __init__(self, dlc: rfcomm.DLC) -> None:
@@ -112,6 +114,7 @@ class HfpProtocol:
        logger.debug(color(f'<<< {line}', 'green'))
        return line


class HfpClientTest(base_test.BaseTestClass):  # type: ignore[misc]
    devices: Optional[PandoraDevices] = None

@@ -139,11 +142,11 @@ class HfpClientTest(base_test.BaseTestClass): # type: ignore[misc]
            if isinstance(server, AndroidPandoraServer):
                self.dut_adb = server.device.adb
                # Enable HFP Client
                self.dut_adb.shell(['setprop', PROPERTY_HF_ENABLED, 'true'])
                self.dut_adb.shell(['setprop', PROPERTY_HF_ENABLED, 'true'])  # type: ignore
                # Set HF features if not set yet
                hf_feature_text = self.dut_adb.getprop(PROPERTY_HF_FEATURES)
                hf_feature_text = self.dut_adb.getprop(PROPERTY_HF_FEATURES)  # type: ignore
                if len(hf_feature_text) == 0:
                    self.dut_adb.shell(['setprop', PROPERTY_HF_FEATURES, HFP_HF_FEATURE_DEFAULT])
                    self.dut_adb.shell(['setprop', PROPERTY_HF_FEATURES, HFP_HF_FEATURE_DEFAULT])  # type: ignore
                break

    def teardown_class(self) -> None:
@@ -203,9 +206,9 @@ class HfpClientTest(base_test.BaseTestClass): # type: ignore[misc]
    @avatar.asynchronous
    async def test_hf_indicator_setup(self, enhanced_driver_safety_enabled: bool) -> None:
        if enhanced_driver_safety_enabled:
            self.dut_adb.shell(['setprop', PROPERTY_HF_INDICATOR_ENHANCED_DRIVER_SAFETY, 'true'])
            self.dut_adb.shell(['setprop', PROPERTY_HF_INDICATOR_ENHANCED_DRIVER_SAFETY, 'true'])  # type: ignore
        else:
            self.dut_adb.shell(['setprop', PROPERTY_HF_INDICATOR_ENHANCED_DRIVER_SAFETY, 'false'])
            self.dut_adb.shell(['setprop', PROPERTY_HF_INDICATOR_ENHANCED_DRIVER_SAFETY, 'false'])  # type: ignore

        ref_dut_hfp_protocol = await self.make_hfp_connection()

@@ -361,7 +364,6 @@ class HfpAgServer:
        self.send_response_line('OK')



if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    test_runner.main()  # type: ignore
Loading