Metrics: Move bluetooth.proto to one place
* Move bluetooth.proto to proto/ and compile it for both Java LITE
runtime and C++ LITE runtime so that it can be shared between Java
and native code
* Remove redundant comments in bluetooth.proto
Bug: 33693818
Test: make, toggle Bluetooth, clearcut server-client E2E test
adb shell dumpsys bluetooth_manager --proto-bin
ACTS tests: BtMetricsTest, BtFunhausMetricsTest
Change-Id: I7cd5e1b4fb8fcc197272ef8161ff384e53022424
diff --git a/Android.bp b/Android.bp
index d8b884f..687836e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -19,4 +19,5 @@
"types",
"udrv",
"tools",
+ "proto",
]
diff --git a/bta/Android.bp b/bta/Android.bp
index 5759183..60c05a3 100644
--- a/bta/Android.bp
+++ b/bta/Android.bp
@@ -132,7 +132,7 @@
"libbtcore",
"libbt-bta",
"libbluetooth-types",
+ "libbt-protos-lite",
"libosi",
- "libbt-protos",
],
}
diff --git a/btif/Android.bp b/btif/Android.bp
index c23ffa5..af826a6 100644
--- a/btif/Android.bp
+++ b/btif/Android.bp
@@ -126,7 +126,7 @@
"libudrv-uipc",
"libbluetooth-types",
"libosi",
- "libbt-protos",
+ "libbt-protos-lite",
],
whole_static_libs: [
"libbtif",
diff --git a/hci/Android.bp b/hci/Android.bp
index b6fe28a..635d939 100644
--- a/hci/Android.bp
+++ b/hci/Android.bp
@@ -73,6 +73,6 @@
"libosi-AllocationTestHarness",
"libcutils",
"libbtcore",
- "libbt-protos",
+ "libbt-protos-lite",
],
}
diff --git a/main/Android.bp b/main/Android.bp
index 3661458..7eacaf9 100644
--- a/main/Android.bp
+++ b/main/Android.bp
@@ -63,11 +63,11 @@
"libbtdevice",
"libbtif",
"libbt-hci",
- "libbt-protos",
"libbt-stack",
"libbt-utils",
"libbtcore",
"libosi",
+ "libbt-protos-lite",
],
// Shared library link options.
// References to global symbols and functions should bind to the library
diff --git a/osi/Android.bp b/osi/Android.bp
index be8cdfd..ad2f44b 100644
--- a/osi/Android.bp
+++ b/osi/Android.bp
@@ -4,7 +4,6 @@
include_dirs: [
"system/bt",
"system/bt/internal_include",
- "system/bt/osi/src/protos",
"system/bt/utils/include",
"system/bt/stack/include",
]
@@ -36,19 +35,6 @@
},
}
-// Bluetooth Protobuf static library for target and host
-// ========================================================
-cc_library_static {
- name: "libbt-protos",
- defaults: ["fluoride_defaults"],
- srcs: ["src/protos/bluetooth.proto"],
- proto: {
- export_proto_headers: true,
- },
- host_supported: true,
-}
-
-
// libosi static library for target
// ========================================================
cc_library_static {
@@ -85,7 +71,7 @@
shared_libs: [
"liblog",
],
- static_libs: ["libbt-protos"],
+ static_libs: ["libbt-protos-lite"],
host_supported: true,
// TODO(armansito): Setting _GNU_SOURCE isn't very platform-independent but
// should be compatible for a Linux host OS. We should figure out what to do for
@@ -136,7 +122,7 @@
"libcutils",
],
static_libs: [
- "libbt-protos",
+ "libbt-protos-lite",
"libgmock",
"libosi",
],
diff --git a/osi/src/metrics.cc b/osi/src/metrics.cc
index 53cf4d2..bfb54cc 100644
--- a/osi/src/metrics.cc
+++ b/osi/src/metrics.cc
@@ -29,31 +29,32 @@
#include <base/base64.h>
#include <base/logging.h>
+#include "bluetooth/metrics/bluetooth.pb.h"
#include "osi/include/leaky_bonded_queue.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/time.h"
#include "stack/include/btm_api_types.h"
-#include "src/protos/bluetooth.pb.h"
-
#include "osi/include/metrics.h"
namespace system_bt_osi {
-using clearcut::connectivity::A2DPSession;
-using clearcut::connectivity::BluetoothLog;
-using clearcut::connectivity::BluetoothSession;
-using clearcut::connectivity::BluetoothSession_ConnectionTechnologyType;
-using clearcut::connectivity::BluetoothSession_DisconnectReasonType;
-using clearcut::connectivity::DeviceInfo;
-using clearcut::connectivity::DeviceInfo_DeviceType;
-using clearcut::connectivity::PairEvent;
-using clearcut::connectivity::ScanEvent;
-using clearcut::connectivity::ScanEvent_ScanTechnologyType;
-using clearcut::connectivity::ScanEvent_ScanEventType;
-using clearcut::connectivity::WakeEvent;
-using clearcut::connectivity::WakeEvent_WakeEventType;
+using bluetooth::metrics::BluetoothMetricsProto::A2DPSession;
+using bluetooth::metrics::BluetoothMetricsProto::BluetoothLog;
+using bluetooth::metrics::BluetoothMetricsProto::BluetoothSession;
+using bluetooth::metrics::BluetoothMetricsProto::
+ BluetoothSession_ConnectionTechnologyType;
+using bluetooth::metrics::BluetoothMetricsProto::
+ BluetoothSession_DisconnectReasonType;
+using bluetooth::metrics::BluetoothMetricsProto::DeviceInfo;
+using bluetooth::metrics::BluetoothMetricsProto::DeviceInfo_DeviceType;
+using bluetooth::metrics::BluetoothMetricsProto::PairEvent;
+using bluetooth::metrics::BluetoothMetricsProto::ScanEvent;
+using bluetooth::metrics::BluetoothMetricsProto::ScanEvent_ScanTechnologyType;
+using bluetooth::metrics::BluetoothMetricsProto::ScanEvent_ScanEventType;
+using bluetooth::metrics::BluetoothMetricsProto::WakeEvent;
+using bluetooth::metrics::BluetoothMetricsProto::WakeEvent_WakeEventType;
/*
* Get current OS boot time in millisecond
diff --git a/osi/test/metrics_test.cc b/osi/test/metrics_test.cc
index 47852b1..15f6ad9 100644
--- a/osi/test/metrics_test.cc
+++ b/osi/test/metrics_test.cc
@@ -26,28 +26,30 @@
#include <base/logging.h>
+#include "bluetooth/metrics/bluetooth.pb.h"
#include "osi/include/metrics.h"
#include "osi/include/time.h"
-#include "src/protos/bluetooth.pb.h"
#define BTM_COD_MAJOR_AUDIO_TEST 0x04
namespace testing {
-using clearcut::connectivity::A2DPSession;
-using clearcut::connectivity::BluetoothLog;
-using clearcut::connectivity::BluetoothSession;
-using clearcut::connectivity::BluetoothSession_ConnectionTechnologyType;
-using clearcut::connectivity::BluetoothSession_DisconnectReasonType;
-using clearcut::connectivity::DeviceInfo;
-using clearcut::connectivity::DeviceInfo_DeviceType;
-using clearcut::connectivity::PairEvent;
-using clearcut::connectivity::RFCommSession;
-using clearcut::connectivity::ScanEvent;
-using clearcut::connectivity::ScanEvent_ScanTechnologyType;
-using clearcut::connectivity::ScanEvent_ScanEventType;
-using clearcut::connectivity::WakeEvent;
-using clearcut::connectivity::WakeEvent_WakeEventType;
+using bluetooth::metrics::BluetoothMetricsProto::A2DPSession;
+using bluetooth::metrics::BluetoothMetricsProto::BluetoothLog;
+using bluetooth::metrics::BluetoothMetricsProto::BluetoothSession;
+using bluetooth::metrics::BluetoothMetricsProto::
+ BluetoothSession_ConnectionTechnologyType;
+using bluetooth::metrics::BluetoothMetricsProto::
+ BluetoothSession_DisconnectReasonType;
+using bluetooth::metrics::BluetoothMetricsProto::DeviceInfo;
+using bluetooth::metrics::BluetoothMetricsProto::DeviceInfo_DeviceType;
+using bluetooth::metrics::BluetoothMetricsProto::PairEvent;
+using bluetooth::metrics::BluetoothMetricsProto::RFCommSession;
+using bluetooth::metrics::BluetoothMetricsProto::ScanEvent;
+using bluetooth::metrics::BluetoothMetricsProto::ScanEvent_ScanTechnologyType;
+using bluetooth::metrics::BluetoothMetricsProto::ScanEvent_ScanEventType;
+using bluetooth::metrics::BluetoothMetricsProto::WakeEvent;
+using bluetooth::metrics::BluetoothMetricsProto::WakeEvent_WakeEventType;
using system_bt_osi::BluetoothMetricsLogger;
using system_bt_osi::A2dpSessionMetrics;
diff --git a/proto/Android.bp b/proto/Android.bp
new file mode 100644
index 0000000..0f97c72
--- /dev/null
+++ b/proto/Android.bp
@@ -0,0 +1,19 @@
+java_library_static {
+ name: "bluetooth-protos-lite",
+ host_supported: true,
+ proto: {
+ type: "lite",
+ },
+ srcs: ["bluetooth/metrics/bluetooth.proto"],
+}
+
+cc_library_static {
+ name: "libbt-protos-lite",
+ host_supported: true,
+ proto: {
+ export_proto_headers: true,
+ type: "lite",
+ },
+ srcs: ["bluetooth/metrics/bluetooth.proto"],
+}
+
diff --git a/osi/src/protos/bluetooth.proto b/proto/bluetooth/metrics/bluetooth.proto
similarity index 84%
rename from osi/src/protos/bluetooth.proto
rename to proto/bluetooth/metrics/bluetooth.proto
index f6f1d0b..273c23a 100644
--- a/osi/src/protos/bluetooth.proto
+++ b/proto/bluetooth/metrics/bluetooth.proto
@@ -1,16 +1,28 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-// Author: pkanwar@google.com (Pankaj Kanwar)
-// Protos for uploading bluetooth metrics.
+/*
+ * Copyright (C) 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.
+ */
syntax = "proto2";
+
option optimize_for = LITE_RUNTIME;
-package clearcut.connectivity;
+// C++ namespace: bluetooth::metrics::BluetoothMetricsProto
+package bluetooth.metrics.BluetoothMetricsProto;
-option java_package = "com.google.wireless.android.play.playlog.connectivity";
-// option (datapol.file_vetting_status) = "latest";
-
-// import "storage/datapol/annotations/proto/semantic_annotations.proto";
+option java_package = "com.android.bluetooth";
+option java_outer_classname = "BluetoothMetricsProto";
message BluetoothLog {
// Session information that gets logged for every BT connection.
@@ -144,7 +156,7 @@
message PairEvent {
// The reason for disconnecting
- // https://cs.corp.google.com/#android/system/bt/stack/include/hcidefs.h&q=failed_establish.
+ // See: system/bt/stack/include/hcidefs.h, HCI_ERR_CONN_FAILED_ESTABLISHMENT
optional int32 disconnect_reason = 1;
// Pair event time
@@ -158,12 +170,9 @@
message WakeEvent {
// Information about the wake event type.
enum WakeEventType {
- // Type is unknown.
UNKNOWN = 0;
-
// WakeLock was acquired.
ACQUIRED = 1;
-
// WakeLock was released.
RELEASED = 2;
}
@@ -172,7 +181,7 @@
optional WakeEventType wake_event_type = 1;
// Initiator of the scan. Only the first three names will be stored.
- // e.g. com.google.gms.
+ // e.g. com.company.app
optional string requestor = 2;
// Name of the wakelock (e.g. bluedroid_timer).
@@ -186,7 +195,6 @@
message ScanEvent {
// Scan type.
enum ScanTechnologyType {
- // Scan Type is unknown.
SCAN_TYPE_UNKNOWN = 0;
SCAN_TECH_TYPE_LE = 1;
@@ -200,7 +208,6 @@
enum ScanEventType {
// Scan started.
SCAN_EVENT_START = 0;
-
// Scan stopped.
SCAN_EVENT_STOP = 1;
}
@@ -209,7 +216,7 @@
optional ScanEventType scan_event_type = 1;
// Initiator of the scan. Only the first three names will be stored.
- // e.g. com.google.gms.
+ // e.g. com.company.app
optional string initiator = 2;
// Technology used for scanning.
diff --git a/stack/Android.bp b/stack/Android.bp
index 1bedd40..2b5d430 100644
--- a/stack/Android.bp
+++ b/stack/Android.bp
@@ -214,7 +214,7 @@
"libbtdevice",
"libbt-hci",
"libosi",
- "libbt-protos",
+ "libbt-protos-lite",
],
whole_static_libs: [
"libbluetooth-for-tests",
@@ -338,7 +338,7 @@
"libbluetooth-types",
"libgmock",
"libosi",
- "libbt-protos",
+ "libbt-protos-lite",
],
sanitize: {
cfi: false,