OSDN Git Service

DO NOT MERGE Log encryption key size
authorJack He <siyuanh@google.com>
Thu, 21 Mar 2019 00:51:09 +0000 (17:51 -0700)
committerJakub Pawlowski <jpawlowski@google.com>
Tue, 26 Mar 2019 20:05:22 +0000 (20:05 +0000)
* Log result from HCI_READ_ENCR_KEY_SIZE command

Bug: 124301137
Test: test drive with statsd
Change-Id: I776a3c357fcd75623fba241f150d1afb58aa23fb

btif/Android.bp
main/Android.bp
stack/Android.bp
stack/btu/btu_hcif.cc

index 43234da..dadd76a 100644 (file)
@@ -148,6 +148,7 @@ cc_test {
         "libkeystore_binder",
         "libkeystore_parcelables",
         "libbinder",
+        "libstatslog",
     ],
     static_libs: [
         "libbt-bta",
index f512190..a3aebbc 100644 (file)
@@ -60,6 +60,7 @@ cc_library_shared {
         "libkeystore_aidl",
         "libkeystore_binder",
         "libkeystore_parcelables",
+        "libstatslog",
     ],
     static_libs: [
         "libbt-sbc-decoder",
index ceb2f13..03e2c94 100644 (file)
@@ -178,6 +178,7 @@ cc_library_static {
     shared_libs: [
         "libcutils",
         "liblog",
+        "libstatslog",
     ],
     required: [
         "libldacBT_enc",
index eb453c5..fbd7695 100644 (file)
@@ -33,6 +33,7 @@
 #include <base/logging.h>
 #include <base/threading/thread.h>
 #include <log/log.h>
+#include <statslog.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -724,6 +725,14 @@ constexpr uint8_t MIN_KEY_SIZE = 7;
 
 static void read_encryption_key_size_complete_after_encryption_change(
     uint8_t status, uint16_t handle, uint8_t key_size) {
+  int ret = android::util::stats_write(
+      android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, "", handle,
+      HCI_READ_ENCR_KEY_SIZE, HCI_COMMAND_COMPLETE_EVT, status, 0, key_size);
+  if (ret < 0) {
+    LOG(WARNING) << __func__ << ": failed to log encryption key size "
+                 << std::to_string(key_size);
+  }
+
   if (status != HCI_SUCCESS) {
     LOG(INFO) << __func__ << ": disconnecting, status: " << loghex(status);
     btsnd_hcic_disconnect(handle, HCI_ERR_PEER_USER);
@@ -1677,6 +1686,14 @@ static void btu_hcif_enhanced_flush_complete_evt(void) {
 
 static void read_encryption_key_size_complete_after_key_refresh(
     uint8_t status, uint16_t handle, uint8_t key_size) {
+  int ret = android::util::stats_write(
+      android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, "", handle,
+      HCI_READ_ENCR_KEY_SIZE, HCI_COMMAND_COMPLETE_EVT, status, 0, key_size);
+  if (ret < 0) {
+    LOG(WARNING) << __func__ << ": failed to log encryption key size "
+                 << std::to_string(key_size);
+  }
+
   if (status != HCI_SUCCESS) {
     LOG(INFO) << __func__ << ": disconnecting, status: " << loghex(status);
     btsnd_hcic_disconnect(handle, HCI_ERR_PEER_USER);