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

Commit 28ee68c0 authored by Jack He's avatar Jack He
Browse files

Split L2CAP Classic and LE stacks into separate modules

* Although L2CAP LE and Classic stacks look similar, they are actually very different when diving into details
* Splitting them into two separate modules will benefit in the following ways:
 * One can start a LE only stack
 * One can turn off Classic stack entirely when not needed
 * Dependencies are more obvious, e.g. LE-CoC only depends on LE L2CAP and A2DP only depends on Classic L2CAP
* Changed test names as GTEST does not allow test name collisions
* New directory structure after the change:
  - l2cap: common headers that should be exposed to public
    - internal: common internal libraries shared between LE and classic
    - classic: classic headers that should be exposed to public
      - internal: internal libraries for classic
      - cert: certification stack for classic
   - le: LE headers that should be exposed to public
      - internal: internal libraries for LE
      - cert: certification stack for LE

Using Bash
 for file in classic_*; do git mv "$file" "classic/${file/classic_/}"; done
 for file in le_*; do git mv "$file" "le/${file/le_/}"; done
 for file in internal/le_*; do git mv "$file" "le/${file/le_/}"; done
 for file in internal/classic_*; do git mv "$file" "classic/${file/classic_/}"; done
 for file in classic/*; do if [ -f "$file" ]; then sed -i -e 's/Classic//g' "$file"; fi; done
 for file in classic/internal/*; do if [ -f "$file" ]; then sed -i -e 's/Classic//g' "$file"; fi; done
 for file in le/*; do if [ -f "$file" ]; then sed -i -e 's/Le//g' "$file"; fi; done
 for file in le/internal/*; do if [ -f "$file" ]; then sed -i -e 's/Le//g' "$file"; fi; done

Using IDE:
 replace "namespace l2cap {" with "namespace l2cap { namespace classic {" in classic/
 replace "}  // namespace l2cap" with "} }" in classic/
 replace "namespace l2cap {" with "namespace l2cap { namespace le {" in le/
 replace "}  // namespace l2cap" with "} }" in le/
 replace "l2cap/classic_" with "l2cap/classic/" in classic/
 replace "l2cap/internal/classic_" with "l2cap/classic/internal/" in classic/
 replace "l2cap/le_" with "l2cap/le/" in le/
 replace "l2cap/internal/le_" with "l2cap/le/internal/" in le/

Bug: 140938432
Test: bluetooth_test_gd
Change-Id: I29eafefc5b6be4033e5db811776230d28ca312b2
parent dc98c3b2
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ filegroup {
        "facade/rootservice.proto",
        "hal/facade.proto",
        "hci/facade.proto",
        "l2cap/facade.proto",
        "l2cap/classic/facade.proto",
    ],
}

@@ -349,8 +349,8 @@ genrule {
        "hal/facade.pb.h",
        "hci/facade.grpc.pb.h",
        "hci/facade.pb.h",
        "l2cap/facade.grpc.pb.h",
        "l2cap/facade.pb.h",
        "l2cap/classic/facade.grpc.pb.h",
        "l2cap/classic/facade.pb.h",
    ],
}

@@ -373,8 +373,8 @@ genrule {
        "hal/facade.pb.cc",
        "hci/facade.grpc.pb.cc",
        "hci/facade.pb.cc",
        "l2cap/facade.grpc.pb.cc",
        "l2cap/facade.pb.cc",
        "l2cap/classic/facade.grpc.pb.cc",
        "l2cap/classic/facade.pb.cc",
    ],
}

@@ -390,8 +390,8 @@ genrule {
        "touch $(genDir)/hal/cert/__init__.py; " +
        "touch $(genDir)/hci/__init__.py; " +
        "touch $(genDir)/hci/cert/__init__.py; " +
        "touch $(genDir)/l2cap/__init__.py; " +
        "touch $(genDir)/l2cap/cert/__init__.py; ",
        "touch $(genDir)/l2cap/classic/__init__.py; " +
        "touch $(genDir)/l2cap/classic/cert/__init__.py; ",
    srcs: [
        ":BluetoothFacadeProto",
        ":BluetoothCertStackProto",
@@ -410,18 +410,18 @@ genrule {
        "hci/__init__.py",
        "hci/facade_pb2_grpc.py",
        "hci/facade_pb2.py",
        "l2cap/__init__.py",
        "l2cap/facade_pb2_grpc.py",
        "l2cap/facade_pb2.py",
        "l2cap/classic/__init__.py",
        "l2cap/classic/facade_pb2_grpc.py",
        "l2cap/classic/facade_pb2.py",
        "hal/cert/__init__.py",
        "hal/cert/api_pb2_grpc.py",
        "hal/cert/api_pb2.py",
        "hci/cert/__init__.py",
        "hci/cert/api_pb2_grpc.py",
        "hci/cert/api_pb2.py",
        "l2cap/cert/__init__.py",
        "l2cap/cert/api_pb2_grpc.py",
        "l2cap/cert/api_pb2.py",
        "l2cap/classic/cert/__init__.py",
        "l2cap/classic/cert/api_pb2_grpc.py",
        "l2cap/classic/cert/api_pb2.py",
    ],
}

@@ -431,7 +431,7 @@ filegroup {
        "cert/rootservice.proto",
        "hal/cert/api.proto",
        "hci/cert/api.proto",
        "l2cap/cert/api.proto",
        "l2cap/classic/cert/api.proto",
    ],
}

@@ -455,8 +455,8 @@ genrule {
        "hal/cert/api.pb.h",
        "hci/cert/api.grpc.pb.h",
        "hci/cert/api.pb.h",
        "l2cap/cert/api.grpc.pb.h",
        "l2cap/cert/api.pb.h",
        "l2cap/classic/cert/api.grpc.pb.h",
        "l2cap/classic/cert/api.pb.h",
    ],
}

@@ -480,7 +480,7 @@ genrule {
        "hal/cert/api.pb.cc",
        "hci/cert/api.grpc.pb.cc",
        "hci/cert/api.pb.cc",
        "l2cap/cert/api.grpc.pb.cc",
        "l2cap/cert/api.pb.cc",
        "l2cap/classic/cert/api.grpc.pb.cc",
        "l2cap/classic/cert/api.pb.cc",
    ],
}
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ from cert.event_stream import EventStream
from cert import rootservice_pb2_grpc as cert_rootservice_pb2_grpc
from hal.cert import api_pb2_grpc as hal_cert_pb2_grpc
from hci.cert import api_pb2_grpc as hci_cert_pb2_grpc
from l2cap.cert import api_pb2_grpc as l2cap_cert_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"
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ from cert.event_stream import EventStream
from facade import rootservice_pb2_grpc as facade_rootservice_pb2_grpc
from hal import facade_pb2_grpc as hal_facade_pb2_grpc
from hci import facade_pb2_grpc as hci_facade_pb2_grpc
from l2cap import facade_pb2_grpc as l2cap_facade_pb2_grpc
from l2cap.classic import facade_pb2_grpc as l2cap_facade_pb2_grpc

ACTS_CONTROLLER_CONFIG_NAME = "GdDevice"
ACTS_CONTROLLER_REFERENCE_NAME = "gd_devices"
+2 −2
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#include "grpc/grpc_module.h"
#include "hal/cert/cert.h"
#include "hci/cert/cert.h"
#include "l2cap/cert/cert.h"
#include "l2cap/classic/cert/cert.h"
#include "os/log.h"
#include "os/thread.h"
#include "stack_manager.h"
@@ -59,7 +59,7 @@ class RootCertService : public ::bluetooth::cert::RootCert::Service {
        break;
      case BluetoothModule::L2CAP:
        modules.add<::bluetooth::cert::ReadOnlyPropertyServerModule>();
        modules.add<::bluetooth::l2cap::cert::L2capModuleCertModule>();
        modules.add<::bluetooth::l2cap::classic::cert::L2capModuleCertModule>();
        break;
      default:
        return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "invalid module under test");
+2 −2
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#include "grpc/grpc_module.h"
#include "hal/facade.h"
#include "hci/facade.h"
#include "l2cap/facade.h"
#include "l2cap/classic/facade.h"
#include "os/log.h"
#include "os/thread.h"
#include "stack_manager.h"
@@ -60,7 +60,7 @@ class RootFacadeService : public ::bluetooth::facade::RootFacade::Service {
        break;
      case BluetoothModule::L2CAP:
        modules.add<::bluetooth::facade::ReadOnlyPropertyServerModule>();
        modules.add<::bluetooth::l2cap::L2capModuleFacadeModule>();
        modules.add<::bluetooth::l2cap::classic::L2capModuleFacadeModule>();
        break;
      default:
        return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "invalid module under test");
Loading