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

Commit 3d7f86da authored by Myles Watson's avatar Myles Watson
Browse files

Pandora: Add SDP/SR/ support

Test: atest pts-bot:SDP/SR -v
Bug: 239469107
Change-Id: I75606064c67dac1406547db459b4fa17a78efd5e
parent 520daca6
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import grpc


from mmi2grpc.a2dp import A2DPProxy
from mmi2grpc.a2dp import A2DPProxy
from mmi2grpc.hfp import HFPProxy
from mmi2grpc.hfp import HFPProxy
from mmi2grpc.sdp import SDPProxy
from mmi2grpc._helpers import format_proxy
from mmi2grpc._helpers import format_proxy


from pandora.host_grpc import Host
from pandora.host_grpc import Host
@@ -52,6 +53,7 @@ class IUT:
        # Profile proxies.
        # Profile proxies.
        self._a2dp = None
        self._a2dp = None
        self._hfp = None
        self._hfp = None
        self._sdp = None


    def __enter__(self):
    def __enter__(self):
        """Resets the IUT when starting a PTS test."""
        """Resets the IUT when starting a PTS test."""
@@ -63,6 +65,7 @@ class IUT:
    def __exit__(self, exc_type, exc_value, exc_traceback):
    def __exit__(self, exc_type, exc_value, exc_traceback):
        self._a2dp = None
        self._a2dp = None
        self._hfp = None
        self._hfp = None
        self._sdp = None


    def _retry(self, func):
    def _retry(self, func):


@@ -111,6 +114,11 @@ class IUT:
            if not self._hfp:
            if not self._hfp:
                self._hfp = HFPProxy(grpc.insecure_channel(f'localhost:{self.port}'))
                self._hfp = HFPProxy(grpc.insecure_channel(f'localhost:{self.port}'))
            return self._hfp.interact(test, interaction, description, pts_address)
            return self._hfp.interact(test, interaction, description, pts_address)
        # Handles SDP MMIs.
        if profile in ('SDP'):
            if not self._sdp:
                self._sdp = SDPProxy(grpc.insecure_channel(f'localhost:{self.port}'))
            return self._sdp.interact(test, interaction, description, pts_address)


        # Handles unsupported profiles.
        # Handles unsupported profiles.
        code = format_proxy(profile, interaction, description)
        code = format_proxy(profile, interaction, description)
+105 −0
Original line number Original line Diff line number Diff line
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""SDP proxy module."""

from mmi2grpc._helpers import assert_description
from mmi2grpc._proxy import ProfileProxy

import sys
import threading
import os
import socket


class SDPProxy(ProfileProxy):

    def __init__(self, channel: str):
        super().__init__()

    @assert_description
    def _mmi_6000(self, **kwargs):
        """
        If necessary take action to accept the SDP channel connection.
        """

        return "OK"

    @assert_description
    def _mmi_6001(self, **kwargs):
        """
        If necessary take action to respond to the Service Attribute operation
        appropriately.
        """

        return "OK"

    @assert_description
    def _mmi_6002(self, **kwargs):
        """
        If necessary take action to accept the Service Search operation.
        """

        return "OK"

    @assert_description
    def _mmi_6003(self, **kwargs):
        """
        If necessary take action to respond to the Service Search Attribute
        operation appropriately.
        """

        return "OK"

    @assert_description
    def TSC_SDP_mmi_verify_browsable_services(self, **kwargs):
        """
        Are all browsable service classes listed below?

        0x1800, 0x110A, 0x110C,
        0x110E, 0x1112, 0x1203, 0x111F, 0x1203, 0x1855, 0x1132, 0x1116, 0x1115,
        0x112F, 0x1105
        """
        """
        This is the decoded list of UUIDs:
            Service Classes and Profiles 0x1105 OBEXObjectPush
            Service Classes and Profiles 0x110A AudioSource
            Service Classes and Profiles 0x110C A/V_RemoteControlTarget
            Service Classes and Profiles 0x110E A/V_RemoteControl
            Service Classes and Profiles 0x1112 Headset - Audio Gateway
            Service Classes and Profiles 0x1115 PANU
            Service Classes and Profiles 0x1116 NAP
            Service Classes and Profiles 0x111F HandsfreeAudioGateway
            Service Classes and Profiles 0x112F Phonebook Access - PSE
            Service Classes and Profiles 0x1132 Message Access Server
            Service Classes and Profiles 0x1203 GenericAudio
            GATT Service 0x1800 Generic Access
            GATT Service 0x1855 TMAS

        The Android API only returns a subset of the profiles:
            0x110A, 0x1112, 0x111F, 0x112F, 0x1132,

        Since the API doesn't return the full set, this test uses the
        description to check that the number of profiles does not change
        from the last time the test was successfully run.

        Adding or Removing services from Android will cause this
        test to be fail.  Updating the description above will cause
        it to pass again.

        The other option is to add a call to btif_enable_service() for each
        profile which is browsable in SDP.  Then you can add a Host GRPC call
        to BluetoothAdapter.getUuidsList and match the returned UUIDs to the
        list given by PTS.
        """
        return "OK"
+1 −0
Original line number Original line Diff line number Diff line
@@ -25,5 +25,6 @@
        <option name="profile" value="HFP/AG/DIS" />
        <option name="profile" value="HFP/AG/DIS" />
        <option name="profile" value="HFP/AG/HFI" />
        <option name="profile" value="HFP/AG/HFI" />
        <option name="profile" value="HFP/AG/SLC" />
        <option name="profile" value="HFP/AG/SLC" />
        <option name="profile" value="SDP/SR" />
    </test>
    </test>
</configuration>
</configuration>