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

Commit 7bc067f9 authored by Rahul Arya's avatar Rahul Arya Committed by Gerrit Code Review
Browse files

Merge changes I58bd8e1c,I07533027

* changes:
  [Pandora] GAP MMIs
  [Pandora] Add logging to mmi2grpc
parents 10ee32c0 dd9dd9ed
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import grpc
from mmi2grpc.a2dp import A2DPProxy
from mmi2grpc.avrcp import AVRCPProxy
from mmi2grpc.gatt import GATTProxy
from mmi2grpc.gap import GAPProxy
from mmi2grpc.hfp import HFPProxy
from mmi2grpc.hid import HIDProxy
from mmi2grpc.hogp import HOGPProxy
@@ -65,6 +66,7 @@ class IUT:
        self._a2dp = None
        self._avrcp = None
        self._gatt = None
        self._gap = None
        self._hfp = None
        self._hid = None
        self._hogp = None
@@ -89,6 +91,7 @@ class IUT:
        self._a2dp = None
        self._avrcp = None
        self._gatt = None
        self._gap = None
        self._hfp = None
        self._l2cap = None
        self._hid = None
@@ -164,6 +167,11 @@ class IUT:
            if not self._gatt:
                self._gatt = GATTProxy(grpc.insecure_channel(f'localhost:{self.pandora_server_port}'))
            return self._gatt.interact(test, interaction, description, pts_address)
        # Handles GAP MMIs.
        if profile in ('GAP'):
            if not self._gap:
                self._gap = GAPProxy(grpc.insecure_channel(f'localhost:{self.pandora_server_port}'))
            return self._gap.interact(test, interaction, description, pts_address)
        # Handles HFP MMIs.
        if profile in ('HFP'):
            if not self._hfp:
+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ def format_proxy(profile, mmi_name, mmi_description):
            f'class {profile}Proxy(ProfileProxy):\n'
            f'\n'
            f'    def __init__(self, channel):\n'
            f'        super().__init__()\n'
            f'        super().__init__(channel)\n'
            f'        self.{profile.lower()} = {profile}(channel)\n'
            f'\n'
            f'{wrapped_function}')
+12 −3
Original line number Diff line number Diff line
@@ -16,12 +16,15 @@
from mmi2grpc._helpers import format_function
from mmi2grpc._helpers import assert_description

import sys
from pandora_experimental._android_grpc import Android


class ProfileProxy:
    """Profile proxy base class."""

    def __init__(self, channel) -> None:
        self._android = Android(channel)

    def interact(self, test: str, mmi_name: str, mmi_description: str, pts_addr: bytes):
        """Translate a MMI call to its corresponding implementation.

@@ -37,10 +40,16 @@ class ProfileProxy:
        try:
            if not mmi_name.isidentifier():
                mmi_name = "_mmi_" + mmi_name
            return getattr(self, mmi_name)(test=test, description=mmi_description, pts_addr=pts_addr)
            self.log(f"starting MMI {mmi_name}")
            out = getattr(self, mmi_name)(test=test, description=mmi_description, pts_addr=pts_addr)
            self.log(f"finishing MMI {mmi_name}")
            return out
        except AttributeError:
            code = format_function(mmi_name, mmi_description)
            assert False, f'Unhandled mmi {id}\n{code}'
            assert False, f'Unhandled mmi {mmi_name}\n{code}'

    def log(self, text=""):
        self._android.Log(text=text)

    def test_started(self, test: str, description: str, pts_addr: bytes):
        return "OK"
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ class A2DPProxy(ProfileProxy):
    source: Optional[Source] = None

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

        self.host = Host(channel)
        self.a2dp = A2DP(channel)
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ class AVRCPProxy(ProfileProxy):
    source: Optional[Source] = None

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

        self.host = Host(channel)
        self.a2dp = A2DP(channel)
Loading