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

Commit e5c92d52 authored by Charlie Boutier's avatar Charlie Boutier
Browse files

BumbleBluetoothTest: remove click dependency

This allow the following import into g3:
```
from src import register_experimental_services
```
Test: atest BumbleBluetoothTests
Bug: 342195977

Change-Id: I2e471ef2ff87343c954000721d741749a3cfcda0
parent bf3d929c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
    <target_preparer class="com.android.tradefed.targetprep.PythonVirtualenvPreparer">
        <option name="dep-module" value="grpcio==1.51.1" />
        <option name="dep-module" value="cryptography==35" />
        <option name="dep-module" value="click" />
    </target_preparer>

    <target_preparer class="com.android.tradefed.targetprep.RunHostCommandTargetPreparer">
+19 −16
Original line number Diff line number Diff line
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import asyncio
import click
import logging
import json

@@ -34,20 +34,8 @@ BUMBLE_SERVER_GRPC_PORT = 7999
ROOTCANAL_PORT_CUTTLEFISH = 7300


@click.command()
@click.option('--grpc-port', help='gRPC port to serve', default=BUMBLE_SERVER_GRPC_PORT)
@click.option('--rootcanal-port', help='Rootcanal TCP port', default=ROOTCANAL_PORT_CUTTLEFISH)
@click.option(
    '--transport',
    help='HCI transport',
    default=f'tcp-client:127.0.0.1:<rootcanal-port>',
)
@click.option(
    '--config',
    help='Bumble json configuration file',
)
def main(grpc_port: int, rootcanal_port: int, transport: str, config: str) -> None:
    register_bumble_services()
    register_experimental_services()
    if '<rootcanal-port>' in transport:
        transport = transport.replace('<rootcanal-port>', str(rootcanal_port))

@@ -64,7 +52,21 @@ def main(grpc_port: int, rootcanal_port: int, transport: str, config: str) -> No
    asyncio.run(serve(device, config=server_config, port=grpc_port))


def register_bumble_services():
def args_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(description="Bumble command-line tool")

    parser.add_argument('--grpc-port', type=int, default=BUMBLE_SERVER_GRPC_PORT, help='gRPC port to serve')
    parser.add_argument('--rootcanal-port', type=int, default=ROOTCANAL_PORT_CUTTLEFISH, help='Rootcanal TCP port')
    parser.add_argument('--transport',
                        type=str,
                        default='tcp-client:127.0.0.1:<rootcanal-port>',
                        help='HCI transport (default: tcp-client:127.0.0.1:<rootcanal-port>)')
    parser.add_argument('--config', type=str, help='Bumble json configuration file')

    return parser


def register_experimental_services():
    bumble_server.register_servicer_hook(
        lambda bumble, _, server: add_AshaServicer_to_server(AshaService(bumble.device), server))
    bumble_server.register_servicer_hook(
@@ -82,4 +84,5 @@ def retrieve_config(config: str) -> Dict[str, Any]:


if __name__ == '__main__':
    main()  # pylint: disable=no-value-for-parameter
    args = args_parser().parse_args()
    main(**vars(args))