Add BT_HCI_TIMEOUT and BT_CONFIG_SOURCE log events.

These events are used to track HCI timeout and configuration file
usage respectively.

Change-Id: I5c8b6ef20b61f03b9ccb74f3b1c9784e4653b770
diff --git a/EventLogTags.logtags b/EventLogTags.logtags
new file mode 100644
index 0000000..32493d8
--- /dev/null
+++ b/EventLogTags.logtags
@@ -0,0 +1,37 @@
+# The entries in this file map a sparse set of log tag numbers to tag names.
+# This is installed on the device, in /system/etc, and parsed by logcat.
+#
+# Tag numbers are decimal integers, from 0 to 2^31.  (Let's leave the
+# negative values alone for now.)
+#
+# Tag names are one or more ASCII letters and numbers or underscores, i.e.
+# "[A-Z][a-z][0-9]_".  Do not include spaces or punctuation (the former
+# impacts log readability, the latter makes regex searches more annoying).
+#
+# Tag numbers and names are separated by whitespace.  Blank lines and lines
+# starting with '#' are ignored.
+#
+# Optionally, after the tag names can be put a description for the value(s)
+# of the tag. Description are in the format
+#    (<name>|data type[|data unit])
+# Multiple values are separated by commas.
+#
+# The data type is a number from the following values:
+# 1: int
+# 2: long
+# 3: string
+# 4: list
+#
+# The data unit is a number taken from the following list:
+# 1: Number of objects
+# 2: Number of bytes
+# 3: Number of milliseconds
+# 4: Number of allocations
+# 5: Id
+# 6: Percent
+# Default value for data of type int/long is 2 (bytes).
+#
+# TODO: generate ".java" and ".h" files with integer constants from this file.
+
+1010000 bt_hci_timeout (opcode|1)
+1010001 bt_config_source (opcode|1)
diff --git a/btif/Android.mk b/btif/Android.mk
index 78a475b..eee76b9 100644
--- a/btif/Android.mk
+++ b/btif/Android.mk
@@ -23,7 +23,8 @@
 
 # HAL layer
 btifCommonSrc := \
-  src/bluetooth.c
+  src/bluetooth.c \
+  ../EventLogTags.logtags
 
 # BTIF implementation
 btifCommonSrc += \
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c
index 24a8c17..d5fb323 100644
--- a/btif/src/btif_config.c
+++ b/btif/src/btif_config.c
@@ -52,6 +52,8 @@
 #include <cutils/properties.h>
 #endif  /* !defined(OS_GENERIC) */
 
+#define BT_CONFIG_SOURCE_TAG_NUM 1010001
+
 #define INFO_SECTION "Info"
 #define FILE_TIMESTAMP "TimeCreated"
 #define FILE_SOURCE "FileSource"
@@ -199,6 +201,8 @@
     goto error;
   }
 
+  LOG_EVENT_INT(BT_CONFIG_SOURCE_TAG_NUM, btif_config_source);
+
   pthread_mutex_unlock(&lock);
   return future_new_immediate(FUTURE_SUCCESS);
 
diff --git a/hci/Android.mk b/hci/Android.mk
index 24e3d4d..0727100 100644
--- a/hci/Android.mk
+++ b/hci/Android.mk
@@ -19,7 +19,8 @@
     src/hci_packet_parser.c \
     src/low_power_manager.c \
     src/packet_fragmenter.c \
-    src/vendor.c
+    src/vendor.c \
+    ../EventLogTags.logtags
 
 LOCAL_C_INCLUDES += \
     $(LOCAL_PATH)/include \
diff --git a/hci/src/hci_layer.c b/hci/src/hci_layer.c
index d566141..3a45135 100644
--- a/hci/src/hci_layer.c
+++ b/hci/src/hci_layer.c
@@ -55,6 +55,8 @@
 #define PREAMBLE_BUFFER_SIZE 4 // max preamble size, ACL
 #define RETRIEVE_ACL_LENGTH(preamble) ((((preamble)[3]) << 8) | (preamble)[2])
 
+#define BT_HCI_TIMEOUT_TAG_NUM 1010000
+
 static const uint8_t preamble_sizes[] = {
   HCI_COMMAND_PREAMBLE_SIZE,
   HCI_ACL_PREAMBLE_SIZE,
@@ -534,6 +536,7 @@
     // We shouldn't try to recover the stack from this command timeout.
     // If it's caused by a software bug, fix it. If it's a hardware bug, fix it.
     LOG_ERROR(LOG_TAG, "%s hci layer timeout waiting for response to a command. opcode: 0x%x", __func__, wait_entry->opcode);
+    LOG_EVENT_INT(BT_HCI_TIMEOUT_TAG_NUM, wait_entry->opcode);
   }
 
   LOG_ERROR(LOG_TAG, "%s restarting the bluetooth process.", __func__);