diff options
author | uael <uael@google.com> | 2023-03-31 05:04:35 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-31 05:04:35 +0000 |
commit | 4fc0c5a969e7c50732d908a77ba6e0ed71c28f58 (patch) | |
tree | 159b057396bd4080d67276a27aca60da708bf1b2 | |
parent | 895e9e614e888557204d81fb9e26ba4399e3bd07 (diff) | |
parent | 518f36cbc6735deaea6ea343afd565f117ad4891 (diff) | |
download | avatar-4fc0c5a969e7c50732d908a77ba6e0ed71c28f58.tar.gz |
Merge remote-tracking branch 'aosp/upstream-main' into master am: 09c614d849 am: a991240fb1 am: c749cc1956 am: 518f36cbc6android-14.0.0_r45android-14.0.0_r44android-14.0.0_r43android-14.0.0_r42android-14.0.0_r41android-14.0.0_r40android-14.0.0_r39android-14.0.0_r38android-14.0.0_r27android-14.0.0_r26android-14.0.0_r25android-14.0.0_r24android-14.0.0_r23android-14.0.0_r22android-14.0.0_r21android-14.0.0_r20android-14.0.0_r19android-14.0.0_r18android-14.0.0_r17android-14.0.0_r16android14-qpr1-s2-releaseandroid14-qpr1-releaseandroid14-d2-s5-releaseandroid14-d2-s4-releaseandroid14-d2-s3-releaseandroid14-d2-s2-releaseandroid14-d2-s1-releaseandroid14-d2-release
Original change: https://android-review.googlesource.com/c/platform/external/pandora/avatar/+/2516217
Change-Id: Icaa8f8dd916441f67c0f9af1365589ba9590cdba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | avatar/bumble_server/__init__.py | 3 | ||||
-rw-r--r-- | avatar/bumble_server/asha.py | 66 | ||||
-rw-r--r-- | avatar/bumble_server/security.py | 2 | ||||
-rw-r--r-- | avatar/pandora_client.py | 12 |
4 files changed, 2 insertions, 81 deletions
diff --git a/avatar/bumble_server/__init__.py b/avatar/bumble_server/__init__.py index a50b8d6..184968f 100644 --- a/avatar/bumble_server/__init__.py +++ b/avatar/bumble_server/__init__.py @@ -22,11 +22,9 @@ import grpc.aio import logging from avatar.bumble_device import BumbleDevice -from avatar.bumble_server.asha import AshaService from avatar.bumble_server.host import HostService from avatar.bumble_server.security import SecurityService, SecurityStorageService from bumble.smp import PairingDelegate -from pandora.asha_grpc_aio import add_AshaServicer_to_server from pandora.host_grpc_aio import add_HostServicer_to_server from pandora.security_grpc_aio import add_SecurityServicer_to_server, add_SecurityStorageServicer_to_server from typing import Callable, List, Optional @@ -54,7 +52,6 @@ async def serve_bumble(bumble: BumbleDevice, grpc_server: Optional[grpc.aio.Serv add_HostServicer_to_server(HostService(server, bumble.device), server) add_SecurityServicer_to_server(SecurityService(bumble.device, io_capability), server) add_SecurityStorageServicer_to_server(SecurityStorageService(bumble.device), server) - add_AshaServicer_to_server(AshaService(bumble.device), server) # call hooks if any. for hook in _SERVICERS_HOOKS: diff --git a/avatar/bumble_server/asha.py b/avatar/bumble_server/asha.py deleted file mode 100644 index 42448a8..0000000 --- a/avatar/bumble_server/asha.py +++ /dev/null @@ -1,66 +0,0 @@ -# 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. - -import asyncio -import grpc -import logging - -from . import utils -from bumble.device import Device, Connection as BumbleConnection -from bumble.profiles.asha_service import AshaService as BumbleAshaService -from google.protobuf.empty_pb2 import Empty # pytype: disable=pyi-error -from pandora.asha_grpc_aio import AshaServicer -from pandora.asha_pb2 import RegisterRequest, CaptureAudioResponse -from typing import AsyncGenerator, Optional - - -class AshaService(AshaServicer): - device: Device - asha_service: Optional[BumbleAshaService] - - def __init__(self, device: Device) -> None: - self.log = utils.BumbleServerLoggerAdapter(logging.getLogger(), {'service_name': 'Asha', 'device': device}) - self.device = device - self.asha_service = None - - @utils.rpc - async def Register(self, request: RegisterRequest, context: grpc.ServicerContext) -> Empty: - self.log.info('Register') - # asha service from bumble profile - self.asha_service = BumbleAshaService(request.capability, request.hisyncid, self.device) - self.device.add_service(self.asha_service) # type: ignore[no-untyped-call] - return Empty() - - @utils.rpc - async def CaptureAudio(self, request, context) -> AsyncGenerator[CaptureAudioResponse, None]: - connection_handle = int.from_bytes(request.connection.cookie.value, 'big') - logging.info(f'CaptureAudioData connection_handle:{connection_handle}') - - if not (connection := self.device.lookup_connection(connection_handle)): - raise RuntimeError(f"Unknown connection for connection_handle:{connection_handle}") - - queue: asyncio.Queue[bytes] = asyncio.Queue() - - def on_data(asha_connection: BumbleConnection, data: bytes): - if asha_connection == connection: - queue.put_nowait(data) - - self.asha_service.on('data', on_data) - - try: - while data := await queue.get(): - yield CaptureAudioResponse(data=data) - finally: - self.asha_service.remove_listener('data', on_data) - queue = asyncio.Queue() diff --git a/avatar/bumble_server/security.py b/avatar/bumble_server/security.py index 70ca978..000d49f 100644 --- a/avatar/bumble_server/security.py +++ b/avatar/bumble_server/security.py @@ -121,7 +121,7 @@ class PairingDelegate(BasePairingDelegate): assert answer.answer_variant() == 'passkey' return answer.passkey - async def get_string(self, max_length) -> Optional[str]: + async def get_string(self, max_length: int) -> Optional[str]: self.log.info(f"Pairing event: `pin_code_request` (io_capability: {self.io_capability})") if self.service.event_queue is None or self.service.event_answer is None: diff --git a/avatar/pandora_client.py b/avatar/pandora_client.py index f828d4f..548e6d1 100644 --- a/avatar/pandora_client.py +++ b/avatar/pandora_client.py @@ -26,7 +26,7 @@ import logging from avatar.bumble_device import BumbleDevice from bumble.hci import Address as BumbleAddress from dataclasses import dataclass -from pandora import asha_grpc, asha_grpc_aio, host_grpc, host_grpc_aio, security_grpc, security_grpc_aio +from pandora import host_grpc, host_grpc_aio, security_grpc, security_grpc_aio from typing import Any, Dict, MutableMapping, Optional, Tuple, Union @@ -144,11 +144,6 @@ class PandoraClient: """Returns the Pandora SecurityStorage gRPC interface.""" return security_grpc.SecurityStorage(self.channel) - @property - def asha(self) -> asha_grpc.Asha: - """Returns the Pandora ASHA gRPC interface.""" - return asha_grpc.Asha(self.channel) - @dataclass class Aio: channel: grpc.aio.Channel @@ -168,11 +163,6 @@ class PandoraClient: """Returns the Pandora SecurityStorage gRPC interface.""" return security_grpc_aio.SecurityStorage(self.channel) - @property - def asha(self) -> asha_grpc_aio.Asha: - """Returns the Pandora ASHA gRPC interface.""" - return asha_grpc_aio.Asha(self.channel) - @property def aio(self) -> 'PandoraClient.Aio': if not self._aio: |