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

Commit 1e72270f authored by uael's avatar uael
Browse files

avatar: update

Bug: 299622404
Test: atest avatar
Change-Id: I6723c6bf46662da659d02db737ec1a68b85f0756
parent abe3ac92
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",
+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
+8 −8
Original line number Diff line number Diff line
@@ -15,20 +15,20 @@ _BUMBLE_BTSNOOP_FMT = 'bumble_btsnoop_{pid}_{instance}.log'

# Import test cases modules.
import asha_test
import cases.host_test
import cases.le_host_test
import cases.le_security_test
import cases.security_test
import avatar.cases.host_test
import avatar.cases.le_host_test
import avatar.cases.le_security_test
import avatar.cases.security_test
import gatt_test
import hfpclient_test
import sdp_test
import smp_test

_TEST_CLASSES_LIST = [
    cases.host_test.HostTest,
    cases.le_host_test.LeHostTest,
    cases.security_test.SecurityTest,
    cases.le_security_test.LeSecurityTest,
    avatar.cases.host_test.HostTest,
    avatar.cases.le_host_test.LeHostTest,
    avatar.cases.security_test.SecurityTest,
    avatar.cases.le_security_test.LeSecurityTest,
    sdp_test.SdpTest,
    smp_test.SmpTest,
    gatt_test.GattTest,
Loading