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

Commit 752b5ffc authored by Bidhya Sharma's avatar Bidhya Sharma Committed by Gerrit Code Review
Browse files

Merge "[PANDORA_TEST] Implement SMP test on pts-bot"

parents 52881780 80996c6e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import grpc
from mmi2grpc.a2dp import A2DPProxy
from mmi2grpc.hfp import HFPProxy
from mmi2grpc.sdp import SDPProxy
from mmi2grpc.sm import SMProxy
from mmi2grpc._helpers import format_proxy

from pandora.host_grpc import Host
@@ -54,6 +55,7 @@ class IUT:
        self._a2dp = None
        self._hfp = None
        self._sdp = None
        self._sm = None

    def __enter__(self):
        """Resets the IUT when starting a PTS test."""
@@ -119,6 +121,11 @@ class IUT:
            if not self._sdp:
                self._sdp = SDPProxy(grpc.insecure_channel(f'localhost:{self.port}'))
            return self._sdp.interact(test, interaction, description, pts_address)
        # Handles SM MMIs.
        if profile in ('SM'):
            if not self._sm:
                self._sm = SMProxy(grpc.insecure_channel(f'localhost:{self.port}'))
            return self._sm.interact(test, interaction, description, pts_address)

        # Handles unsupported profiles.
        code = format_proxy(profile, interaction, description)
+70 −0
Original line number 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.
"""SMP proxy module."""

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

from pandora.sm_grpc import SM
from pandora.host_grpc import Host

# The tests needs the MMI to accept pairing confirmation request.
NEEDS_PAIRING_CONFIRMATION = {
    "SM/CEN/EKS/BV-01-C",
    "SM/CEN/JW/BI-04-C",
    "SM/CEN/JW/BI-01-C",
}


class SMProxy(ProfileProxy):

    def __init__(self, channel):
        super().__init__()
        self.sm = SM(channel)
        self.host = Host(channel)
        self.connection = None

    @assert_description
    def MMI_IUT_ENABLE_CONNECTION_SM(self, pts_addr: bytes, **kwargs):
        """
        Initiate an connection from the IUT to the PTS.
        """
        self.connection = self.host.ConnectLE(address=pts_addr).connection
        return "OK"

    @assert_description
    def MMI_ASK_IUT_PERFORM_PAIRING_PROCESS(self, test, **kwargs):
        """
        Please start pairing process.
        """
        if self.connection:
            self.sm.Pair(connection=self.connection)
            if test in NEEDS_PAIRING_CONFIRMATION:
                self.sm.ProvidePairingConfirmation(connection=self.connection, pairing_confirmation_value=True)

            return "OK"

    @assert_description
    def MMI_IUT_SEND_DISCONNECTION_REQUEST(self, **kwargs):
        """
        Please initiate a disconnection to the PTS.

        Description: Verify that
        the Implementation Under Test(IUT) can initiate a disconnect request to
        PTS.
        """
        if self.connection:
            self.host.DisconnectLE(connection=self.connection)
            self.connection = None
            return "OK"
+3 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ genrule {
        "proto/pandora/a2dp.proto",
        "proto/pandora/hfp.proto",
        "proto/pandora/host.proto",
        "proto/pandora/sm.proto"
    ],
    out: [
        "pandora/a2dp_grpc.py",
@@ -109,5 +110,7 @@ genrule {
        "pandora/hfp_pb2.py",
        "pandora/host_grpc.py",
        "pandora/host_pb2.py",
        "pandora/sm_pb2.py",
        "pandora/sm_grpc.py",
    ]
}
+6 −0
Original line number Diff line number Diff line
@@ -24,6 +24,12 @@
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />


    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />

+2 −0
Original line number Diff line number Diff line
@@ -26,5 +26,7 @@
        <option name="profile" value="HFP/AG/HFI" />
        <option name="profile" value="HFP/AG/SLC" />
        <option name="profile" value="SDP/SR" />
        <option name="profile" value="SM/CEN/EKS" />
        <option name="profile" value="SM/CEN/JW" />
    </test>
</configuration>
Loading