RootCanal: Remove libbt-rootcanal-packets and include/hci/
Bug: 140386699
Test: run_cert.sh
Change-Id: I50266b05ccf9e0775f1fecad2057b992a9ab8264
diff --git a/vendor_libs/test_vendor_lib/Android.bp b/vendor_libs/test_vendor_lib/Android.bp
index 7d20b25..16662c2 100644
--- a/vendor_libs/test_vendor_lib/Android.bp
+++ b/vendor_libs/test_vendor_lib/Android.bp
@@ -61,9 +61,6 @@
"libbase",
"liblog",
],
- whole_static_libs: [
- "libbt-rootcanal-packets",
- ],
static_libs: [
"libbt-rootcanal-types",
],
diff --git a/vendor_libs/test_vendor_lib/include/hci.h b/vendor_libs/test_vendor_lib/include/hci.h
index a2e696b..eaa74c0 100644
--- a/vendor_libs/test_vendor_lib/include/hci.h
+++ b/vendor_libs/test_vendor_lib/include/hci.h
@@ -17,11 +17,6 @@
#pragma once
#include <cstdint>
-#include "include/hci/event_code.h"
-#include "include/hci/le_sub_event_code.h"
-#include "include/hci/op_code.h"
-#include "include/hci/status.h"
-
namespace test_vendor_lib {
namespace hci {
@@ -33,36 +28,5 @@
EVENT = 4,
};
-enum class LinkType : uint8_t {
- SCO = 0x00,
- ACL = 0x01,
- ESCO = 0x02,
-};
-
-enum class LoopbackMode : uint8_t {
- NO = 0x00,
- LOCAL = 0x01,
- REMOTE = 0x02,
-};
-
-/* HCI, PAL, and LMP Version numbers are the same */
-enum class Version : uint8_t {
- V1_0 = 0,
- V1_1 = 1,
- V1_2 = 2,
- V2_0 = 3,
- V2_1 = 4,
- V3_0 = 5,
- V4_0 = 6,
- V4_1 = 7,
- V4_2 = 8,
- V5_0 = 9,
-};
-
-enum class Role : uint8_t {
- MASTER = 0x00,
- SLAVE = 0x01,
-};
-
} // namespace hci
} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/include/hci/event_code.h b/vendor_libs/test_vendor_lib/include/hci/event_code.h
deleted file mode 100644
index 306e522..0000000
--- a/vendor_libs/test_vendor_lib/include/hci/event_code.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-#include <cstdint>
-
-namespace test_vendor_lib {
-namespace hci {
-
-enum class EventCode : uint8_t {
- INQUIRY_COMPLETE = 0x01,
- INQUIRY_RESULT = 0x02,
- CONNECTION_COMPLETE = 0x03,
- CONNECTION_REQUEST = 0x04,
- DISCONNECTION_COMPLETE = 0x05,
- AUTHENTICATION_COMPLETE = 0x06,
- REMOTE_NAME_REQUEST_COMPLETE = 0x07,
- ENCRYPTION_CHANGE = 0x08,
- CHANGE_CONNECTION_LINK_KEY_COMPLETE = 0x09,
- MASTER_LINK_KEY_COMPLETE = 0x0A,
- READ_REMOTE_SUPPORTED_FEATURES_COMPLETE = 0x0B,
- READ_REMOTE_VERSION_INFORMATION_COMPLETE = 0x0C,
- QOS_SETUP_COMPLETE = 0x0D,
- COMMAND_COMPLETE = 0x0E,
- COMMAND_STATUS = 0x0F,
- HARDWARE_ERROR = 0x10,
- FLUSH_OCCURED = 0x11,
- ROLE_CHANGE = 0x12,
- NUMBER_OF_COMPLETED_PACKETS = 0x13,
- MODE_CHANGE = 0x14,
- RETURN_LINK_KEYS = 0x15,
- PIN_CODE_REQUEST = 0x16,
- LINK_KEY_REQUEST = 0x17,
- LINK_KEY_NOTIFICATION = 0x18,
- LOOPBACK_COMMAND = 0x19,
- DATA_BUFFER_OVERFLOW = 0x1A,
- MAX_SLOTS_CHANGE = 0x1B,
- READ_CLOCK_OFFSET_COMPLETE = 0x1C,
- CONNECTION_PACKET_TYPE_CHANGED = 0x1D,
- QOS_VIOLATION = 0x1E,
- PAGE_SCAN_REPETITION_MODE_CHANGE = 0x20,
- FLOW_SPECIFICATION_COMPLETE = 0x21,
- INQUIRY_RESULT_WITH_RSSI = 0x22,
- READ_REMOTE_EXTENDED_FEATURES_COMPLETE = 0x23,
- SYNCHRONOUS_CONNECTION_COMPLETE = 0x2C,
- SYNCHRONOUS_CONNECTION_CHANGED = 0x2D,
- SNIFF_SUBRATING = 0x2E,
- EXTENDED_INQUIRY_RESULT = 0x2F,
- ENCRYPTION_KEY_REFRESH_COMPLETE = 0x30,
- IO_CAPABILITY_REQUEST = 0x31,
- IO_CAPABILITY_RESPONSE = 0x32,
- USER_CONFIRMATION_REQUEST = 0x33,
- USER_PASSKEY_REQUEST = 0x34,
- REMOTE_OOB_DATA_REQUEST = 0x35,
- SIMPLE_PAIRING_COMPLETE = 0x36,
- LINK_SUPERVISION_TIMEOUT_CHANGED = 0x38,
- ENHANCED_FLUSH_COMPLETE = 0x39,
- USER_PASSKEY_NOTIFICATION = 0x3B,
- KEYPRESS_NOTIFICATION = 0x3C,
- REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION = 0x3D,
- LE_META_EVENT = 0x3e,
- PHYSICAL_LINK_COMPLETE = 0x40,
- CHANNEL_SELECTED = 0x41,
- DISCONNECTION_PHYSICAL_LINK_COMPLETE = 0x42,
- PHYSICAL_LINK_LOSS_EARLY_WARNING = 0x43,
- PHYSICAL_LINK_RECOVERY = 0x44,
- LOGICAL_LINK_COMPLETE = 0x45,
- DISCONNECTION_LOGICAL_LINK_COMPLETE = 0x46,
- FLOW_SPEC_MODIFY_COMPLETE = 0x47,
- NUMBER_OF_COMPLETED_DATA_BLOCKS = 0x48,
- SHORT_RANGE_MODE_CHANGE_COMPLETE = 0x4C,
-};
-}
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/include/hci/le_sub_event_code.h b/vendor_libs/test_vendor_lib/include/hci/le_sub_event_code.h
deleted file mode 100644
index 42edecd..0000000
--- a/vendor_libs/test_vendor_lib/include/hci/le_sub_event_code.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-#include <cstdint>
-
-namespace test_vendor_lib {
-namespace hci {
-
-enum class LeSubEventCode : uint8_t {
- CONNECTION_COMPLETE = 0x01,
- ADVERTISING_REPORT = 0x02,
- CONNECTION_UPDATE_COMPLETE = 0x03,
- READ_REMOTE_FEATURES_COMPLETE = 0x04,
- LONG_TERM_KEY_REQUEST = 0x05,
- REMOTE_CONNECTION_PARAMETER_REQUEST = 0x06,
- DATA_LENGTH_CHANGE = 0x07,
- ENHANCED_CONNECTION_COMPLETE = 0x0a,
- DIRECTED_ADVERTISING_REPORT = 0x0b,
- PHY_UPDATE_COMPLETE = 0x0c,
- EXTENDED_ADVERTISING_REPORT = 0x0D,
- PERIODIC_ADVERTISING_SYNC_ESTABLISHED = 0x0E,
- PERIODIC_ADVERTISING_REPORT = 0x0F,
- PERIODIC_ADVERTISING_SYNC_LOST = 0x10,
- SCAN_TIMEOUT = 0x11,
- ADVERTISING_SET_TERMINATED = 0x12,
- SCAN_REQUEST_RECEIVED = 0x13,
-};
-}
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/include/hci/op_code.h b/vendor_libs/test_vendor_lib/include/hci/op_code.h
deleted file mode 100644
index 64f9947..0000000
--- a/vendor_libs/test_vendor_lib/include/hci/op_code.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-#include <cstdint>
-
-namespace test_vendor_lib {
-namespace hci {
-
-using CommandGroups = enum {
- LINK_CONTROL = 0x01 << 10, /* 0x0400 */
- LINK_POLICY = 0x02 << 10, /* 0x0800 */
- CONTROLLER_AND_BASEBAND = 0x03 << 10, /* 0x0C00 */
- INFORMATIONAL_PARAMETERS = 0x04 << 10, /* 0x1000 */
- STATUS_PARAMETERS = 0x05 << 10, /* 0x1400 */
- TESTING = 0x06 << 10, /* 0x1800 */
- LE_CONTROLLER = 0x08 << 10, /* 0x2000 */
- VENDOR_SPECIFIC = 0x3F << 10, /* 0xFC00 */
-};
-
-enum class OpCode : uint16_t {
- NONE = 0x0000,
-
- /* LINK_CONTROL */
- INQUIRY = LINK_CONTROL | 0x0001,
- INQUIRY_CANCEL = LINK_CONTROL | 0x0002,
- PERIODIC_INQUIRY_MODE = LINK_CONTROL | 0x0003,
- EXIT_PERIODIC_INQUIRY_MODE = LINK_CONTROL | 0x0004,
- CREATE_CONNECTION = LINK_CONTROL | 0x0005,
- DISCONNECT = LINK_CONTROL | 0x0006,
- CREATE_CONNECTION_CANCEL = LINK_CONTROL | 0x0008,
- ACCEPT_CONNECTION_REQUEST = LINK_CONTROL | 0x0009,
- REJECT_CONNECTION_REQUEST = LINK_CONTROL | 0x000A,
- LINK_KEY_REQUEST_REPLY = LINK_CONTROL | 0x000B,
- LINK_KEY_REQUEST_NEGATIVE_REPLY = LINK_CONTROL | 0x000C,
- PIN_CODE_REQUEST_REPLY = LINK_CONTROL | 0x000D,
- PIN_CODE_REQUEST_NEGATIVE_REPLY = LINK_CONTROL | 0x000E,
- CHANGE_CONNECTION_PACKET_TYPE = LINK_CONTROL | 0x000F,
- AUTHENTICATION_REQUESTED = LINK_CONTROL | 0x0011,
- SET_CONNECTION_ENCRYPTION = LINK_CONTROL | 0x0013,
- CHANGE_CONNECTION_LINK_KEY = LINK_CONTROL | 0x0015,
- MASTER_LINK_KEY = LINK_CONTROL | 0x0017,
- REMOTE_NAME_REQUEST = LINK_CONTROL | 0x0019,
- REMOTE_NAME_REQUEST_CANCEL = LINK_CONTROL | 0x001A,
- READ_REMOTE_SUPPORTED_FEATURES = LINK_CONTROL | 0x001B,
- READ_REMOTE_EXTENDED_FEATURES = LINK_CONTROL | 0x001C,
- READ_REMOTE_VERSION_INFORMATION = LINK_CONTROL | 0x001D,
- READ_CLOCK_OFFSET = LINK_CONTROL | 0x001F,
- READ_LMP_HANDLE = LINK_CONTROL | 0x0020,
- SETUP_SYNCHRONOUS_CONNECTION = LINK_CONTROL | 0x0028,
- ACCEPT_SYNCHRONOUS_CONNECTION = LINK_CONTROL | 0x0029,
- REJECT_SYNCHRONOUS_CONNECTION = LINK_CONTROL | 0x002A,
- IO_CAPABILITY_REQUEST_REPLY = LINK_CONTROL | 0x002B,
- USER_CONFIRMATION_REQUEST_REPLY = LINK_CONTROL | 0x002C,
- USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY = LINK_CONTROL | 0x002D,
- USER_PASSKEY_REQUEST_REPLY = LINK_CONTROL | 0x002E,
- USER_PASSKEY_REQUEST_NEGATIVE_REPLY = LINK_CONTROL | 0x002F,
- REMOTE_OOB_DATA_REQUEST_REPLY = LINK_CONTROL | 0x0030,
- REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY = LINK_CONTROL | 0x0033,
- IO_CAPABILITY_REQUEST_NEGATIVE_REPLY = LINK_CONTROL | 0x0034,
- ENHANCED_SETUP_SYNCHRONOUS_CONNECTION = LINK_CONTROL | 0x003D,
- ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION = LINK_CONTROL | 0x003E,
-
- /* LINK_POLICY */
- HOLD_MODE = LINK_POLICY | 0x0001,
- SNIFF_MODE = LINK_POLICY | 0x0003,
- EXIT_SNIFF_MODE = LINK_POLICY | 0x0004,
- QOS_SETUP = LINK_POLICY | 0x0007,
- ROLE_DISCOVERY = LINK_POLICY | 0x0009,
- SWITCH_ROLE = LINK_POLICY | 0x000B,
- READ_LINK_POLICY_SETTINGS = LINK_POLICY | 0x000C,
- WRITE_LINK_POLICY_SETTINGS = LINK_POLICY | 0x000D,
- READ_DEFAULT_LINK_POLICY_SETTINGS = LINK_POLICY | 0x000E,
- WRITE_DEFAULT_LINK_POLICY_SETTINGS = LINK_POLICY | 0x000F,
- FLOW_SPECIFICATION = LINK_POLICY | 0x0010,
- SNIFF_SUBRATING = LINK_POLICY | 0x0011,
-
- /* CONTROLLER_AND_BASEBAND */
- SET_EVENT_MASK = CONTROLLER_AND_BASEBAND | 0x0001,
- RESET = CONTROLLER_AND_BASEBAND | 0x0003,
- SET_EVENT_FILTER = CONTROLLER_AND_BASEBAND | 0x0005,
- FLUSH = CONTROLLER_AND_BASEBAND | 0x0008,
- READ_PIN_TYPE = CONTROLLER_AND_BASEBAND | 0x0009,
- WRITE_PIN_TYPE = CONTROLLER_AND_BASEBAND | 0x000A,
- CREATE_NEW_UNIT_KEY = CONTROLLER_AND_BASEBAND | 0x000B,
- READ_STORED_LINK_KEY = CONTROLLER_AND_BASEBAND | 0x000D,
- WRITE_STORED_LINK_KEY = CONTROLLER_AND_BASEBAND | 0x0011,
- DELETE_STORED_LINK_KEY = CONTROLLER_AND_BASEBAND | 0x0012,
- WRITE_LOCAL_NAME = CONTROLLER_AND_BASEBAND | 0x0013,
- READ_LOCAL_NAME = CONTROLLER_AND_BASEBAND | 0x0014,
- READ_CONNECTION_ACCEPT_TIMEOUT = CONTROLLER_AND_BASEBAND | 0x0015,
- WRITE_CONNECTION_ACCEPT_TIMEOUT = CONTROLLER_AND_BASEBAND | 0x0016,
- READ_PAGE_TIMEOUT = CONTROLLER_AND_BASEBAND | 0x0017,
- WRITE_PAGE_TIMEOUT = CONTROLLER_AND_BASEBAND | 0x0018,
- READ_SCAN_ENABLE = CONTROLLER_AND_BASEBAND | 0x0019,
- WRITE_SCAN_ENABLE = CONTROLLER_AND_BASEBAND | 0x001A,
- READ_PAGE_SCAN_ACTIVITY = CONTROLLER_AND_BASEBAND | 0x001B,
- WRITE_PAGE_SCAN_ACTIVITY = CONTROLLER_AND_BASEBAND | 0x001C,
- READ_INQUIRY_SCAN_ACTIVITY = CONTROLLER_AND_BASEBAND | 0x001D,
- WRITE_INQUIRY_SCAN_ACTIVITY = CONTROLLER_AND_BASEBAND | 0x001E,
- READ_AUTHENTICATION_ENABLE = CONTROLLER_AND_BASEBAND | 0x001F,
- WRITE_AUTHENTICATION_ENABLE = CONTROLLER_AND_BASEBAND | 0x0020,
- READ_CLASS_OF_DEVICE = CONTROLLER_AND_BASEBAND | 0x0023,
- WRITE_CLASS_OF_DEVICE = CONTROLLER_AND_BASEBAND | 0x0024,
- READ_VOICE_SETTING = CONTROLLER_AND_BASEBAND | 0x0025,
- WRITE_VOICE_SETTING = CONTROLLER_AND_BASEBAND | 0x0026,
- READ_AUTOMATIC_FLUSH_TIMEOUT = CONTROLLER_AND_BASEBAND | 0x0027,
- WRITE_AUTOMATIC_FLUSH_TIMEOUT = CONTROLLER_AND_BASEBAND | 0x0028,
- READ_NUM_BROADCAST_RETRANSMITS = CONTROLLER_AND_BASEBAND | 0x0029,
- WRITE_NUM_BROADCAST_RETRANSMITS = CONTROLLER_AND_BASEBAND | 0x002A,
- READ_HOLD_MODE_ACTIVITY = CONTROLLER_AND_BASEBAND | 0x002B,
- WRITE_HOLD_MODE_ACTIVITY = CONTROLLER_AND_BASEBAND | 0x002C,
- READ_TRANSMIT_POWER_LEVEL = CONTROLLER_AND_BASEBAND | 0x002D,
- READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE = CONTROLLER_AND_BASEBAND | 0x002E,
- WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE = CONTROLLER_AND_BASEBAND | 0x002F,
- SET_CONTROLLER_TO_HOST_FLOW_CONTROL = CONTROLLER_AND_BASEBAND | 0x0031,
- HOST_BUFFER_SIZE = CONTROLLER_AND_BASEBAND | 0x0033,
- HOST_NUM_COMPLETED_PACKETS = CONTROLLER_AND_BASEBAND | 0x0035,
- READ_LINK_SUPERVISION_TIMEOUT = CONTROLLER_AND_BASEBAND | 0x0036,
- WRITE_LINK_SUPERVISION_TIMEOUT = CONTROLLER_AND_BASEBAND | 0x0037,
- READ_NUMBER_OF_SUPPORTED_IAC = CONTROLLER_AND_BASEBAND | 0x0038,
- READ_CURRENT_IAC_LAP = CONTROLLER_AND_BASEBAND | 0x0039,
- WRITE_CURRENT_IAC_LAP = CONTROLLER_AND_BASEBAND | 0x003A,
- SET_AFH_HOST_CHANNEL_CLASSIFICATION = CONTROLLER_AND_BASEBAND | 0x003F,
- READ_LE_HOST_SUPPORT = CONTROLLER_AND_BASEBAND | 0x6C,
- WRITE_LE_HOST_SUPPORT = CONTROLLER_AND_BASEBAND | 0x6D,
- READ_INQUIRY_SCAN_TYPE = CONTROLLER_AND_BASEBAND | 0x0042,
- WRITE_INQUIRY_SCAN_TYPE = CONTROLLER_AND_BASEBAND | 0x0043,
- READ_INQUIRY_MODE = CONTROLLER_AND_BASEBAND | 0x0044,
- WRITE_INQUIRY_MODE = CONTROLLER_AND_BASEBAND | 0x0045,
- READ_PAGE_SCAN_TYPE = CONTROLLER_AND_BASEBAND | 0x0046,
- WRITE_PAGE_SCAN_TYPE = CONTROLLER_AND_BASEBAND | 0x0047,
- READ_AFH_CHANNEL_ASSESSMENT_MODE = CONTROLLER_AND_BASEBAND | 0x0048,
- WRITE_AFH_CHANNEL_ASSESSMENT_MODE = CONTROLLER_AND_BASEBAND | 0x0049,
- READ_EXTENDED_INQUIRY_RESPONSE = CONTROLLER_AND_BASEBAND | 0x0051,
- WRITE_EXTENDED_INQUIRY_RESPONSE = CONTROLLER_AND_BASEBAND | 0x0052,
- REFRESH_ENCRYPTION_KEY = CONTROLLER_AND_BASEBAND | 0x0053,
- READ_SIMPLE_PAIRING_MODE = CONTROLLER_AND_BASEBAND | 0x0055,
- WRITE_SIMPLE_PAIRING_MODE = CONTROLLER_AND_BASEBAND | 0x0056,
- READ_LOCAL_OOB_DATA = CONTROLLER_AND_BASEBAND | 0x0057,
- READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL = CONTROLLER_AND_BASEBAND | 0x0058,
- WRITE_INQUIRY_TRANSMIT_POWER_LEVEL = CONTROLLER_AND_BASEBAND | 0x0059,
- SEND_KEYPRESS_NOTIFICATION = CONTROLLER_AND_BASEBAND | 0x0060,
-
- READ_SECURE_CONNECTIONS_HOST_SUPPORT = CONTROLLER_AND_BASEBAND | 0x0079,
- WRITE_SECURE_CONNECTIONS_HOST_SUPPORT = CONTROLLER_AND_BASEBAND | 0x007A,
-
- /* INFORMATIONAL_PARAMETERS */
- READ_LOCAL_VERSION_INFORMATION = INFORMATIONAL_PARAMETERS | 0x0001,
- READ_LOCAL_SUPPORTED_COMMANDS = INFORMATIONAL_PARAMETERS | 0x0002,
- READ_LOCAL_SUPPORTED_FEATURES = INFORMATIONAL_PARAMETERS | 0x0003,
- READ_LOCAL_EXTENDED_FEATURES = INFORMATIONAL_PARAMETERS | 0x0004,
- READ_BUFFER_SIZE = INFORMATIONAL_PARAMETERS | 0x0005,
- READ_BD_ADDR = INFORMATIONAL_PARAMETERS | 0x0009,
- READ_DATA_BLOCK_SIZE = INFORMATIONAL_PARAMETERS | 0x000A,
- READ_LOCAL_SUPPORTED_CODECS = INFORMATIONAL_PARAMETERS | 0x000B,
-
- /* STATUS_PARAMETERS */
- READ_FAILED_CONTACT_COUNTER = STATUS_PARAMETERS | 0x0001,
- RESET_FAILED_CONTACT_COUNTER = STATUS_PARAMETERS | 0x0002,
- READ_LINK_QUALITY = STATUS_PARAMETERS | 0x0003,
- READ_RSSI = STATUS_PARAMETERS | 0x0005,
- READ_AFH_CHANNEL_MAP = STATUS_PARAMETERS | 0x0006,
- READ_CLOCK = STATUS_PARAMETERS | 0x0007,
- READ_ENCRYPTION_KEY_SIZE = STATUS_PARAMETERS | 0x0008,
-
- /* TESTING */
- READ_LOOPBACK_MODE = TESTING | 0x0001,
- WRITE_LOOPBACK_MODE = TESTING | 0x0002,
- ENABLE_DEVICE_UNDER_TEST_MODE = TESTING | 0x0003,
- WRITE_SIMPLE_PAIRING_DEBUG_MODE = TESTING | 0x0004,
- WRITE_SECURE_CONNECTIONS_TEST_MODE = TESTING | 0x000A,
-
- /* LE_CONTROLLER */
- LE_SET_EVENT_MASK = LE_CONTROLLER | 0x0001,
- LE_READ_BUFFER_SIZE = LE_CONTROLLER | 0x0002,
- LE_READ_LOCAL_SUPPORTED_FEATURES = LE_CONTROLLER | 0x0003,
- LE_WRITE_LOCAL_SUPPORTED_FEATURES = LE_CONTROLLER | 0x0004,
- LE_SET_RANDOM_ADDRESS = LE_CONTROLLER | 0x0005,
- LE_SET_ADVERTISING_PARAMETERS = LE_CONTROLLER | 0x0006,
- LE_READ_ADVERTISING_CHANNEL_TX_POWER = LE_CONTROLLER | 0x0007,
- LE_SET_ADVERTISING_DATA = LE_CONTROLLER | 0x0008,
- LE_SET_SCAN_RESPONSE_DATA = LE_CONTROLLER | 0x0009,
- LE_SET_ADVERTISING_ENABLE = LE_CONTROLLER | 0x000A,
- LE_SET_SCAN_PARAMETERS = LE_CONTROLLER | 0x000B,
- LE_SET_SCAN_ENABLE = LE_CONTROLLER | 0x000C,
- LE_CREATE_CONNECTION = LE_CONTROLLER | 0x000D,
- LE_CREATE_CONNECTION_CANCEL = LE_CONTROLLER | 0x000E,
- LE_READ_WHITE_LIST_SIZE = LE_CONTROLLER | 0x000F,
- LE_CLEAR_WHITE_LIST = LE_CONTROLLER | 0x0010,
- LE_ADD_DEVICE_TO_WHITE_LIST = LE_CONTROLLER | 0x0011,
- LE_REMOVE_DEVICE_FROM_WHITE_LIST = LE_CONTROLLER | 0x0012,
- LE_CONNECTION_UPDATE = LE_CONTROLLER | 0x0013,
- LE_SET_HOST_CHANNEL_CLASSIFICATION = LE_CONTROLLER | 0x0014,
- LE_READ_CHANNEL_MAP = LE_CONTROLLER | 0x0015,
- LE_READ_REMOTE_FEATURES = LE_CONTROLLER | 0x0016,
- LE_ENCRYPT = LE_CONTROLLER | 0x0017,
- LE_RAND = LE_CONTROLLER | 0x0018,
- LE_START_ENCRYPTION = LE_CONTROLLER | 0x0019,
- LE_LONG_TERM_KEY_REQUEST_REPLY = LE_CONTROLLER | 0x001A,
- LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY = LE_CONTROLLER | 0x001B,
- LE_READ_SUPPORTED_STATES = LE_CONTROLLER | 0x001C,
- LE_RECEIVER_TEST = LE_CONTROLLER | 0x001D,
- LE_TRANSMITTER_TEST = LE_CONTROLLER | 0x001E,
- LE_TEST_END = LE_CONTROLLER | 0x001F,
- LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY = LE_CONTROLLER | 0x0020,
- LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY = LE_CONTROLLER | 0x0021,
-
- LE_SET_DATA_LENGTH = LE_CONTROLLER | 0x0022,
- LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH = LE_CONTROLLER | 0x0023,
- LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH = LE_CONTROLLER | 0x0024,
- LE_READ_LOCAL_P_256_PUBLIC_KEY_COMMAND = LE_CONTROLLER | 0x0025,
- LE_GENERATE_DHKEY_COMMAND = LE_CONTROLLER | 0x0026,
- LE_ADD_DEVICE_TO_RESOLVING_LIST = LE_CONTROLLER | 0x0027,
- LE_REMOVE_DEVICE_FROM_RESOLVING_LIST = LE_CONTROLLER | 0x0028,
- LE_CLEAR_RESOLVING_LIST = LE_CONTROLLER | 0x0029,
- LE_READ_RESOLVING_LIST_SIZE = LE_CONTROLLER | 0x002A,
- LE_READ_PEER_RESOLVABLE_ADDRESS = LE_CONTROLLER | 0x002B,
- LE_READ_LOCAL_RESOLVABLE_ADDRESS = LE_CONTROLLER | 0x002C,
- LE_SET_ADDRESS_RESOLUTION_ENABLE = LE_CONTROLLER | 0x002D,
- LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT = LE_CONTROLLER | 0x002E,
- LE_READ_MAXIMUM_DATA_LENGTH = LE_CONTROLLER | 0x002F,
- LE_READ_PHY = LE_CONTROLLER | 0x0030,
- LE_SET_DEFAULT_PHY = LE_CONTROLLER | 0x0031,
- LE_SET_PHY = LE_CONTROLLER | 0x0032,
- LE_ENHANCED_RECEIVER_TEST = LE_CONTROLLER | 0x0033,
- LE_ENHANCED_TRANSMITTER_TEST = LE_CONTROLLER | 0x0034,
- LE_SET_EXTENDED_ADVERTISING_RANDOM_ADDRESS = LE_CONTROLLER | 0x35,
- LE_SET_EXTENDED_ADVERTISING_PARAMETERS = LE_CONTROLLER | 0x36,
- LE_SET_EXTENDED_ADVERTISING_DATA = LE_CONTROLLER | 0x37,
- LE_SET_EXTENDED_ADVERTISING_SCAN_RESPONSE = LE_CONTROLLER | 0x38,
- LE_SET_EXTENDED_ADVERTISING_ENABLE = LE_CONTROLLER | 0x39,
- LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH = LE_CONTROLLER | 0x003A,
- LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS = LE_CONTROLLER | 0x003B,
- LE_REMOVE_ADVERTISING_SET = LE_CONTROLLER | 0x003C,
- LE_CLEAR_ADVERTISING_SETS = LE_CONTROLLER | 0x003D,
- LE_SET_PERIODIC_ADVERTISING_PARAM = LE_CONTROLLER | 0x003E,
- LE_SET_PERIODIC_ADVERTISING_DATA = LE_CONTROLLER | 0x003F,
- LE_SET_PERIODIC_ADVERTISING_ENABLE = LE_CONTROLLER | 0x0040,
- LE_SET_EXTENDED_SCAN_PARAMETERS = LE_CONTROLLER | 0x0041,
- LE_SET_EXTENDED_SCAN_ENABLE = LE_CONTROLLER | 0x0042,
- LE_EXTENDED_CREATE_CONNECTION = LE_CONTROLLER | 0x0043,
- LE_PERIODIC_ADVERTISING_CREATE_SYNC = LE_CONTROLLER | 0x0044,
- LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL = LE_CONTROLLER | 0x0045,
- LE_PERIODIC_ADVERTISING_TERMINATE_SYNC = LE_CONTROLLER | 0x0046,
- LE_ADD_DEVICE_TO_PERIODIC_ADVERTISING_LIST = LE_CONTROLLER | 0x0047,
- LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISING_LIST = LE_CONTROLLER | 0x0048,
- LE_CLEAR_PERIODIC_ADVERTISING_LIST = LE_CONTROLLER | 0x0049,
- LE_READ_PERIODIC_ADVERTISING_LIST_SIZE = LE_CONTROLLER | 0x004A,
- LE_READ_TRANSMIT_POWER = LE_CONTROLLER | 0x004B,
- LE_READ_RF_PATH_COMPENSATION_POWER = LE_CONTROLLER | 0x004C,
- LE_WRITE_RF_PATH_COMPENSATION_POWER = LE_CONTROLLER | 0x004D,
- LE_SET_PRIVACY_MODE = LE_CONTROLLER | 0x004E,
-
- /* VENDOR_SPECIFIC */
- LE_GET_VENDOR_CAPABILITIES = VENDOR_SPECIFIC | 0x0153,
- LE_MULTI_ADVT = VENDOR_SPECIFIC | 0x0154,
- LE_BATCH_SCAN = VENDOR_SPECIFIC | 0x0156,
- LE_ADV_FILTER = VENDOR_SPECIFIC | 0x0157,
- LE_TRACK_ADV = VENDOR_SPECIFIC | 0x0158,
- LE_ENERGY_INFO = VENDOR_SPECIFIC | 0x0159,
- LE_EXTENDED_SCAN_PARAMS = VENDOR_SPECIFIC | 0x015A,
- CONTROLLER_DEBUG_INFO = VENDOR_SPECIFIC | 0x015B,
- CONTROLLER_A2DP_OPCODE = VENDOR_SPECIFIC | 0x015D,
-};
-
-} // namespace hci
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/include/hci/status.h b/vendor_libs/test_vendor_lib/include/hci/status.h
deleted file mode 100644
index 4452cfa..0000000
--- a/vendor_libs/test_vendor_lib/include/hci/status.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-#include <cstdint>
-
-namespace test_vendor_lib {
-namespace hci {
-
-enum class Status : uint8_t {
- SUCCESS = 0,
- UNKNOWN_COMMAND = 1,
- UNKNOWN_CONNECTION = 2,
- HARDWARE_FAILURE = 3,
- PAGE_TIMEOUT = 4,
- AUTHENTICATION_FAILURE = 5,
- PIN_OR_KEY_MISSING = 6,
- MEMORY_CAPACITY_EXCEEDED = 7,
- CONNECTION_TIMEOUT = 8,
- COMMAND_DISALLOWED = 0x0c,
- CONNECTION_REJECTED_LIMITED_RESOURCES = 0x0d,
- CONNECTION_REJECTED_SECURITY = 0x0e,
- CONNECTION_REJECTED_UNACCEPTABLE_BD_ADDR = 0x0f,
- INVALID_HCI_COMMAND_PARAMETERS = 0x12,
- REMOTE_USER_TERMINATED_CONNECTION = 0x13,
- CONNECTION_TERMINATED_BY_LOCAL_HOST = 0x16,
- UNSPECIFIED_ERROR = 0x1f,
- ENCRYPTION_MODE_NOT_ACCEPTABLE = 0x25,
- HOST_BUSY_PAIRING = 0x38,
- CONTROLLER_BUSY = 0x3a,
-};
-}
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc b/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
index f84e514..bb3ba63 100644
--- a/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
+++ b/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
@@ -25,11 +25,8 @@
#include "os/log.h"
#include "packet/raw_builder.h"
-#include "hci.h"
-
+using bluetooth::hci::OpCode;
using std::vector;
-using test_vendor_lib::hci::EventCode;
-using test_vendor_lib::hci::OpCode;
namespace {
@@ -89,7 +86,7 @@
DualModeController::DualModeController(const std::string& properties_filename, uint16_t num_keys)
: Device(properties_filename), security_manager_(num_keys) {
- loopback_mode_ = hci::LoopbackMode::NO;
+ loopback_mode_ = bluetooth::hci::LoopbackMode::NO_LOOPBACK;
Address public_address;
ASSERT(Address::FromString("3C:5A:B4:04:05:06", public_address));
@@ -236,7 +233,7 @@
bluetooth::hci::PacketView<bluetooth::hci::kLittleEndian> raw_packet(packet);
auto acl_packet = bluetooth::hci::AclPacketView::Create(raw_packet);
ASSERT(acl_packet.IsValid());
- if (loopback_mode_ == hci::LoopbackMode::LOCAL) {
+ if (loopback_mode_ == bluetooth::hci::LoopbackMode::ENABLE_LOCAL) {
uint16_t handle = acl_packet.GetHandle();
std::vector<bluetooth::hci::CompletedPackets> completed_packets;
@@ -256,7 +253,7 @@
void DualModeController::HandleSco(std::shared_ptr<std::vector<uint8_t>> packet) {
bluetooth::hci::PacketView<bluetooth::hci::kLittleEndian> raw_packet(packet);
auto sco_packet = bluetooth::hci::ScoPacketView::Create(raw_packet);
- if (loopback_mode_ == hci::LoopbackMode::LOCAL) {
+ if (loopback_mode_ == bluetooth::hci::LoopbackMode::ENABLE_LOCAL) {
uint16_t handle = sco_packet.GetHandle();
send_sco_(packet);
std::vector<bluetooth::hci::CompletedPackets> completed_packets;
@@ -283,7 +280,7 @@
auto op = command_packet.GetOpCode();
uint16_t opcode = static_cast<uint16_t>(op);
- if (loopback_mode_ == hci::LoopbackMode::LOCAL &&
+ if (loopback_mode_ == bluetooth::hci::LoopbackMode::ENABLE_LOCAL &&
// Loopback exceptions.
op != bluetooth::hci::OpCode::RESET &&
op != bluetooth::hci::OpCode::SET_CONTROLLER_TO_HOST_FLOW_CONTROL &&
@@ -349,8 +346,8 @@
void DualModeController::HciReset(bluetooth::packet::PacketView<true> args) {
ASSERT_LOG(args.size() == 0, "%s size=%zu", __func__, args.size());
link_layer_controller_.Reset();
- if (loopback_mode_ == hci::LoopbackMode::LOCAL) {
- loopback_mode_ = hci::LoopbackMode::NO;
+ if (loopback_mode_ == bluetooth::hci::LoopbackMode::ENABLE_LOCAL) {
+ loopback_mode_ = bluetooth::hci::LoopbackMode::NO_LOOPBACK;
}
send_event_(bluetooth::hci::ResetCompleteBuilder::Create(
@@ -662,7 +659,8 @@
auto args_itr = args.begin();
Address peer = args_itr.extract<Address>();
- hci::Status reason = args_itr.extract<hci::Status>();
+ bluetooth::hci::ErrorCode reason =
+ args_itr.extract<bluetooth::hci::ErrorCode>();
auto status =
link_layer_controller_.IoCapabilityRequestNegativeReply(peer, reason);
@@ -1675,7 +1673,7 @@
void DualModeController::HciWriteLoopbackMode(
bluetooth::packet::PacketView<true> args) {
ASSERT_LOG(args.size() == 1, "%s size=%zu", __func__, args.size());
- loopback_mode_ = static_cast<hci::LoopbackMode>(args[0]);
+ loopback_mode_ = static_cast<bluetooth::hci::LoopbackMode>(args[0]);
// ACL channel
uint16_t acl_handle = 0x123;
auto packet_acl = bluetooth::hci::ConnectionCompleteBuilder::Create(
diff --git a/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h b/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
index 53c1a56..d7c41e5 100644
--- a/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
+++ b/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
@@ -440,9 +440,6 @@
void AddConnectionAction(const TaskCallback& callback, uint16_t handle);
- // Creates a command complete event and sends it back to the HCI.
- void SendCommandComplete(hci::OpCode command_opcode, const std::vector<uint8_t>& return_parameters) const;
-
void SendCommandCompleteUnknownOpCodeEvent(uint16_t command_opcode) const;
// Callbacks to send packets back to the HCI.
@@ -460,7 +457,7 @@
std::function<void(bluetooth::packet::PacketView<true>)>>
active_hci_commands_;
- hci::LoopbackMode loopback_mode_;
+ bluetooth::hci::LoopbackMode loopback_mode_;
SecurityManager security_manager_;
diff --git a/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.cc b/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.cc
index 39e5373..d5f3ba7 100644
--- a/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.cc
+++ b/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.cc
@@ -16,14 +16,12 @@
#include "link_layer_controller.h"
-#include "hci.h"
#include "include/le_advertisement.h"
#include "os/log.h"
#include "packet/raw_builder.h"
using std::vector;
using namespace std::chrono;
-using namespace test_vendor_lib::packets;
namespace test_vendor_lib {
@@ -111,11 +109,11 @@
connections_.GetAddress(handle));
}
-hci::Status LinkLayerController::SendAclToRemote(
+bluetooth::hci::ErrorCode LinkLayerController::SendAclToRemote(
bluetooth::hci::AclPacketView acl_packet) {
uint16_t handle = acl_packet.GetHandle();
if (!connections_.HasHandle(handle)) {
- return hci::Status::UNKNOWN_CONNECTION;
+ return bluetooth::hci::ErrorCode::UNKNOWN_CONNECTION;
}
Address my_address = properties_.GetAddress();
@@ -156,7 +154,7 @@
my_address, destination, std::move(raw_builder_ptr));
SendLinkLayerPacket(std::move(acl));
- return hci::Status::SUCCESS;
+ return bluetooth::hci::ErrorCode::SUCCESS;
}
void LinkLayerController::IncomingPacket(
@@ -797,10 +795,13 @@
incoming.GetSourceAddress().ToString().c_str(), connect.GetAddressType());
return;
}
- HandleLeConnection(incoming.GetSourceAddress(), static_cast<uint8_t>(connect.GetAddressType()),
- static_cast<uint8_t>(properties_.GetLeAdvertisingOwnAddressType()),
- static_cast<uint8_t>(hci::Role::SLAVE), connection_interval, connect.GetLeConnectionLatency(),
- connect.GetLeConnectionSupervisionTimeout());
+ HandleLeConnection(
+ incoming.GetSourceAddress(),
+ static_cast<uint8_t>(connect.GetAddressType()),
+ static_cast<uint8_t>(properties_.GetLeAdvertisingOwnAddressType()),
+ static_cast<uint8_t>(bluetooth::hci::Role::SLAVE), connection_interval,
+ connect.GetLeConnectionLatency(),
+ connect.GetLeConnectionSupervisionTimeout());
auto to_send = model::packets::LeConnectCompleteBuilder::Create(
incoming.GetDestinationAddress(), incoming.GetSourceAddress(),
@@ -814,9 +815,12 @@
model::packets::LinkLayerPacketView incoming) {
auto complete = model::packets::LeConnectCompleteView::Create(incoming);
ASSERT(complete.IsValid());
- HandleLeConnection(incoming.GetSourceAddress(), static_cast<uint8_t>(complete.GetAddressType()),
- static_cast<uint8_t>(le_address_type_), static_cast<uint8_t>(hci::Role::MASTER),
- complete.GetLeConnectionInterval(), complete.GetLeConnectionLatency(),
+ HandleLeConnection(incoming.GetSourceAddress(),
+ static_cast<uint8_t>(complete.GetAddressType()),
+ static_cast<uint8_t>(le_address_type_),
+ static_cast<uint8_t>(bluetooth::hci::Role::MASTER),
+ complete.GetLeConnectionInterval(),
+ complete.GetLeConnectionLatency(),
complete.GetLeConnectionSupervisionTimeout());
}
@@ -1124,7 +1128,7 @@
}
bluetooth::hci::ErrorCode LinkLayerController::IoCapabilityRequestNegativeReply(
- const Address& peer, hci::Status reason) {
+ const Address& peer, bluetooth::hci::ErrorCode reason) {
if (security_manager_.GetAuthenticationAddress() != peer) {
return bluetooth::hci::ErrorCode::AUTHENTICATION_FAILURE;
}
@@ -1373,7 +1377,10 @@
ASSERT_LOG(connections_.Disconnect(handle), "Disconnecting %hx", handle);
ScheduleTask(milliseconds(20), [this, handle]() {
- DisconnectCleanup(handle, static_cast<uint8_t>(hci::Status::CONNECTION_TERMINATED_BY_LOCAL_HOST));
+ DisconnectCleanup(
+ handle,
+ static_cast<uint8_t>(
+ bluetooth::hci::ErrorCode::CONNECTION_TERMINATED_BY_LOCAL_HOST));
});
return bluetooth::hci::ErrorCode::SUCCESS;
diff --git a/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.h b/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.h
index 460d015..487109f 100644
--- a/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.h
+++ b/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.h
@@ -25,7 +25,6 @@
#include "model/devices/device_properties.h"
#include "model/setup/async_manager.h"
#include "packets/link_layer_packets.h"
-#include "packets/packet_view.h"
#include "security_manager.h"
namespace test_vendor_lib {
@@ -43,8 +42,10 @@
bluetooth::hci::ErrorCode SendCommandToRemoteByHandle(
bluetooth::hci::OpCode opcode, bluetooth::packet::PacketView<true> args,
uint16_t handle);
- hci::Status SendScoToRemote(bluetooth::hci::ScoPacketView sco_packet);
- hci::Status SendAclToRemote(bluetooth::hci::AclPacketView acl_packet);
+ bluetooth::hci::ErrorCode SendScoToRemote(
+ bluetooth::hci::ScoPacketView sco_packet);
+ bluetooth::hci::ErrorCode SendAclToRemote(
+ bluetooth::hci::AclPacketView acl_packet);
void WriteSimplePairingMode(bool enabled);
void StartSimplePairing(const Address& address);
@@ -57,7 +58,7 @@
const Address& peer, uint8_t io_capability, uint8_t oob_data_present_flag,
uint8_t authentication_requirements);
bluetooth::hci::ErrorCode IoCapabilityRequestNegativeReply(
- const Address& peer, hci::Status reason);
+ const Address& peer, bluetooth::hci::ErrorCode reason);
bluetooth::hci::ErrorCode UserConfirmationRequestReply(const Address& peer);
bluetooth::hci::ErrorCode UserConfirmationRequestNegativeReply(
const Address& peer);
diff --git a/vendor_libs/test_vendor_lib/model/devices/device_properties.cc b/vendor_libs/test_vendor_lib/model/devices/device_properties.cc
index 2a4a970..8309268 100644
--- a/vendor_libs/test_vendor_lib/model/devices/device_properties.cc
+++ b/vendor_libs/test_vendor_lib/model/devices/device_properties.cc
@@ -22,7 +22,6 @@
#include "base/json/json_reader.h"
#include "base/values.h"
-#include "hci.h"
#include "os/log.h"
#include "osi/include/osi.h"
@@ -49,9 +48,9 @@
sco_data_packet_size_(255),
num_acl_data_packets_(10),
num_sco_data_packets_(10),
- version_(static_cast<uint8_t>(hci::Version::V4_1)),
+ version_(static_cast<uint8_t>(bluetooth::hci::HciVersion::V_4_1)),
revision_(0),
- lmp_pal_version_(static_cast<uint8_t>(hci::Version::V4_1)),
+ lmp_pal_version_(static_cast<uint8_t>(bluetooth::hci::LmpVersion::V_4_1)),
manufacturer_name_(0),
lmp_pal_subversion_(0),
le_data_packet_length_(27),
diff --git a/vendor_libs/test_vendor_lib/packets/Android.bp b/vendor_libs/test_vendor_lib/packets/Android.bp
deleted file mode 100644
index e507c27..0000000
--- a/vendor_libs/test_vendor_lib/packets/Android.bp
+++ /dev/null
@@ -1,71 +0,0 @@
-// packet library for libbt-rootcanal
-// ========================================================
-cc_library_static {
- name: "libbt-rootcanal-packets",
- defaults: [
- "libchrome_support_defaults",
- "clang_file_coverage",
- ],
- host_supported: true,
- proprietary: true,
- srcs: [
- "iterator.cc",
- "counted_builder.cc",
- "packet_view.cc",
- "raw_builder.cc",
- "view.cc",
- ],
- cflags: [
- "-fvisibility=hidden",
- ],
- local_include_dirs: [
- ".",
- ],
- export_include_dirs: ["."],
- include_dirs: [
- "system/bt/vendor_libs/test_vendor_lib/include",
- "system/bt/vendor_libs/test_vendor_lib/",
- "system/bt/",
- "system/bt/gd",
- ],
- shared_libs: [
- "libbase",
- "liblog",
- ],
-}
-
-// Unit tests for the host
-// ========================================================
-cc_test_host {
- name: "rootcanal-packets_test_host",
- defaults: [
- "libchrome_support_defaults",
- "clang_file_coverage",
- "clang_coverage_bin",
- ],
- srcs: [
- "test/packet_builder_test.cc",
- "test/packet_view_test.cc",
- ":BluetoothHciClassSources",
- ],
- header_libs: [
- "libbluetooth_headers",
- ],
- local_include_dirs: [
- ".",
- ],
- include_dirs: [
- "system/bt",
- "system/bt/gd",
- "system/bt/hci/include",
- "system/bt/vendor_libs/test_vendor_lib",
- "system/bt/vendor_libs/test_vendor_lib/include",
- ],
- shared_libs: [
- "liblog",
- ],
- static_libs: [
- "libbt-rootcanal-types",
- "libbt-rootcanal-packets",
- ],
-}
diff --git a/vendor_libs/test_vendor_lib/packets/base_packet_builder.h b/vendor_libs/test_vendor_lib/packets/base_packet_builder.h
deleted file mode 100644
index 92ae3a9..0000000
--- a/vendor_libs/test_vendor_lib/packets/base_packet_builder.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-
-#include <cstdint>
-#include <forward_list>
-#include <iterator>
-#include <memory>
-#include <vector>
-
-namespace test_vendor_lib {
-namespace packets {
-
-// A little-endian PacketBuilder might contain a big-endian PacketBuilder,
-// so BasePacketBuilder provides a common base class.
-class BasePacketBuilder {
- public:
- virtual ~BasePacketBuilder() = default;
-
- virtual size_t size() const = 0;
-
- // Write to the vector with the given iterator.
- virtual void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const = 0;
-
- protected:
- BasePacketBuilder() = default;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/counted_builder.cc b/vendor_libs/test_vendor_lib/packets/counted_builder.cc
deleted file mode 100644
index 10d3ceb..0000000
--- a/vendor_libs/test_vendor_lib/packets/counted_builder.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2018 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 "counted_builder.h"
-
-using std::vector;
-
-namespace test_vendor_lib {
-namespace packets {
-
-size_t CountedBuilder::size() const {
- size_t payload_size = sizeof(uint8_t);
- for (size_t i = 0; i < sub_builders_.size(); i++) {
- payload_size += sub_builders_[i]->size();
- }
- return payload_size;
-}
-
-void CountedBuilder::Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const {
- insert(static_cast<uint8_t>(sub_builders_.size()), it);
- for (size_t i = 0; i < sub_builders_.size(); i++) {
- sub_builders_[i]->Serialize(it);
- }
-}
-
-void CountedBuilder::Add(std::unique_ptr<BasePacketBuilder> builder) {
- sub_builders_.push_back(std::move(builder));
-}
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/counted_builder.h b/vendor_libs/test_vendor_lib/packets/counted_builder.h
deleted file mode 100644
index fed88c5..0000000
--- a/vendor_libs/test_vendor_lib/packets/counted_builder.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-
-#include <cstdint>
-#include <forward_list>
-#include <memory>
-#include <vector>
-
-#include "packets/base_packet_builder.h"
-#include "packets/packet_builder.h"
-#include "packets/raw_builder.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-class CountedBuilder : public RawBuilder {
- public:
- CountedBuilder() = default;
- virtual ~CountedBuilder() = default;
-
- virtual size_t size() const override;
-
- virtual void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override;
-
- void Add(std::unique_ptr<BasePacketBuilder> builder);
-
- private:
- std::vector<std::unique_ptr<BasePacketBuilder>> sub_builders_;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/iterator.cc b/vendor_libs/test_vendor_lib/packets/iterator.cc
deleted file mode 100644
index dca3c82..0000000
--- a/vendor_libs/test_vendor_lib/packets/iterator.cc
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2018 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 "iterator.h"
-
-#include "os/log.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-template <bool little_endian>
-Iterator<little_endian>::Iterator(std::forward_list<View> data, size_t offset) {
- data_ = data;
- index_ = offset;
- length_ = 0;
- for (auto& view : data) {
- length_ += view.size();
- }
-}
-
-template <bool little_endian>
-Iterator<little_endian> Iterator<little_endian>::operator+(int offset) {
- auto itr(*this);
-
- return itr += offset;
-}
-
-template <bool little_endian>
-Iterator<little_endian>& Iterator<little_endian>::operator+=(int offset) {
- index_ += offset;
- return *this;
-}
-
-template <bool little_endian>
-Iterator<little_endian> Iterator<little_endian>::operator++(int) {
- auto itr(*this);
- index_++;
- return itr;
-}
-
-template <bool little_endian>
-Iterator<little_endian>& Iterator<little_endian>::operator++() {
- index_++;
- return *this;
-}
-
-template <bool little_endian>
-Iterator<little_endian> Iterator<little_endian>::operator-(int offset) {
- auto itr(*this);
-
- return itr -= offset;
-}
-
-template <bool little_endian>
-int Iterator<little_endian>::operator-(Iterator<little_endian>& itr) {
- return index_ - itr.index_;
-}
-
-template <bool little_endian>
-Iterator<little_endian>& Iterator<little_endian>::operator-=(int offset) {
- index_ -= offset;
-
- return *this;
-}
-
-template <bool little_endian>
-Iterator<little_endian> Iterator<little_endian>::operator--(int) {
- auto itr(*this);
- if (index_ != 0) index_--;
-
- return itr;
-}
-
-template <bool little_endian>
-Iterator<little_endian>& Iterator<little_endian>::operator--() {
- if (index_ != 0) index_--;
-
- return *this;
-}
-
-template <bool little_endian>
-Iterator<little_endian>& Iterator<little_endian>::operator=(const Iterator<little_endian>& itr) {
- data_ = itr.data_;
- index_ = itr.index_;
-
- return *this;
-}
-
-template <bool little_endian>
-bool Iterator<little_endian>::operator==(const Iterator<little_endian>& itr) const {
- return index_ == itr.index_;
-}
-
-template <bool little_endian>
-bool Iterator<little_endian>::operator!=(const Iterator<little_endian>& itr) const {
- return !(*this == itr);
-}
-
-template <bool little_endian>
-bool Iterator<little_endian>::operator<(const Iterator<little_endian>& itr) const {
- return index_ < itr.index_;
-}
-
-template <bool little_endian>
-bool Iterator<little_endian>::operator>(const Iterator<little_endian>& itr) const {
- return index_ > itr.index_;
-}
-
-template <bool little_endian>
-bool Iterator<little_endian>::operator<=(const Iterator<little_endian>& itr) const {
- return index_ <= itr.index_;
-}
-
-template <bool little_endian>
-bool Iterator<little_endian>::operator>=(const Iterator<little_endian>& itr) const {
- return index_ >= itr.index_;
-}
-
-template <bool little_endian>
-uint8_t Iterator<little_endian>::operator*() const {
- ASSERT_LOG(index_ < length_, "Index %d out of bounds: %d", static_cast<int>(index_), static_cast<int>(length_));
- size_t index = index_;
-
- for (auto view : data_) {
- if (index < view.size()) {
- return view[index];
- }
- index -= view.size();
- }
- LOG_ALWAYS_FATAL("Out of fragments searching for Index %d", static_cast<int>(index_));
- return 0;
-}
-
-template <bool little_endian>
-size_t Iterator<little_endian>::NumBytesRemaining() const {
- if (length_ > index_) {
- return length_ - index_;
- } else {
- return 0;
- }
-}
-
-// Explicit instantiations for both types of Iterators.
-template class Iterator<true>;
-template class Iterator<false>;
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/iterator.h b/vendor_libs/test_vendor_lib/packets/iterator.h
deleted file mode 100644
index 2f01fb9..0000000
--- a/vendor_libs/test_vendor_lib/packets/iterator.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-
-#include <cstdint>
-#include <forward_list>
-
-#include "hci/address.h"
-#include "view.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-using ::bluetooth::hci::Address;
-
-// Templated Iterator for endianness
-template <bool little_endian>
-class Iterator : public std::iterator<std::random_access_iterator_tag, uint8_t> {
- public:
- Iterator(std::forward_list<View> data, size_t offset);
- Iterator(const Iterator& itr) = default;
- virtual ~Iterator() = default;
-
- // All addition and subtraction operators are unbounded.
- Iterator operator+(int offset);
- Iterator& operator+=(int offset);
- Iterator operator++(int);
- Iterator& operator++();
-
- Iterator operator-(int offset);
- int operator-(Iterator& itr);
- Iterator& operator-=(int offset);
- Iterator operator--(int);
- Iterator& operator--();
-
- Iterator& operator=(const Iterator& itr);
-
- bool operator!=(const Iterator& itr) const;
- bool operator==(const Iterator& itr) const;
-
- bool operator<(const Iterator& itr) const;
- bool operator>(const Iterator& itr) const;
-
- bool operator<=(const Iterator& itr) const;
- bool operator>=(const Iterator& itr) const;
-
- uint8_t operator*() const;
- uint8_t operator->() const;
-
- size_t NumBytesRemaining() const;
-
- // Get the next sizeof(FixedWidthPODType) bytes and return the filled type
- template <typename FixedWidthPODType>
- FixedWidthPODType extract() {
- static_assert(std::is_pod<FixedWidthPODType>::value, "Iterator::extract requires an fixed type.");
- FixedWidthPODType extracted_value;
- uint8_t* value_ptr = (uint8_t*)&extracted_value;
-
- for (size_t i = 0; i < sizeof(FixedWidthPODType); i++) {
- size_t index = (little_endian ? i : sizeof(FixedWidthPODType) - i - 1);
- value_ptr[index] = *((*this)++);
- }
- return extracted_value;
- }
-
- private:
- std::forward_list<View> data_;
- size_t index_;
- size_t length_;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/packet_builder.h b/vendor_libs/test_vendor_lib/packets/packet_builder.h
deleted file mode 100644
index 44feac8..0000000
--- a/vendor_libs/test_vendor_lib/packets/packet_builder.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-
-#include <cstdint>
-#include <forward_list>
-#include <iterator>
-#include <memory>
-#include <vector>
-
-#include "base_packet_builder.h"
-#include "hci/address.h"
-#include "types/class_of_device.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-using ::bluetooth::hci::Address;
-
-// Abstract base class that is subclassed to build specifc packets.
-// The template parameter little_endian controls the generation of insert().
-template <bool little_endian>
-class PacketBuilder : public BasePacketBuilder {
- public:
- PacketBuilder() = default;
- virtual ~PacketBuilder() = default;
-
- // Classes which need fragmentation should define a function like this:
- // std::forward_list<DerivedBuilder>& Fragment(size_t max_size);
-
- protected:
- // Write sizeof(FixedWidthIntegerType) bytes using the iterator
- template <typename FixedWidthIntegerType,
- typename std::enable_if<std::is_integral<FixedWidthIntegerType>::value, int>::type = 0>
- void insert(FixedWidthIntegerType value, std::back_insert_iterator<std::vector<uint8_t>> it) const {
- for (size_t i = 0; i < sizeof(FixedWidthIntegerType); i++) {
- if (little_endian == true) {
- *it = static_cast<uint8_t>(value >> (i * 8));
- } else {
- *it = static_cast<uint8_t>(value >> ((sizeof(FixedWidthIntegerType) - i - 1) * 8));
- }
- it++;
- }
- }
-
- // Specialized insert that allows inserting enums without casting
- template <typename Enum, typename std::enable_if<std::is_enum_v<Enum>, int>::type = 0>
- inline void insert(Enum value, std::back_insert_iterator<std::vector<uint8_t>> it) const {
- using enum_type = typename std::underlying_type_t<Enum>;
- static_assert(std::is_unsigned_v<enum_type>, "Enum type is signed. Did you forget to specify the enum size?");
- insert<enum_type>(static_cast<enum_type>(value), it);
- }
-
- // Write a vector of FixedWidthIntegerType using the iterator
- template <typename FixedWidthIntegerType>
- void insert_vector(const std::vector<FixedWidthIntegerType>& vec,
- std::back_insert_iterator<std::vector<uint8_t>> it) const {
- static_assert(std::is_integral<FixedWidthIntegerType>::value,
- "PacketBuilder::insert requires an integral type vector.");
- for (const auto& element : vec) {
- insert(element, it);
- }
- }
-
- void insert_address(const Address& addr, std::back_insert_iterator<std::vector<uint8_t>> it) const {
- for (const auto& element : addr.address) {
- insert(element, it);
- }
- }
-
- void insert_class_of_device(const ClassOfDevice& cod, std::back_insert_iterator<std::vector<uint8_t>> it) const {
- for (const auto& element : cod.cod) {
- insert(element, it);
- }
- }
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/packet_view.cc b/vendor_libs/test_vendor_lib/packets/packet_view.cc
deleted file mode 100644
index 65cd4e7..0000000
--- a/vendor_libs/test_vendor_lib/packets/packet_view.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2018 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 "packet_view.h"
-
-#include <algorithm>
-
-#include "os/log.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-template <bool little_endian>
-PacketView<little_endian>::PacketView(const std::forward_list<class View> fragments)
- : fragments_(fragments), length_(0) {
- for (auto fragment : fragments_) {
- length_ += fragment.size();
- }
-}
-
-template <bool little_endian>
-PacketView<little_endian>::PacketView(std::shared_ptr<std::vector<uint8_t>> packet)
- : fragments_({View(packet, 0, packet->size())}), length_(packet->size()) {}
-
-template <bool little_endian>
-Iterator<little_endian> PacketView<little_endian>::begin() const {
- return Iterator<little_endian>(this->fragments_, 0);
-}
-
-template <bool little_endian>
-Iterator<little_endian> PacketView<little_endian>::end() const {
- return Iterator<little_endian>(this->fragments_, size());
-}
-
-template <bool little_endian>
-uint8_t PacketView<little_endian>::operator[](size_t index) const {
- return at(index);
-}
-
-template <bool little_endian>
-uint8_t PacketView<little_endian>::at(size_t index) const {
- ASSERT_LOG(index < length_, "Index %d out of bounds", static_cast<int>(index));
- for (const auto& fragment : fragments_) {
- if (index < fragment.size()) {
- return fragment[index];
- }
- index -= fragment.size();
- }
- LOG_ALWAYS_FATAL("Out of fragments searching for Index %d", static_cast<int>(index));
- return 0;
-}
-
-template <bool little_endian>
-size_t PacketView<little_endian>::size() const {
- return length_;
-}
-
-template <bool little_endian>
-std::forward_list<View> PacketView<little_endian>::SubViewList(size_t begin, size_t end) const {
- ASSERT_LOG(begin <= end, "Begin %d is past end %d", static_cast<int>(begin), static_cast<int>(end));
- ASSERT_LOG(end <= length_, "End %d is too large", static_cast<int>(end));
- std::forward_list<View> view_list;
- std::forward_list<View>::iterator it = view_list.before_begin();
- size_t length = end - begin;
- for (const auto& fragment : fragments_) {
- if (begin >= fragment.size()) {
- begin -= fragment.size();
- } else {
- View view(fragment, begin, begin + std::min(length, fragment.size() - begin));
- length -= view.size();
- it = view_list.insert_after(it, view);
- begin = 0;
- }
- }
- return view_list;
-}
-
-template <bool little_endian>
-PacketView<true> PacketView<little_endian>::SubViewLittleEndian(size_t begin, size_t end) const {
- return PacketView<true>(SubViewList(begin, end));
-}
-
-template <bool little_endian>
-PacketView<false> PacketView<little_endian>::SubViewBigEndian(size_t begin, size_t end) const {
- return PacketView<false>(SubViewList(begin, end));
-}
-
-// Explicit instantiations for both types of PacketViews.
-template class PacketView<true>;
-template class PacketView<false>;
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/packet_view.h b/vendor_libs/test_vendor_lib/packets/packet_view.h
deleted file mode 100644
index 22c530a..0000000
--- a/vendor_libs/test_vendor_lib/packets/packet_view.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-
-#include <cstdint>
-#include <forward_list>
-
-#include "iterator.h"
-#include "view.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-// Abstract base class that is subclassed to provide type-specifc accessors.
-// Holds a shared pointer to the underlying data.
-// The template parameter little_endian controls the generation of extract().
-template <bool little_endian>
-class PacketView {
- public:
- PacketView(const std::forward_list<class View> fragments);
- PacketView(std::shared_ptr<std::vector<uint8_t>> packet);
- PacketView(const PacketView& PacketView) = default;
- virtual ~PacketView() = default;
-
- virtual Iterator<little_endian> begin() const;
-
- virtual Iterator<little_endian> end() const;
-
- uint8_t operator[](size_t i) const;
-
- uint8_t at(size_t index) const;
-
- size_t size() const;
-
- PacketView<true> SubViewLittleEndian(size_t begin, size_t end) const;
-
- PacketView<false> SubViewBigEndian(size_t begin, size_t end) const;
-
- private:
- std::forward_list<View> fragments_;
- size_t length_;
- PacketView<little_endian>() = delete;
- std::forward_list<View> SubViewList(size_t begin, size_t end) const;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/raw_builder.cc b/vendor_libs/test_vendor_lib/packets/raw_builder.cc
deleted file mode 100644
index 2ba2198..0000000
--- a/vendor_libs/test_vendor_lib/packets/raw_builder.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2018 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 "raw_builder.h"
-
-#include <algorithm>
-
-using std::vector;
-
-namespace test_vendor_lib {
-namespace packets {
-
-RawBuilder::RawBuilder(size_t max_bytes) : max_bytes_(max_bytes) {}
-
-bool RawBuilder::AddOctets(size_t octets, const vector<uint8_t>& bytes) {
- if (payload_.size() + octets > max_bytes_) return false;
-
- if (octets != bytes.size()) return false;
-
- payload_.insert(payload_.end(), bytes.begin(), bytes.end());
-
- return true;
-}
-
-bool RawBuilder::AddOctets(const vector<uint8_t>& bytes) {
- return AddOctets(bytes.size(), bytes);
-}
-
-bool RawBuilder::AddOctets(size_t octets, uint64_t value) {
- vector<uint8_t> val_vector;
-
- uint64_t v = value;
-
- if (octets > sizeof(uint64_t)) return false;
-
- for (size_t i = 0; i < octets; i++) {
- val_vector.push_back(v & 0xff);
- v = v >> 8;
- }
-
- if (v != 0) return false;
-
- return AddOctets(octets, val_vector);
-}
-
-bool RawBuilder::AddAddress(const Address& address) {
- if (payload_.size() + Address::kLength > max_bytes_) return false;
-
- for (size_t i = 0; i < Address::kLength; i++) {
- payload_.push_back(address.address[i]);
- }
- return true;
-}
-
-bool RawBuilder::AddOctets1(uint8_t value) {
- return AddOctets(1, value);
-}
-
-bool RawBuilder::AddOctets2(uint16_t value) {
- return AddOctets(2, value);
-}
-
-bool RawBuilder::AddOctets3(uint32_t value) {
- return AddOctets(3, value);
-}
-
-bool RawBuilder::AddOctets4(uint32_t value) {
- return AddOctets(4, value);
-}
-
-bool RawBuilder::AddOctets6(uint64_t value) {
- return AddOctets(6, value);
-}
-
-bool RawBuilder::AddOctets8(uint64_t value) {
- return AddOctets(8, value);
-}
-
-bool RawBuilder::CanAddOctets(size_t num_bytes) const {
- return payload_.size() + num_bytes <= max_bytes_;
-}
-
-void RawBuilder::Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const {
- for (const auto& val : payload_) {
- insert(val, it);
- }
-}
-
-size_t RawBuilder::size() const {
- return payload_.size();
-}
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/raw_builder.h b/vendor_libs/test_vendor_lib/packets/raw_builder.h
deleted file mode 100644
index 82ba885..0000000
--- a/vendor_libs/test_vendor_lib/packets/raw_builder.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-
-#include <cstdint>
-#include <vector>
-
-#include "hci/address.h"
-#include "packets/packet_builder.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-using ::bluetooth::hci::Address;
-
-class RawBuilder : public PacketBuilder<true> {
- public:
- RawBuilder() = default;
- RawBuilder(size_t max_bytes);
- virtual ~RawBuilder() = default;
-
- virtual size_t size() const override;
-
- virtual void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const;
-
- // Add |address| to the payload. Return true if:
- // - the new size of the payload is still <= |max_bytes_|
- bool AddAddress(const Address& address);
-
- // Return true if |num_bytes| can be added to the payload.
- bool CanAddOctets(size_t num_bytes) const;
-
- // Add |octets| bytes to the payload. Return true if:
- // - the size of |bytes| is equal to |octets| and
- // - the new size of the payload is still <= |max_bytes_|
- bool AddOctets(size_t octets, const std::vector<uint8_t>& bytes);
-
- bool AddOctets(const std::vector<uint8_t>& bytes);
-
- bool AddOctets1(uint8_t value);
- bool AddOctets2(uint16_t value);
- bool AddOctets3(uint32_t value);
- bool AddOctets4(uint32_t value);
- bool AddOctets6(uint64_t value);
- bool AddOctets8(uint64_t value);
-
- private:
- // Add |octets| bytes to the payload. Return true if:
- // - the value of |value| fits in |octets| bytes and
- // - the new size of the payload is still <= |max_bytes_|
- bool AddOctets(size_t octets, uint64_t value);
-
- size_t max_bytes_{255};
-
- // Underlying containers for storing the actual packet
- std::vector<uint8_t> payload_;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/test/counted_builder_test.cc b/vendor_libs/test_vendor_lib/packets/test/counted_builder_test.cc
deleted file mode 100644
index c91466b..0000000
--- a/vendor_libs/test_vendor_lib/packets/test/counted_builder_test.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2018 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 "packets/counted_builder.h"
-
-#include <gtest/gtest.h>
-#include <forward_list>
-#include <memory>
-
-#include "hci/address.h"
-
-using ::bluetooth::hci::Address;
-using std::vector;
-
-namespace {
-vector<uint8_t> count = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-
-} // namespace
-
-namespace test_vendor_lib {
-namespace packets {
-
-class CountedBuilderTest : public ::testing::Test {
- public:
- CountedBuilderTest() = default;
- ~CountedBuilderTest() override = default;
-};
-
-TEST(CountedBuilderTest, buildCountTest) {
- std::unique_ptr<CountedBuilder> count_builder = std::make_unique<CountedBuilder>();
- ASSERT_EQ(1u, count_builder->size());
- std::unique_ptr<RawBuilder> raw1 = std::make_unique<RawBuilder>();
- std::unique_ptr<RawBuilder> raw2 = std::make_unique<RawBuilder>();
- std::unique_ptr<RawBuilder> raw3 = std::make_unique<RawBuilder>();
- std::unique_ptr<RawBuilder> raw4 = std::make_unique<RawBuilder>();
- std::unique_ptr<RawBuilder> raw5 = std::make_unique<RawBuilder>();
- std::unique_ptr<RawBuilder> raw6 = std::make_unique<RawBuilder>();
- std::unique_ptr<RawBuilder> raw7 = std::make_unique<RawBuilder>();
- raw1->AddOctets8(0x0706050403020100);
- raw2->AddOctets4(0x0b0a0908);
- raw3->AddOctets2(0x0d0c);
- raw4->AddOctets1(0x0e);
- raw5->AddOctets1(0x0f);
- raw6->AddAddress(Address({0x10, 0x11, 0x12, 0x13, 0x14, 0x15}));
- std::vector<uint8_t> count_subset(count.begin() + 0x16, count.end());
- raw7->AddOctets(count_subset);
-
- count_builder->Add(std::move(raw1));
- count_builder->Add(std::move(raw2));
- count_builder->Add(std::move(raw3));
- count_builder->Add(std::move(raw4));
- count_builder->Add(std::move(raw5));
- count_builder->Add(std::move(raw6));
- count_builder->Add(std::move(raw7));
-
- ASSERT_EQ(count.size(), count_builder->size() - 1);
-
- std::vector<uint8_t> packet;
- std::back_insert_iterator<std::vector<uint8_t>> it(packet);
-
- count_builder->Serialize(it);
- ASSERT_EQ(7u, packet[0]);
- std::vector<uint8_t> payload_packet(packet.begin() + 1, packet.end());
-
- ASSERT_EQ(count, payload_packet);
-}
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/test/packet_builder_test.cc b/vendor_libs/test_vendor_lib/packets/test/packet_builder_test.cc
deleted file mode 100644
index a2b3569..0000000
--- a/vendor_libs/test_vendor_lib/packets/test/packet_builder_test.cc
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2018 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 "packets/packet_builder.h"
-
-#include <gtest/gtest.h>
-#include <forward_list>
-#include <memory>
-
-using std::vector;
-
-namespace {
-vector<uint8_t> count_all = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-
-vector<uint8_t> count_1 = {
- 0x00,
- 0x01,
- 0x02,
-};
-
-vector<uint8_t> count_2 = {
- 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
-};
-
-vector<uint8_t> count_3 = {
- 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-} // namespace
-
-namespace test_vendor_lib {
-namespace packets {
-
-template <bool little_endian>
-class EndianBuilder : public PacketBuilder<little_endian> {
- public:
- EndianBuilder(uint8_t byte, uint16_t two_bytes, uint32_t four_bytes, uint64_t eight_bytes)
- : byte_(byte), two_bytes_(two_bytes), four_bytes_(four_bytes), eight_bytes_(eight_bytes) {}
- ~EndianBuilder() override = default;
-
- size_t size() const override {
- return sizeof(signature_) + sizeof(byte_) + sizeof(two_bytes_) + sizeof(four_bytes_) + sizeof(eight_bytes_);
- }
-
- virtual const std::unique_ptr<std::vector<uint8_t>> FinalPacket() {
- std::unique_ptr<std::vector<uint8_t>> packet = std::make_unique<std::vector<uint8_t>>();
- packet->reserve(size());
- std::back_insert_iterator<std::vector<uint8_t>> it(*packet);
- Serialize(it);
- return packet;
- }
-
- void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
- PacketBuilder<little_endian>::insert(signature_, it);
- PacketBuilder<little_endian>::insert(byte_, it);
- PacketBuilder<little_endian>::insert(two_bytes_, it);
- PacketBuilder<little_endian>::insert(four_bytes_, it);
- PacketBuilder<little_endian>::insert(eight_bytes_, it);
- }
-
- private:
- uint32_t signature_{(little_endian ? 0x03020100 : 0x00010203)};
- uint8_t byte_;
- uint16_t two_bytes_;
- uint32_t four_bytes_;
- uint64_t eight_bytes_;
-};
-
-class PacketBuilderEndianTest : public ::testing::Test {
- public:
- PacketBuilderEndianTest() = default;
- ~PacketBuilderEndianTest() override = default;
-};
-
-TEST(PacketBuilderEndianTest, insertTest) {
- EndianBuilder<true> little(0x04, 0x0605, 0x0a090807, 0x1211100f0e0d0c0b);
- EndianBuilder<false> big(0x04, 0x0506, 0x0708090a, 0x0b0c0d0e0f101112);
- ASSERT_EQ(*big.FinalPacket(), *little.FinalPacket());
-}
-
-template <typename T>
-class VectorBuilder : public PacketBuilder<true> {
- public:
- VectorBuilder(std::vector<uint64_t> vect) {
- for (uint64_t element : vect) {
- vect.push_back(static_cast<T>(element));
- }
- }
- ~VectorBuilder() override = default;
-
- size_t size() const override {
- return vect_.size() * sizeof(T);
- }
-
- virtual const std::unique_ptr<std::vector<uint8_t>> FinalPacket() {
- std::unique_ptr<std::vector<uint8_t>> packet = std::make_unique<std::vector<uint8_t>>();
- packet->reserve(size());
- std::back_insert_iterator<std::vector<uint8_t>> it(*packet);
- Serialize(it);
- return packet;
- }
-
- void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
- PacketBuilder<true>::insert_vector(vect_, it);
- }
-
- private:
- std::vector<T> vect_;
-};
-
-template <typename T>
-class InsertElementsBuilder : public PacketBuilder<true> {
- public:
- InsertElementsBuilder(std::vector<uint64_t> vect) {
- for (uint64_t element : vect) {
- vect.push_back(static_cast<T>(element));
- }
- }
- ~InsertElementsBuilder() override = default;
-
- size_t size() const override {
- return vect_.size() * sizeof(T);
- }
-
- virtual const std::unique_ptr<std::vector<uint8_t>> FinalPacket() {
- std::unique_ptr<std::vector<uint8_t>> packet = std::make_unique<std::vector<uint8_t>>();
- packet->reserve(size());
- std::back_insert_iterator<std::vector<uint8_t>> it(*packet);
- Serialize(it);
- return packet;
- }
-
- void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
- for (T elem : vect_) {
- PacketBuilder<true>::insert(elem, it);
- }
- }
-
- private:
- std::vector<T> vect_;
-};
-
-std::vector<uint64_t> vector_data{
- 0x7060504030201000, 0x7161514131211101, 0x7262524232221202, 0x7363534333231303, 0x7464544434241404,
- 0x7565554535251505, 0x7666564636261606, 0x7767574737271707, 0x7868584838281808,
-};
-
-template <typename T>
-class VectorBuilderTest : public ::testing::Test {
- public:
- VectorBuilderTest() = default;
- ~VectorBuilderTest() override = default;
-
- void SetUp() override {
- packet_1_ = std::shared_ptr<VectorBuilder<T>>(new VectorBuilder<T>(vector_data));
- packet_2_ = std::shared_ptr<InsertElementsBuilder<T>>(new InsertElementsBuilder<T>(vector_data));
- }
-
- void TearDown() override {
- packet_1_.reset();
- packet_2_.reset();
- }
-
- std::shared_ptr<VectorBuilder<T>> packet_1_;
- std::shared_ptr<InsertElementsBuilder<T>> packet_2_;
-};
-
-using VectorBaseTypes = ::testing::Types<uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t>;
-TYPED_TEST_CASE(VectorBuilderTest, VectorBaseTypes);
-
-TYPED_TEST(VectorBuilderTest, insertVectorTest) {
- ASSERT_EQ(*(this->packet_1_->FinalPacket()), *(this->packet_2_->FinalPacket()));
-}
-
-class NestedBuilder : public PacketBuilder<true> {
- public:
- ~NestedBuilder() override = default;
-
- size_t size() const override {
- size_t payload_size = (payload_ ? payload_->size() : 0);
- return 1 + payload_size;
- }
-
- static std::unique_ptr<NestedBuilder> Create(uint8_t level) {
- return std::unique_ptr<NestedBuilder>(new NestedBuilder(level));
- }
-
- static std::unique_ptr<NestedBuilder> CreateNested(std::unique_ptr<BasePacketBuilder> payload, uint8_t level) {
- return std::unique_ptr<NestedBuilder>(new NestedBuilder(std::move(payload), level));
- }
-
- virtual const std::unique_ptr<std::vector<uint8_t>> FinalPacket() {
- std::unique_ptr<std::vector<uint8_t>> packet = std::make_unique<std::vector<uint8_t>>();
- packet->reserve(size());
- std::back_insert_iterator<std::vector<uint8_t>> it(*packet);
- Serialize(it);
- return packet;
- }
-
- void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
- PacketBuilder<true>::insert(level_, it);
- if (payload_) {
- payload_->Serialize(it);
- }
- }
-
- private:
- std::unique_ptr<BasePacketBuilder> payload_;
- uint8_t level_;
-
- NestedBuilder(std::unique_ptr<BasePacketBuilder> inner, uint8_t level) : payload_(std::move(inner)), level_(level) {}
- NestedBuilder(uint8_t level) : level_(level) {}
-};
-
-class BuilderBuilderTest : public ::testing::Test {};
-
-TEST(BuilderBuilderTest, nestingTest) {
- std::unique_ptr<BasePacketBuilder> innermost = NestedBuilder::Create(0);
- std::unique_ptr<BasePacketBuilder> number_1 = NestedBuilder::CreateNested(std::move(innermost), 1);
- std::unique_ptr<BasePacketBuilder> number_2 = NestedBuilder::CreateNested(std::move(number_1), 2);
- std::unique_ptr<BasePacketBuilder> number_3 = NestedBuilder::CreateNested(std::move(number_2), 3);
- std::unique_ptr<BasePacketBuilder> number_4 = NestedBuilder::CreateNested(std::move(number_3), 4);
- std::unique_ptr<NestedBuilder> number_5 = NestedBuilder::CreateNested(std::move(number_4), 5);
-
- std::vector<uint8_t> count_down{5, 4, 3, 2, 1, 0};
- ASSERT_EQ(*number_5->FinalPacket(), count_down);
-}
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/test/packet_view_test.cc b/vendor_libs/test_vendor_lib/packets/test/packet_view_test.cc
deleted file mode 100644
index 11891c6..0000000
--- a/vendor_libs/test_vendor_lib/packets/test/packet_view_test.cc
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Copyright 2018 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 "packets/packet_view.h"
-
-#include <gtest/gtest.h>
-#include <forward_list>
-#include <memory>
-
-#include "hci/address.h"
-
-using ::bluetooth::hci::Address;
-using std::vector;
-
-namespace {
-vector<uint8_t> count_all = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-
-vector<uint8_t> count_1 = {
- 0x00,
- 0x01,
- 0x02,
-};
-
-vector<uint8_t> count_2 = {
- 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
-};
-
-vector<uint8_t> count_3 = {
- 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-} // namespace
-
-namespace test_vendor_lib {
-namespace packets {
-
-template <typename T>
-class IteratorTest : public ::testing::Test {
- public:
- IteratorTest() = default;
- ~IteratorTest() override = default;
-
- void SetUp() override {
- packet = std::shared_ptr<T>(new T({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())}));
- }
-
- void TearDown() override {
- packet.reset();
- }
-
- std::shared_ptr<T> packet;
-};
-
-using PacketViewTypes = ::testing::Types<PacketView<true>, PacketView<false>>;
-TYPED_TEST_CASE(IteratorTest, PacketViewTypes);
-
-class IteratorExtractTest : public ::testing::Test {
- public:
- IteratorExtractTest() = default;
- ~IteratorExtractTest() override = default;
-};
-
-template <typename T>
-class PacketViewTest : public IteratorTest<T> {
- public:
- PacketViewTest() = default;
- ~PacketViewTest() override = default;
-};
-
-using PacketViewTypes = ::testing::Types<PacketView<true>, PacketView<false>>;
-TYPED_TEST_CASE(PacketViewTest, PacketViewTypes);
-
-class PacketViewMultiViewTest : public ::testing::Test {
- public:
- PacketViewMultiViewTest() = default;
- ~PacketViewMultiViewTest() override = default;
-};
-
-class ViewTest : public ::testing::Test {
- public:
- ViewTest() = default;
- ~ViewTest() override = default;
-};
-
-TEST(IteratorExtractTest, extractLeTest) {
- PacketView<true> packet({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- auto general_case = packet.begin();
-
- ASSERT_EQ(0x00, general_case.extract<uint8_t>());
- ASSERT_EQ(0x0201, general_case.extract<uint16_t>());
- ASSERT_EQ(0x06050403u, general_case.extract<uint32_t>());
- ASSERT_EQ(0x0e0d0c0b0a090807u, general_case.extract<uint64_t>());
- ASSERT_EQ(0x0f, general_case.extract<uint8_t>());
- Address raw({0x10, 0x11, 0x12, 0x13, 0x14, 0x15});
- ASSERT_EQ(raw, general_case.extract<Address>());
- ASSERT_EQ(0x16, general_case.extract<uint8_t>());
-}
-
-TEST(IteratorExtractTest, extractBeTest) {
- PacketView<false> packet({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- auto general_case = packet.begin();
-
- ASSERT_EQ(0x00, general_case.extract<uint8_t>());
- ASSERT_EQ(0x0102, general_case.extract<uint16_t>());
- ASSERT_EQ(0x03040506u, general_case.extract<uint32_t>());
- ASSERT_EQ(0x0708090a0b0c0d0eu, general_case.extract<uint64_t>());
- ASSERT_EQ(0x0f, general_case.extract<uint8_t>());
- Address raw({0x15, 0x14, 0x13, 0x12, 0x11, 0x10});
- ASSERT_EQ(raw, general_case.extract<Address>());
- ASSERT_EQ(0x16, general_case.extract<uint8_t>());
-}
-
-TYPED_TEST(IteratorTest, extractBoundsDeathTest) {
- auto bounds_test = this->packet->end();
-
- ASSERT_DEATH(bounds_test.template extract<uint8_t>(), "");
- ASSERT_DEATH(bounds_test.template extract<uint16_t>(), "");
- ASSERT_DEATH(bounds_test.template extract<uint32_t>(), "");
- ASSERT_DEATH(bounds_test.template extract<uint64_t>(), "");
-}
-
-TYPED_TEST(IteratorTest, dereferenceDeathTest) {
- auto dereference_test = this->packet->end();
-
- ASSERT_DEATH(*dereference_test, "");
- ASSERT_EQ(0x1f, *(dereference_test - 1));
-}
-
-TYPED_TEST(IteratorTest, plusEqTest) {
- auto plus_eq = this->packet->begin();
- for (size_t i = 0; i < count_all.size(); i += 2) {
- ASSERT_EQ(count_all[i], *plus_eq) << "+= test: Dereferenced iterator does not equal expected at index " << i;
- plus_eq += 2;
- }
-}
-
-TYPED_TEST(IteratorTest, preIncrementTest) {
- auto plus_plus = this->packet->begin();
- for (size_t i = 0; i < count_all.size() - 1; i++) {
- ASSERT_EQ(count_all[i + 1], *(++plus_plus)) << "Pre-increment test: Dereferenced iterator does not equal expected "
- << "at index " << i;
- }
-}
-
-TYPED_TEST(IteratorTest, postIncrementTest) {
- auto plus_plus = this->packet->begin();
- for (size_t i = 0; i < count_all.size(); i++) {
- ASSERT_EQ(count_all[i], *(plus_plus++)) << "Post-increment test: Dereferenced iterator does not equal expected "
- << "at index " << i;
- }
-}
-
-TYPED_TEST(IteratorTest, additionTest) {
- auto plus = this->packet->begin();
- for (size_t i = 0; i < count_all.size(); i++) {
- ASSERT_EQ(count_all[i], *plus) << "+ test: Dereferenced iterator does not equal expected at index " << i;
- plus = plus + 1;
- }
-}
-
-TYPED_TEST(IteratorTest, minusEqTest) {
- auto minus_eq = this->packet->end();
- minus_eq -= 1;
- size_t index = count_all.size() - 1;
- for (size_t i = 0; index > i; i++) {
- ASSERT_EQ(count_all[index], *minus_eq)
- << "-= test: Dereferenced iterator does not equal expected at index " << index;
- index -= i;
- minus_eq -= i;
- }
-}
-
-TYPED_TEST(IteratorTest, preDecrementTest) {
- auto minus_minus = this->packet->end();
- for (size_t i = count_all.size(); i > 0; i--) {
- ASSERT_EQ(count_all[i - 1], *(--minus_minus))
- << "Pre-decrement test: Dereferenced iterator does not equal expected "
- << "at index " << i;
- }
-}
-
-TYPED_TEST(IteratorTest, postDecrementTest) {
- auto minus_minus = this->packet->end();
- minus_minus--;
- for (size_t i = count_all.size() - 1; i > 0; i--) {
- ASSERT_EQ(count_all[i], *(minus_minus--)) << "Post-decrement test: Dereferenced iterator does not equal expected "
- << "at index " << i;
- }
-}
-
-TYPED_TEST(IteratorTest, subtractionTest) {
- auto minus = this->packet->end();
- minus = minus - 1;
- for (size_t i = count_all.size() - 1; i > 0; i--) {
- ASSERT_EQ(count_all[i], *minus) << "- test: Dereferenced iterator does not equal expected at index " << i;
- minus = minus - 1;
- }
-}
-
-TYPED_TEST(IteratorTest, differenceTest) {
- auto begin = this->packet->begin();
- auto end = this->packet->end();
- int difference = end - begin;
- ASSERT_EQ(difference, static_cast<int>(count_all.size()));
- int neg_difference = begin - end;
- ASSERT_EQ(neg_difference, -static_cast<int>(count_all.size()));
-}
-
-TYPED_TEST(IteratorTest, equalityTest) {
- auto begin = this->packet->begin();
- auto end = this->packet->end();
- auto begin_copy = this->packet->begin();
- auto end_copy = this->packet->end();
- ASSERT_EQ(begin_copy, begin);
- ASSERT_EQ(end_copy, end);
-}
-
-TYPED_TEST(IteratorTest, comparisonsTest) {
- auto begin = this->packet->begin();
- auto end = this->packet->end();
- auto begin_copy = this->packet->begin();
- auto end_copy = this->packet->end();
- ASSERT_EQ(begin_copy, begin);
- ASSERT_EQ(end_copy, end);
- ASSERT_NE(begin, end);
- ASSERT_TRUE(begin < end);
- ASSERT_FALSE(end < end);
- ASSERT_FALSE(end < begin);
- ASSERT_FALSE(begin > end);
- ASSERT_FALSE(end > end);
- ASSERT_TRUE(end > begin);
- ASSERT_TRUE(begin <= end);
- ASSERT_TRUE(end <= end);
- ASSERT_FALSE(end <= begin);
- ASSERT_FALSE(begin >= end);
- ASSERT_TRUE(end >= end);
- ASSERT_TRUE(end >= begin);
-}
-
-TYPED_TEST(PacketViewTest, getLengthTest) {
- size_t length = this->packet->size();
- ASSERT_EQ(length, count_all.size());
-}
-
-TYPED_TEST(PacketViewTest, getAtIndexTest) {
- size_t past_end = this->packet->size();
- ASSERT_DEATH(this->packet->at(past_end), "");
- size_t working_index = 0x1f;
- ASSERT_EQ(0x1f, this->packet->at(working_index));
-}
-
-TYPED_TEST(PacketViewTest, arrayOperatorTest) {
- size_t past_end = this->packet->size();
- ASSERT_DEATH((*(this->packet))[past_end], "");
- size_t working_index = 0x1f;
- ASSERT_EQ(0x1f, (*(this->packet))[working_index]);
-}
-
-TYPED_TEST(PacketViewTest, numBytesRemainingTest) {
- auto all = this->packet->begin();
- size_t remaining = all.NumBytesRemaining();
- for (size_t n = remaining; n > 0; n--) {
- ASSERT_EQ(remaining, all.NumBytesRemaining());
- all++;
- remaining--;
- }
- ASSERT_EQ(static_cast<size_t>(0), all.NumBytesRemaining());
- ASSERT_DEATH(*(all++), "");
- all++;
- ASSERT_EQ(static_cast<size_t>(0), all.NumBytesRemaining());
- ASSERT_DEATH(*(all++), "");
-}
-
-using SubViewTestParam = std::pair<size_t, size_t>;
-class SubViewBaseTest : public ::testing::TestWithParam<SubViewTestParam> {
- public:
- class SubPacketView : public PacketView<true> {
- public:
- using PacketView<true>::PacketView;
- PacketView<true> Slice(size_t header, size_t tail) {
- return PacketView<true>::SubViewLittleEndian(header, tail);
- }
- };
-};
-
-class SubViewPassTest : public SubViewBaseTest {};
-
-TEST_P(SubViewPassTest, subViewTest) {
- auto header = GetParam().first;
- auto tail = GetParam().second;
- SubPacketView single_view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- SubPacketView multi_view({
- View(std::make_shared<const vector<uint8_t>>(count_1), 0, count_1.size()),
- View(std::make_shared<const vector<uint8_t>>(count_2), 0, count_2.size()),
- View(std::make_shared<const vector<uint8_t>>(count_3), 0, count_3.size()),
- });
-
- auto single_slice = single_view.Slice(header, tail);
- auto multi_slice = multi_view.Slice(header, tail);
-
- ASSERT_EQ(single_slice.size(), tail - header);
- ASSERT_EQ(single_slice.size(), multi_slice.size());
- for (size_t i = 0; i < single_slice.size(); i++) {
- ASSERT_EQ(single_slice[i], multi_slice[i]);
- }
-}
-
-static const size_t boundary_1 = count_1.size();
-static const size_t boundary_2 = count_1.size() + count_2.size();
-
-INSTANTIATE_TEST_CASE_P(
- chopomatic, SubViewPassTest,
- ::testing::Values(
- // {begin, end} pairs for subsets into the PacketView
- SubViewTestParam{0, 0}, SubViewTestParam{0, boundary_1}, SubViewTestParam{0, boundary_1 + 1},
- SubViewTestParam{0, boundary_2}, SubViewTestParam{0, boundary_2 + 1}, SubViewTestParam{0, count_all.size()},
- SubViewTestParam{boundary_1 - 1, boundary_1}, SubViewTestParam{boundary_1 - 1, boundary_1 + 1},
- SubViewTestParam{boundary_1 - 1, boundary_2}, SubViewTestParam{boundary_1 - 1, boundary_2 + 1},
- SubViewTestParam{boundary_1 - 1, count_all.size()}, SubViewTestParam{boundary_1, boundary_1},
- SubViewTestParam{boundary_1, boundary_2}, SubViewTestParam{boundary_1, boundary_2 + 1},
- SubViewTestParam{boundary_1, count_all.size()}, SubViewTestParam{boundary_2 - 1, boundary_2},
- SubViewTestParam{boundary_2 - 1, boundary_2 + 1}, SubViewTestParam{boundary_2 - 1, count_all.size()},
- SubViewTestParam{boundary_2, boundary_2}, SubViewTestParam{boundary_2, boundary_2 + 1},
- SubViewTestParam{boundary_2, count_all.size()}, SubViewTestParam{count_all.size() - 1, count_all.size()},
- SubViewTestParam{count_all.size(), count_all.size()}));
-
-class SubViewDeathTest : public SubViewBaseTest {};
-
-TEST_P(SubViewDeathTest, subViewDeathTest) {
- auto header = GetParam().first;
- auto tail = GetParam().second;
- SubPacketView single_view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- SubPacketView multi_view({
- View(std::make_shared<const vector<uint8_t>>(count_1), 0, count_1.size()),
- View(std::make_shared<const vector<uint8_t>>(count_2), 0, count_2.size()),
- View(std::make_shared<const vector<uint8_t>>(count_3), 0, count_3.size()),
- });
-
- ASSERT_DEATH(auto single_slice = single_view.Slice(header, tail), "");
- ASSERT_DEATH(auto multi_slice = multi_view.Slice(header, tail), "");
-}
-
-INSTANTIATE_TEST_CASE_P(chopomaticDeath, SubViewDeathTest,
- ::testing::Values(
- // {begin, end} pairs for subsets into the PacketView
- SubViewTestParam{1, 0}, SubViewTestParam{count_all.size(), count_all.size() - 1},
- SubViewTestParam{count_all.size(), count_all.size() + 1}));
-
-TEST(SubViewTest, simpleSubViewTest) {
- PacketView<true> view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- PacketView<true> sub_1_view = view.SubViewLittleEndian(0, view.size());
- PacketView<true> sub_2_view = sub_1_view.SubViewLittleEndian(0, sub_1_view.size());
- PacketView<true> sub_3_view = sub_2_view.SubViewLittleEndian(0, sub_2_view.size());
- PacketView<true> sub_4_view = sub_3_view.SubViewLittleEndian(0, sub_3_view.size());
- ASSERT_EQ(sub_1_view.size(), view.size());
- ASSERT_EQ(sub_2_view.size(), view.size());
- ASSERT_EQ(sub_3_view.size(), view.size());
- ASSERT_EQ(sub_4_view.size(), view.size());
-}
-
-TEST(SubViewTest, realSubViewTest) {
- PacketView<true> view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- std::vector<PacketView<true>> sub_views{view};
- for (size_t i = 1; i < 6; i++) {
- size_t parent_size = sub_views[i - 1].size();
- sub_views.push_back(sub_views[i - 1].SubViewLittleEndian(1, parent_size - 1));
- ASSERT_EQ(sub_views[i][0], i);
- ASSERT_EQ(sub_views[i].size(), parent_size - 2);
- }
-}
-
-TEST(SubViewTest, subSubViewTest) {
- PacketView<true> single_view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- PacketView<true> multi_view({
- View(std::make_shared<const vector<uint8_t>>(count_1), 0, count_1.size()),
- View(std::make_shared<const vector<uint8_t>>(count_2), 0, count_2.size()),
- View(std::make_shared<const vector<uint8_t>>(count_3), 0, count_3.size()),
- });
- ASSERT_EQ(single_view.size(), multi_view.size());
- for (size_t i = 0; i < count_all.size() / 2; i++) {
- PacketView<true> sub_single_view = single_view.SubViewLittleEndian(i, count_all.size() - i);
- PacketView<true> sub_multi_view = multi_view.SubViewLittleEndian(i, count_all.size() - i);
- ASSERT_EQ(count_all.size() - 2 * i, sub_single_view.size());
- ASSERT_EQ(sub_single_view.size(), sub_multi_view.size());
- for (size_t j = 0; j < sub_single_view.size() / 2; j++) {
- PacketView<true> sub_sub_single_view = sub_single_view.SubViewLittleEndian(j, sub_single_view.size() - j);
- PacketView<true> sub_sub_multi_view = sub_multi_view.SubViewLittleEndian(j, sub_multi_view.size() - j);
- ASSERT_EQ(sub_single_view.size() - 2 * j, sub_sub_single_view.size());
- ASSERT_EQ(sub_sub_single_view.size(), sub_sub_multi_view.size());
- }
- }
-}
-
-TEST(PacketViewMultiViewTest, sizeTest) {
- PacketView<true> single_view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- PacketView<true> multi_view({
- View(std::make_shared<const vector<uint8_t>>(count_1), 0, count_1.size()),
- View(std::make_shared<const vector<uint8_t>>(count_2), 0, count_2.size()),
- View(std::make_shared<const vector<uint8_t>>(count_3), 0, count_3.size()),
- });
- ASSERT_EQ(single_view.size(), multi_view.size());
-}
-
-TEST(PacketViewMultiViewTest, dereferenceTestLittleEndian) {
- PacketView<true> single_view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- PacketView<true> multi_view({
- View(std::make_shared<const vector<uint8_t>>(count_1), 0, count_1.size()),
- View(std::make_shared<const vector<uint8_t>>(count_2), 0, count_2.size()),
- View(std::make_shared<const vector<uint8_t>>(count_3), 0, count_3.size()),
- });
- auto single_itr = single_view.begin();
- auto multi_itr = multi_view.begin();
- for (size_t i = 0; i < single_view.size(); i++) {
- ASSERT_EQ(*(single_itr++), *(multi_itr++));
- }
- ASSERT_DEATH(*multi_itr, "");
-}
-
-TEST(PacketViewMultiViewTest, dereferenceTestBigEndian) {
- PacketView<false> single_view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- PacketView<false> multi_view({
- View(std::make_shared<const vector<uint8_t>>(count_1), 0, count_1.size()),
- View(std::make_shared<const vector<uint8_t>>(count_2), 0, count_2.size()),
- View(std::make_shared<const vector<uint8_t>>(count_3), 0, count_3.size()),
- });
- auto single_itr = single_view.begin();
- auto multi_itr = multi_view.begin();
- for (size_t i = 0; i < single_view.size(); i++) {
- ASSERT_EQ(*(single_itr++), *(multi_itr++));
- }
- ASSERT_DEATH(*multi_itr, "");
-}
-
-TEST(PacketViewMultiViewTest, arrayOperatorTest) {
- PacketView<true> single_view({View(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size())});
- PacketView<true> multi_view({
- View(std::make_shared<const vector<uint8_t>>(count_1), 0, count_1.size()),
- View(std::make_shared<const vector<uint8_t>>(count_2), 0, count_2.size()),
- View(std::make_shared<const vector<uint8_t>>(count_3), 0, count_3.size()),
- });
- for (size_t i = 0; i < single_view.size(); i++) {
- ASSERT_EQ(single_view[i], multi_view[i]);
- }
- ASSERT_DEATH(multi_view[single_view.size()], "");
-}
-
-TEST(ViewTest, arrayOperatorTest) {
- View view_all(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size());
- size_t past_end = view_all.size();
- for (size_t i = 0; i < past_end; i++) {
- ASSERT_EQ(view_all[i], count_all[i]);
- }
- ASSERT_DEATH(view_all[past_end], "");
-
- size_t header_size = 2;
- size_t tail_size = 3;
- View view_subset(std::make_shared<const vector<uint8_t>>(count_all), header_size, count_all.size() - tail_size);
- View view_subset2(view_all, header_size, count_all.size() - tail_size);
- size_t subset_length = view_subset.size();
- for (size_t i = 0; i < subset_length; i++) {
- ASSERT_EQ(view_subset[i], count_all[header_size + i]);
- ASSERT_EQ(view_subset[i], view_subset2[i]);
- }
- ASSERT_DEATH(view_subset[subset_length + 1], "");
- ASSERT_DEATH(view_subset2[subset_length + 1], "");
-}
-
-TEST(ViewTest, earlySubSubViewTest) {
- View view(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size());
- View sub_1_view(view, view.size() - 3, view.size() - 1);
- View sub_2_view(sub_1_view, 1, 2);
- ASSERT_EQ(sub_1_view.size(), 2u);
- ASSERT_EQ(sub_2_view.size(), 1u);
-}
-
-TEST(ViewTest, subSubViewTest) {
- View view(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size());
- std::vector<View> sub_views{view};
- for (size_t i = 1; i < 6; i++) {
- size_t parent_size = sub_views[i - 1].size();
- sub_views.push_back({View(sub_views[i - 1], 1, parent_size - 1)});
- ASSERT_EQ(sub_views[i][0], i);
- ASSERT_EQ(sub_views[i].size(), parent_size - 2);
- }
-}
-
-TEST(ViewTest, zeroSubViewTest) {
- View view(std::make_shared<const vector<uint8_t>>(count_all), 0, count_all.size());
- View subview(view, view.size(), view.size() + 1);
- ASSERT_EQ(subview.size(), 0u);
-}
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/test/raw_builder_test.cc b/vendor_libs/test_vendor_lib/packets/test/raw_builder_test.cc
deleted file mode 100644
index 8e69f9f..0000000
--- a/vendor_libs/test_vendor_lib/packets/test/raw_builder_test.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2018 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 "packets/raw_builder.h"
-
-#include <gtest/gtest.h>
-#include <forward_list>
-#include <memory>
-
-#include "hci/address.h"
-
-using ::bluetooth::hci::Address;
-using std::vector;
-
-namespace {
-vector<uint8_t> count = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-
-} // namespace
-
-namespace test_vendor_lib {
-namespace packets {
-
-class RawBuilderTest : public ::testing::Test {
- public:
- RawBuilderTest() = default;
- ~RawBuilderTest() override = default;
-};
-
-TEST(RawBuilderTest, buildCountTest) {
- std::unique_ptr<RawBuilder> count_builder = std::make_unique<RawBuilder>();
- ASSERT_EQ(0u, count_builder->size());
- count_builder->AddOctets8(0x0706050403020100);
- count_builder->AddOctets4(0x0b0a0908);
- count_builder->AddOctets2(0x0d0c);
- count_builder->AddOctets1(0x0e);
- count_builder->AddOctets1(0x0f);
- count_builder->AddAddress(Address({0x10, 0x11, 0x12, 0x13, 0x14, 0x15}));
- std::vector<uint8_t> count_subset(count.begin() + 0x16, count.end());
- count_builder->AddOctets(count_subset);
-
- ASSERT_EQ(count.size(), count_builder->size());
-
- std::vector<uint8_t> packet;
- std::back_insert_iterator<std::vector<uint8_t>> it(packet);
-
- count_builder->Serialize(it);
-
- ASSERT_EQ(count, packet);
-}
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/view.cc b/vendor_libs/test_vendor_lib/packets/view.cc
deleted file mode 100644
index a358169..0000000
--- a/vendor_libs/test_vendor_lib/packets/view.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2018 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 "view.h"
-
-#include "os/log.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-View::View(std::shared_ptr<const std::vector<uint8_t>> data, size_t begin, size_t end)
- : data_(data), begin_(begin < data_->size() ? begin : data_->size()),
- end_(end < data_->size() ? end : data_->size()) {}
-
-View::View(const View& view, size_t begin, size_t end) : data_(view.data_) {
- begin_ = (begin < view.size() ? begin : view.size());
- begin_ += view.begin_;
- end_ = (end < view.size() ? end : view.size());
- end_ += view.begin_;
-}
-
-uint8_t View::operator[](size_t i) const {
- ASSERT_LOG(i + begin_ < end_, "Out of bounds access at %d", static_cast<int>(i));
- return data_->operator[](i + begin_);
-}
-
-size_t View::size() const {
- return end_ - begin_;
-}
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/view.h b/vendor_libs/test_vendor_lib/packets/view.h
deleted file mode 100644
index ca38875..0000000
--- a/vendor_libs/test_vendor_lib/packets/view.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2018 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.
- */
-
-#pragma once
-
-#include <cstdint>
-#include <vector>
-
-namespace test_vendor_lib {
-namespace packets {
-
-// Base class that holds a shared pointer to data with bounds.
-class View {
- public:
- View(std::shared_ptr<const std::vector<uint8_t>> data, size_t begin, size_t end);
- View(const View& view, size_t begin, size_t end);
- View(const View& view) = default;
- virtual ~View() = default;
-
- uint8_t operator[](size_t i) const;
-
- size_t size() const;
-
- private:
- std::shared_ptr<const std::vector<uint8_t>> data_;
- size_t begin_;
- size_t end_;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/test/packet_builder_test.cc b/vendor_libs/test_vendor_lib/test/packet_builder_test.cc
deleted file mode 100644
index a2b3569..0000000
--- a/vendor_libs/test_vendor_lib/test/packet_builder_test.cc
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2018 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 "packets/packet_builder.h"
-
-#include <gtest/gtest.h>
-#include <forward_list>
-#include <memory>
-
-using std::vector;
-
-namespace {
-vector<uint8_t> count_all = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-
-vector<uint8_t> count_1 = {
- 0x00,
- 0x01,
- 0x02,
-};
-
-vector<uint8_t> count_2 = {
- 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
-};
-
-vector<uint8_t> count_3 = {
- 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-} // namespace
-
-namespace test_vendor_lib {
-namespace packets {
-
-template <bool little_endian>
-class EndianBuilder : public PacketBuilder<little_endian> {
- public:
- EndianBuilder(uint8_t byte, uint16_t two_bytes, uint32_t four_bytes, uint64_t eight_bytes)
- : byte_(byte), two_bytes_(two_bytes), four_bytes_(four_bytes), eight_bytes_(eight_bytes) {}
- ~EndianBuilder() override = default;
-
- size_t size() const override {
- return sizeof(signature_) + sizeof(byte_) + sizeof(two_bytes_) + sizeof(four_bytes_) + sizeof(eight_bytes_);
- }
-
- virtual const std::unique_ptr<std::vector<uint8_t>> FinalPacket() {
- std::unique_ptr<std::vector<uint8_t>> packet = std::make_unique<std::vector<uint8_t>>();
- packet->reserve(size());
- std::back_insert_iterator<std::vector<uint8_t>> it(*packet);
- Serialize(it);
- return packet;
- }
-
- void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
- PacketBuilder<little_endian>::insert(signature_, it);
- PacketBuilder<little_endian>::insert(byte_, it);
- PacketBuilder<little_endian>::insert(two_bytes_, it);
- PacketBuilder<little_endian>::insert(four_bytes_, it);
- PacketBuilder<little_endian>::insert(eight_bytes_, it);
- }
-
- private:
- uint32_t signature_{(little_endian ? 0x03020100 : 0x00010203)};
- uint8_t byte_;
- uint16_t two_bytes_;
- uint32_t four_bytes_;
- uint64_t eight_bytes_;
-};
-
-class PacketBuilderEndianTest : public ::testing::Test {
- public:
- PacketBuilderEndianTest() = default;
- ~PacketBuilderEndianTest() override = default;
-};
-
-TEST(PacketBuilderEndianTest, insertTest) {
- EndianBuilder<true> little(0x04, 0x0605, 0x0a090807, 0x1211100f0e0d0c0b);
- EndianBuilder<false> big(0x04, 0x0506, 0x0708090a, 0x0b0c0d0e0f101112);
- ASSERT_EQ(*big.FinalPacket(), *little.FinalPacket());
-}
-
-template <typename T>
-class VectorBuilder : public PacketBuilder<true> {
- public:
- VectorBuilder(std::vector<uint64_t> vect) {
- for (uint64_t element : vect) {
- vect.push_back(static_cast<T>(element));
- }
- }
- ~VectorBuilder() override = default;
-
- size_t size() const override {
- return vect_.size() * sizeof(T);
- }
-
- virtual const std::unique_ptr<std::vector<uint8_t>> FinalPacket() {
- std::unique_ptr<std::vector<uint8_t>> packet = std::make_unique<std::vector<uint8_t>>();
- packet->reserve(size());
- std::back_insert_iterator<std::vector<uint8_t>> it(*packet);
- Serialize(it);
- return packet;
- }
-
- void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
- PacketBuilder<true>::insert_vector(vect_, it);
- }
-
- private:
- std::vector<T> vect_;
-};
-
-template <typename T>
-class InsertElementsBuilder : public PacketBuilder<true> {
- public:
- InsertElementsBuilder(std::vector<uint64_t> vect) {
- for (uint64_t element : vect) {
- vect.push_back(static_cast<T>(element));
- }
- }
- ~InsertElementsBuilder() override = default;
-
- size_t size() const override {
- return vect_.size() * sizeof(T);
- }
-
- virtual const std::unique_ptr<std::vector<uint8_t>> FinalPacket() {
- std::unique_ptr<std::vector<uint8_t>> packet = std::make_unique<std::vector<uint8_t>>();
- packet->reserve(size());
- std::back_insert_iterator<std::vector<uint8_t>> it(*packet);
- Serialize(it);
- return packet;
- }
-
- void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
- for (T elem : vect_) {
- PacketBuilder<true>::insert(elem, it);
- }
- }
-
- private:
- std::vector<T> vect_;
-};
-
-std::vector<uint64_t> vector_data{
- 0x7060504030201000, 0x7161514131211101, 0x7262524232221202, 0x7363534333231303, 0x7464544434241404,
- 0x7565554535251505, 0x7666564636261606, 0x7767574737271707, 0x7868584838281808,
-};
-
-template <typename T>
-class VectorBuilderTest : public ::testing::Test {
- public:
- VectorBuilderTest() = default;
- ~VectorBuilderTest() override = default;
-
- void SetUp() override {
- packet_1_ = std::shared_ptr<VectorBuilder<T>>(new VectorBuilder<T>(vector_data));
- packet_2_ = std::shared_ptr<InsertElementsBuilder<T>>(new InsertElementsBuilder<T>(vector_data));
- }
-
- void TearDown() override {
- packet_1_.reset();
- packet_2_.reset();
- }
-
- std::shared_ptr<VectorBuilder<T>> packet_1_;
- std::shared_ptr<InsertElementsBuilder<T>> packet_2_;
-};
-
-using VectorBaseTypes = ::testing::Types<uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t>;
-TYPED_TEST_CASE(VectorBuilderTest, VectorBaseTypes);
-
-TYPED_TEST(VectorBuilderTest, insertVectorTest) {
- ASSERT_EQ(*(this->packet_1_->FinalPacket()), *(this->packet_2_->FinalPacket()));
-}
-
-class NestedBuilder : public PacketBuilder<true> {
- public:
- ~NestedBuilder() override = default;
-
- size_t size() const override {
- size_t payload_size = (payload_ ? payload_->size() : 0);
- return 1 + payload_size;
- }
-
- static std::unique_ptr<NestedBuilder> Create(uint8_t level) {
- return std::unique_ptr<NestedBuilder>(new NestedBuilder(level));
- }
-
- static std::unique_ptr<NestedBuilder> CreateNested(std::unique_ptr<BasePacketBuilder> payload, uint8_t level) {
- return std::unique_ptr<NestedBuilder>(new NestedBuilder(std::move(payload), level));
- }
-
- virtual const std::unique_ptr<std::vector<uint8_t>> FinalPacket() {
- std::unique_ptr<std::vector<uint8_t>> packet = std::make_unique<std::vector<uint8_t>>();
- packet->reserve(size());
- std::back_insert_iterator<std::vector<uint8_t>> it(*packet);
- Serialize(it);
- return packet;
- }
-
- void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
- PacketBuilder<true>::insert(level_, it);
- if (payload_) {
- payload_->Serialize(it);
- }
- }
-
- private:
- std::unique_ptr<BasePacketBuilder> payload_;
- uint8_t level_;
-
- NestedBuilder(std::unique_ptr<BasePacketBuilder> inner, uint8_t level) : payload_(std::move(inner)), level_(level) {}
- NestedBuilder(uint8_t level) : level_(level) {}
-};
-
-class BuilderBuilderTest : public ::testing::Test {};
-
-TEST(BuilderBuilderTest, nestingTest) {
- std::unique_ptr<BasePacketBuilder> innermost = NestedBuilder::Create(0);
- std::unique_ptr<BasePacketBuilder> number_1 = NestedBuilder::CreateNested(std::move(innermost), 1);
- std::unique_ptr<BasePacketBuilder> number_2 = NestedBuilder::CreateNested(std::move(number_1), 2);
- std::unique_ptr<BasePacketBuilder> number_3 = NestedBuilder::CreateNested(std::move(number_2), 3);
- std::unique_ptr<BasePacketBuilder> number_4 = NestedBuilder::CreateNested(std::move(number_3), 4);
- std::unique_ptr<NestedBuilder> number_5 = NestedBuilder::CreateNested(std::move(number_4), 5);
-
- std::vector<uint8_t> count_down{5, 4, 3, 2, 1, 0};
- ASSERT_EQ(*number_5->FinalPacket(), count_down);
-}
-} // namespace packets
-} // namespace test_vendor_lib