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

Commit b7181888 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Remove C++ cert stack" am: 924b8ddf am: de45f31e am: 590567e5

Change-Id: I45589ceaf3c61b2ac288b9c63b4feb6e4d8df2de
parents 864f7d8c 590567e5
Loading
Loading
Loading
Loading
+0 −94
Original line number Original line Diff line number Diff line
@@ -174,48 +174,6 @@ cc_binary {
    },
    },
}
}


cc_binary {
    name: "bluetooth_cert_stack",
    defaults: [
        "gd_defaults",
    ],
    host_supported: true,
    srcs: [
        "cert/cert_main.cc",
        "cert/grpc_root_server.cc",
        "cert/read_only_property_server.cc",
        "grpc/grpc_module.cc",
        ":BluetoothCertSource_l2cap_layer",
    ],
    generated_headers: [
        "BluetoothGeneratedPackets_h",
        "BluetoothCertStackGeneratedStub_h",
    ],
    generated_sources: [
        "BluetoothCertStackGeneratedStub_cc",
    ],
    static_libs: [
        "libbluetooth_gd",
    ],
    shared_libs: [
        "libchrome",
        "libgrpc++_unsecure",
        "libprotobuf-cpp-full",
    ],
    target: {
        android: {
            shared_libs: [
                "android.hardware.bluetooth@1.0",
                "libhidlbase",
                "libutils",
            ],
        },
    },
    sanitize: {
        address: true,
    },
}

cc_test {
cc_test {
    name: "bluetooth_test_gd",
    name: "bluetooth_test_gd",
    test_suites: ["device-tests"],
    test_suites: ["device-tests"],
@@ -507,13 +465,11 @@ genrule {
        "touch $(genDir)/hci/__init__.py; " +
        "touch $(genDir)/hci/__init__.py; " +
        "touch $(genDir)/hci/facade/__init__.py; " +
        "touch $(genDir)/hci/facade/__init__.py; " +
        "touch $(genDir)/l2cap/classic/__init__.py; " +
        "touch $(genDir)/l2cap/classic/__init__.py; " +
        "touch $(genDir)/l2cap/classic/cert/__init__.py; " +
        "touch $(genDir)/neighbor/facade/__init__.py; " +
        "touch $(genDir)/neighbor/facade/__init__.py; " +
        "touch $(genDir)/security/__init__.py; " +
        "touch $(genDir)/security/__init__.py; " +
        "$(location soong_zip) -C $(genDir) -D $(genDir) -o $(out)",
        "$(location soong_zip) -C $(genDir) -D $(genDir) -o $(out)",
    srcs: [
    srcs: [
        ":BluetoothFacadeProto",
        ":BluetoothFacadeProto",
        ":BluetoothCertStackProto",
    ],
    ],
    out: ["bluetooth_cert_generated_py.zip"],
    out: ["bluetooth_cert_generated_py.zip"],
    dist: {
    dist: {
@@ -522,56 +478,6 @@ genrule {


}
}


filegroup {
    name: "BluetoothCertStackProto",
    srcs: [
        "cert/rootservice.proto",
        "l2cap/classic/cert/api.proto",
    ],
}

genrule {
    name: "BluetoothCertStackGeneratedStub_h",
    tools: [
        "aprotoc",
        "protoc-gen-grpc-cpp-plugin",
    ],
    cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system/gd -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)",
    srcs: [
        ":BluetoothCertStackProto",
        ":BluetoothFacadeProto", // we need to use facade/common.proto
    ],
    out: [
        "cert/rootservice.grpc.pb.h",
        "cert/rootservice.pb.h",
        "facade/common.grpc.pb.h",
        "facade/common.pb.h",
        "l2cap/classic/cert/api.grpc.pb.h",
        "l2cap/classic/cert/api.pb.h",
    ],
}

genrule {
    name: "BluetoothCertStackGeneratedStub_cc",
    tools: [
        "aprotoc",
        "protoc-gen-grpc-cpp-plugin",
    ],
    cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system/gd -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)",
    srcs: [
        ":BluetoothCertStackProto",
        ":BluetoothFacadeProto", // we need to use facade/common.proto
    ],
    out: [
        "cert/rootservice.grpc.pb.cc",
        "cert/rootservice.pb.cc",
        "facade/common.grpc.pb.cc",
        "facade/common.pb.cc",
        "l2cap/classic/cert/api.grpc.pb.cc",
        "l2cap/classic/cert/api.pb.cc",
    ],
}

cc_defaults {
cc_defaults {
  name: "bluetooth_py3_native_extension_defaults",
  name: "bluetooth_py3_native_extension_defaults",
  include_dirs: [
  include_dirs: [
+0 −2
Original line number Original line Diff line number Diff line
@@ -5,10 +5,8 @@ bluetooth_cert_test_file_list := \
    $(call all-named-files-under,*.sh,cert) \
    $(call all-named-files-under,*.sh,cert) \
    $(call all-named-files-under,*.proto,cert facade hal hci/cert hci/facade l2cap/classic \
    $(call all-named-files-under,*.proto,cert facade hal hci/cert hci/facade l2cap/classic \
	    l2cap/classic/cert neighbor/facade security) \
	    l2cap/classic/cert neighbor/facade security) \
    cert/cert_testcases \
    cert/cert_testcases_facade_only \
    cert/cert_testcases_facade_only \
    cert/android_devices_config.json \
    cert/android_devices_config.json \
    cert/host_only_config.json \
    cert/host_only_config_facade_only.json \
    cert/host_only_config_facade_only.json \
    hal/cert/simple_hal_test.py \
    hal/cert/simple_hal_test.py \
    hci/cert/acl_manager_test.py \
    hci/cert/acl_manager_test.py \

system/gd/cert/cert_main.cc

deleted100644 → 0
+0 −94
Original line number Original line Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * 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
 *
 *      http://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.
 */

#include "stack_manager.h"

#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <csignal>
#include <cstring>
#include <string>
#include <thread>

#include "cert/grpc_root_server.h"
#include "hal/hci_hal_host_rootcanal.h"
#include "hal/snoop_logger.h"

using ::bluetooth::Module;
using ::bluetooth::ModuleList;
using ::bluetooth::StackManager;
using ::bluetooth::os::Thread;

namespace {
::bluetooth::cert::GrpcRootServer grpc_root_server;

void interrupt_handler(int) {
  grpc_root_server.StopServer();
}
}  // namespace

int main(int argc, const char** argv) {
  int root_server_port = 8896;
  int grpc_port = 8898;
  int signal_port = 8894;

  const std::string arg_grpc_root_server_port = "--root-server-port=";
  const std::string arg_grpc_server_port = "--grpc-port=";
  const std::string arg_rootcanal_port = "--rootcanal-port=";
  const std::string arg_signal_port = "--signal-port=";
  const std::string arg_btsnoop_path = "--btsnoop=";
  std::string btsnoop_path;
  for (int i = 1; i < argc; i++) {
    std::string arg = argv[i];
    if (arg.find(arg_grpc_root_server_port) == 0) {
      auto port_number = arg.substr(arg_grpc_root_server_port.size());
      root_server_port = std::stoi(port_number);
    }
    if (arg.find(arg_grpc_server_port) == 0) {
      auto port_number = arg.substr(arg_grpc_server_port.size());
      grpc_port = std::stoi(port_number);
    }
    if (arg.find(arg_rootcanal_port) == 0) {
      auto port_number = arg.substr(arg_rootcanal_port.size());
      ::bluetooth::hal::HciHalHostRootcanalConfig::Get()->SetPort(std::stoi(port_number));
    }
    if (arg.find(arg_btsnoop_path) == 0) {
      btsnoop_path = arg.substr(arg_btsnoop_path.size());
      ::bluetooth::hal::SnoopLogger::SetFilePath(btsnoop_path);
    }
    if (arg.find(arg_signal_port) == 0) {
      auto port_number = arg.substr(arg_signal_port.size());
      signal_port = std::stoi(port_number);
    }
  }

  signal(SIGINT, interrupt_handler);
  grpc_root_server.StartServer("0.0.0.0", root_server_port, grpc_port);
  int tester_signal_socket = socket(AF_INET, SOCK_STREAM, 0);
  struct sockaddr_in addr;
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_port = htons(signal_port);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  connect(tester_signal_socket, (sockaddr*)&addr, sizeof(addr));
  close(tester_signal_socket);
  auto wait_thread = std::thread([] { grpc_root_server.RunGrpcLoop(); });
  wait_thread.join();

  return 0;
}

system/gd/cert/cert_testcases

deleted100644 → 0
+0 −1
Original line number Original line Diff line number Diff line
SimpleL2capTest

system/gd/cert/gd_cert_device.py

deleted100644 → 0
+0 −72
Original line number Original line Diff line number Diff line
#!/usr/bin/env python3
#
#   Copyright 2019 - The Android Open Source Project
#
#   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
#
#       http://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.

from cert.gd_device_base import GdDeviceBase, GdDeviceConfigError, replace_vars
import cert.rootservice_pb2_grpc as cert_rootservice_pb2_grpc
from l2cap.classic.cert import api_pb2_grpc as l2cap_cert_pb2_grpc

ACTS_CONTROLLER_CONFIG_NAME = "GdCertDevice"
ACTS_CONTROLLER_REFERENCE_NAME = "gd_cert_devices"


def create(configs):
    if not configs:
        raise GdDeviceConfigError("Configuration is empty")
    elif not isinstance(configs, list):
        raise GdDeviceConfigError("Configuration should be a list")
    return get_instances_with_configs(configs)


def destroy(devices):
    for device in devices:
        try:
            device.clean_up()
        except:
            device.log.exception("Failed to clean up properly.")


def get_info(devices):
    return []


def get_instances_with_configs(configs):
    print(configs)
    devices = []
    for config in configs:
        resolved_cmd = []
        for entry in config["cmd"]:
            resolved_cmd.append(replace_vars(entry, config))
        devices.append(
            GdCertDevice(config["grpc_port"], config["grpc_root_server_port"],
                         config["signal_port"], resolved_cmd, config["label"],
                         config.get("serial_number", "")))
    return devices


class GdCertDevice(GdDeviceBase):

    def __init__(self, grpc_port, grpc_root_server_port, signal_port, cmd,
                 label, serial_number):
        super().__init__(grpc_port, grpc_root_server_port, signal_port, cmd,
                         label, ACTS_CONTROLLER_CONFIG_NAME, serial_number)

        # Cert stubs
        self.rootservice = cert_rootservice_pb2_grpc.RootCertStub(
            self.grpc_root_server_channel)
        self.controller_read_only_property = cert_rootservice_pb2_grpc.ReadOnlyPropertyStub(
            self.grpc_channel)
        self.l2cap = l2cap_cert_pb2_grpc.L2capClassicModuleCertStub(
            self.grpc_channel)
Loading