• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


Commit MetaInfo

Revisióne1c8ed17c7a35510f00997ca329687f73cd193d8 (tree)
Tiempo2016-09-17 06:46:23
AutorPavlin Radoslavov <pavlin@goog...>
CommiterPavlin Radoslavov

Log Message

Add BT_HCI_UNKNOWN_MESSAGE_TYPE log event

If the received HCI type is unknown, then log an event and abort.
The most likely reason for that to happen is if the UART stream
is corrupted. We cannot recover from that, and there is not much
else we can do.

Also, fixed a bug in an HCI-related unit test that was exposed
by the above change.

Bug: 31432127
Change-Id: Ia888c485f177af4962268bf8f593b27fd7a4b080
(cherry picked from commit 27ec0c7824cf67b8a36bf5391734e6d2fc6207e2)

Cambiar Resumen

Diferencia incremental

--- a/EventLogTags.logtags
+++ b/EventLogTags.logtags
@@ -35,3 +35,4 @@
3535
3636 1010000 bt_hci_timeout (opcode|1)
3737 1010001 bt_config_source (opcode|1)
38+1010002 bt_hci_unknown_type (hci_type|1)
--- a/hci/src/hci_hal_h4.c
+++ b/hci/src/hci_hal_h4.c
@@ -38,6 +38,8 @@
3838 // when streaming time sensitive data (A2DP).
3939 #define HCI_THREAD_PRIORITY -19
4040
41+#define BT_HCI_UNKNOWN_MESSAGE_TYPE_NUM 1010002
42+
4143 // Our interface and modules we import
4244 static const hci_hal_t interface;
4345 static const hci_hal_callbacks_t *callbacks;
@@ -233,7 +235,10 @@ static void event_uart_has_bytes(eager_reader_t *reader, UNUSED_ATTR void *conte
233235 return;
234236
235237 if (type_byte < DATA_TYPE_ACL || type_byte > DATA_TYPE_EVENT) {
236- LOG_ERROR(LOG_TAG, "%s Unknown HCI message type. Dropping this byte 0x%x, min %x, max %x", __func__, type_byte, DATA_TYPE_ACL, DATA_TYPE_EVENT);
238+ LOG_ERROR(LOG_TAG, "%s Unknown HCI message type 0x%x (min=0x%x max=0x%x). Aborting...",
239+ __func__, type_byte, DATA_TYPE_ACL, DATA_TYPE_EVENT);
240+ LOG_EVENT_INT(BT_HCI_UNKNOWN_MESSAGE_TYPE_NUM, type_byte);
241+ assert(false && "Unknown HCI message type");
237242 return;
238243 }
239244
--- a/hci/test/hci_hal_h4_test.cpp
+++ b/hci/test/hci_hal_h4_test.cpp
@@ -192,17 +192,18 @@ static void expect_socket_data(int fd, char first_byte, char *data) {
192192 }
193193 }
194194
195-static void write_packet(int fd, char first_byte, char *data) {
195+static void write_packet(int fd, char first_byte, const void *data,
196+ size_t datalen) {
196197 write(fd, &first_byte, 1);
197- write(fd, data, strlen(data));
198+ write(fd, data, datalen);
198199 }
199200
200-static void write_packet_reentry(int fd, char first_byte, char *data) {
201+static void write_packet_reentry(int fd, char first_byte, const void *data,
202+ size_t datalen) {
201203 write(fd, &first_byte, 1);
202204
203- int length = strlen(data);
204- for (int i = 0; i < length; i++) {
205- write(fd, &data[i], 1);
205+ for (size_t i = 0; i < datalen; i++) {
206+ write(fd, static_cast<const uint8_t *>(data) + i, 1);
206207 semaphore_wait(reentry_semaphore);
207208 }
208209 }
@@ -226,10 +227,11 @@ TEST_F(HciHalH4Test, test_transmit) {
226227 TEST_F(HciHalH4Test, test_read_synchronous) {
227228 reset_for(read_synchronous);
228229
229- write_packet(sockfd[1], DATA_TYPE_ACL, acl_data);
230- write_packet(sockfd[1], HCI_BLE_EVENT, corrupted_data);
231- write_packet(sockfd[1], DATA_TYPE_SCO, sco_data);
232- write_packet(sockfd[1], DATA_TYPE_EVENT, event_data);
230+ write_packet(sockfd[1], DATA_TYPE_ACL, acl_data, strlen(acl_data));
231+ write_packet(sockfd[1], HCI_BLE_EVENT, corrupted_data,
232+ sizeof(corrupted_data));
233+ write_packet(sockfd[1], DATA_TYPE_SCO, sco_data, strlen(sco_data));
234+ write_packet(sockfd[1], DATA_TYPE_EVENT, event_data, strlen(event_data));
233235
234236 // Wait for all data to be received before calling the test good
235237 semaphore_wait(done);
@@ -242,7 +244,8 @@ TEST_F(HciHalH4Test, test_read_async_reentry) {
242244 reentry_semaphore = semaphore_new(0);
243245 reentry_i = 0;
244246
245- write_packet_reentry(sockfd[1], DATA_TYPE_ACL, sample_data3);
247+ write_packet_reentry(sockfd[1], DATA_TYPE_ACL, sample_data3,
248+ strlen(sample_data3));
246249
247250 // write_packet_reentry ensures the data has been received
248251 semaphore_free(reentry_semaphore);