Skip to content

Commit

Permalink
Sync with aosp/main
Browse files Browse the repository at this point in the history
Synchronized to packages/modules/Bluetooth
commit 62a71c25ab79ef9b854ef4e1c5b71f98f0f74966
  • Loading branch information
hchataing committed Dec 22, 2023
1 parent 00768c2 commit 3fa658e
Show file tree
Hide file tree
Showing 68 changed files with 1,500 additions and 332 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/avatar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
python -m pip install pandora-avatar
- name: Rootcanal
run: |
cargo install pdl-compiler --version 0.2.0
cargo install pdl-compiler --version 0.2.2
bazel build :rootcanal
- name: Test
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Install dependencies
run: |
cargo install pdl-compiler --version 0.2.0
cargo install pdl-compiler --version 0.2.2
- name: Build
run: |
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Install dependencies
run: |
cargo install pdl-compiler --version 0.2.0
cargo install pdl-compiler --version 0.2.2
python3 -m pip install hatch
- name: Set VERSION
Expand Down
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ cc_library(
"model/controller/sco_connection.cc",
"model/controller/sco_connection.h",
"model/controller/vendor_commands/csr.h",
"model/controller/vendor_commands/le_apcf.cc",
"model/controller/vendor_commands/le_apcf.h",
"model/devices/baseband_sniffer.cc",
"model/devices/baseband_sniffer.h",
"model/devices/beacon.cc",
Expand Down
2 changes: 0 additions & 2 deletions third_party/BUILD.fmtlib → BUILD.fmtlib
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ cc_library(
"include/fmt/compile.h",
"include/fmt/core.h",
"include/fmt/format.h",
"include/fmt/locale.h",
"include/fmt/os.h",
"include/fmt/ostream.h",
"include/fmt/posix.h",
"include/fmt/printf.h",
"include/fmt/ranges.h",
],
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
new_local_repository(
name = "fmtlib",
path = "third_party/fmtlib",
build_file = "third_party/BUILD.fmtlib",
build_file = "//:BUILD.fmtlib",
)

git_repository(
name = "boringssl",
# branch master-with-bazel
commit = "4280d451e661db0c4d800f2c5219f3f4701c7cd0",
commit = "3d72f682f72f232328055746c9878307e0d7a066",
remote = "https://boringssl.googlesource.com/boringssl",
)

Expand All @@ -26,7 +26,7 @@ local_repository(
new_local_repository(
name = "pdl",
path = "third_party/pdl",
build_file = "third_party/BUILD.pdl",
build_file = "//:BUILD.pdl",
)

http_archive(
Expand Down
36 changes: 25 additions & 11 deletions desktop/test_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,36 @@
// limitations under the License.
//

#include "test_environment.h"
#include "desktop/test_environment.h"

#include <google/protobuf/text_format.h>

#include <filesystem> // for exists
#include <type_traits> // for remove_extent_t
#include <utility> // for move
#include <vector> // for vector

#include <chrono>
#include <filesystem>
#include <fstream>
#include <functional>
#include <future>
#include <ios>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "hci/pcap_filter.h"
#include "log.h"
#include "model/controller/controller_properties.h"
#include "model/devices/baseband_sniffer.h"
#include "model/devices/link_layer_socket_device.h" // for LinkLayerSocketDevice
#include "model/hci/hci_sniffer.h" // for HciSniffer
#include "model/hci/hci_socket_transport.h" // for HciSocketTransport
#include "net/async_data_channel.h" // for AsyncDataChannel
#include "net/async_data_channel_connector.h" // for AsyncDataChannelConnector
#include "model/devices/device.h"
#include "model/devices/hci_device.h"
#include "model/devices/link_layer_socket_device.h"
#include "model/hci/hci_sniffer.h"
#include "model/hci/hci_socket_transport.h"
#include "model/setup/async_manager.h"
#include "model/setup/test_channel_transport.h"
#include "net/async_data_channel.h"
#include "net/async_data_channel_connector.h"
#include "phy.h"
#include "rootcanal/configuration.pb.h"

namespace rootcanal {

Expand Down
24 changes: 13 additions & 11 deletions desktop/test_environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@

#pragma once

#include <chrono> // for milliseconds
#include <functional> // for __base, function
#include <future> // for promise
#include <memory> // for shared_ptr, make_...
#include <string> // for string

#include "model/setup/async_manager.h" // for AsyncTaskId, Asyn...
#include "model/setup/test_channel_transport.h" // for TestChannelTransport
#include "model/setup/test_command_handler.h" // for TestCommandHandler
#include "model/setup/test_model.h" // for TestModel
#include "net/async_data_channel_server.h" // for AsyncDataChannelS...
#include <chrono>
#include <functional>
#include <future>
#include <memory>
#include <string>
#include <vector>

#include "model/controller/controller_properties.h"
#include "model/setup/async_manager.h"
#include "model/setup/test_channel_transport.h"
#include "model/setup/test_command_handler.h"
#include "model/setup/test_model.h"
#include "net/async_data_channel_server.h"

namespace android::net {
class AsyncDataChannel;
Expand Down
49 changes: 45 additions & 4 deletions include/hci/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@

#pragma once

#include <fmt/core.h>
#include <packet_runtime.h>

#include <array>
#include <cstdint>
#include <cstring>
#include <functional>
#include <initializer_list>
#include <optional>
#include <ostream>
#include <string>
#include <vector>

namespace bluetooth {
namespace hci {
namespace bluetooth::hci {

class Address final : public pdl::packet::Builder {
public:
Expand Down Expand Up @@ -88,8 +90,7 @@ inline std::ostream& operator<<(std::ostream& os, const Address& a) {
return os;
}

} // namespace hci
} // namespace bluetooth
} // namespace bluetooth::hci

namespace std {
template <>
Expand All @@ -104,3 +105,43 @@ struct hash<bluetooth::hci::Address> {
}
};
} // namespace std

template <>
struct fmt::formatter<bluetooth::hci::Address> {
// Presentation format: 'x' - lowercase, 'X' - uppercase.
char presentation = 'x';

// Parses format specifications of the form ['x' | 'X'].
constexpr auto parse(format_parse_context& ctx)
-> format_parse_context::iterator {
// Parse the presentation format and store it in the formatter:
auto it = ctx.begin();
auto end = ctx.end();
if (it != end && (*it == 'x' || *it == 'X')) {
presentation = *it++;
}

// Check if reached the end of the range:
if (it != end && *it != '}') {
throw_format_error("invalid format");
}

// Return an iterator past the end of the parsed range:
return it;
}

// Formats the address a using the parsed format specification (presentation)
// stored in this formatter.
auto format(const bluetooth::hci::Address& a, format_context& ctx) const
-> format_context::iterator {
return presentation == 'x'
? fmt::format_to(ctx.out(),
"{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
a.address[5], a.address[4], a.address[3],
a.address[2], a.address[1], a.address[0])
: fmt::format_to(ctx.out(),
"{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}",
a.address[5], a.address[4], a.address[3],
a.address[2], a.address[1], a.address[0]);
}
};
48 changes: 44 additions & 4 deletions include/hci/address_with_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

#pragma once

#include <fmt/core.h>

#include <cstddef>
#include <cstdint>
#include <cstring>
#include <functional>
#include <ostream>
#include <sstream>
#include <string>
#include <utility>
Expand All @@ -24,8 +31,7 @@
#include "hci/address.h"
#include "packets/hci_packets.h"

namespace bluetooth {
namespace hci {
namespace bluetooth::hci {

class AddressWithType final {
public:
Expand Down Expand Up @@ -118,8 +124,7 @@ inline std::ostream& operator<<(std::ostream& os, const AddressWithType& a) {
return os;
}

} // namespace hci
} // namespace bluetooth
} // namespace bluetooth::hci

namespace std {
template <>
Expand All @@ -134,3 +139,38 @@ struct hash<bluetooth::hci::AddressWithType> {
}
};
} // namespace std

template <>
struct fmt::formatter<bluetooth::hci::AddressWithType> {
// Presentation format: 'x' - lowercase, 'X' - uppercase.
char presentation = 'x';

// Parses format specifications of the form ['x' | 'X'].
constexpr auto parse(format_parse_context& ctx)
-> format_parse_context::iterator {
// Parse the presentation format and store it in the formatter:
auto it = ctx.begin();
auto end = ctx.end();
if (it != end && (*it == 'x' || *it == 'X')) {
presentation = *it++;
}

// Check if reached the end of the range:
if (it != end && *it != '}') {
throw_format_error("invalid format");
}

// Return an iterator past the end of the parsed range:
return it;
}

// Formats the address a using the parsed format specification (presentation)
// stored in this formatter.
auto format(const bluetooth::hci::AddressWithType& a,
format_context& ctx) const -> format_context::iterator {
auto out = presentation == 'x'
? fmt::format_to(ctx.out(), "{:x}", a.GetAddress())
: fmt::format_to(ctx.out(), "{:X}", a.GetAddress());
return fmt::format_to(out, "[{}]", AddressTypeText(a.GetAddressType()));
}
};
6 changes: 5 additions & 1 deletion include/hci/pcap_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

#pragma once

#include <unordered_map>
#include <array>
#include <cstddef>
#include <cstdint>
#include <utility>
#include <vector>

#include "packets/hci_packets.h"

Expand Down
1 change: 1 addition & 0 deletions include/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#pragma once

#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/printf.h>

Expand Down
1 change: 1 addition & 0 deletions include/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ class Phy {
BR_EDR,
};
};

} // namespace rootcanal
1 change: 0 additions & 1 deletion lib/crypto/crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <openssl/aes.h>

#include <algorithm>
#include <cstdint>

namespace rootcanal::crypto {

Expand Down
Loading

0 comments on commit 3fa658e

Please sign in to comment.