Fixes for Linux build

Some fixes needed to build on Linux:
* Add missing C++ source files to BUILD.gn
* Add stubs in common/metrics_linux.cc
* Add Linux stub implementation of ActivityAttribution
* Add Linux stub for ParameterProvider::SnoozLogFilePath
* Add missing include files

Bug: 184975659
Tag: #floss
Test: atest --host bluetooth_test_gd
Change-Id: I37e6c3f593a95777c9c72bc9cda3da1e7ba466c0
diff --git a/system/bta/BUILD.gn b/system/bta/BUILD.gn
index b8b32ea..64bd53c 100644
--- a/system/bta/BUILD.gn
+++ b/system/bta/BUILD.gn
@@ -83,6 +83,8 @@
     "sys/bta_sys_conn.cc",
     "sys/bta_sys_main.cc",
     "sys/utl.cc",
+    "vc/device.cc",
+    "vc/vc.cc",
   ]
 
   include_dirs = [
diff --git a/system/btif/BUILD.gn b/system/btif/BUILD.gn
index df326e5..9d1bc6c 100644
--- a/system/btif/BUILD.gn
+++ b/system/btif/BUILD.gn
@@ -42,6 +42,7 @@
     "src/btif_a2dp_control.cc",
     "src/btif_a2dp_sink.cc",
     "src/btif_a2dp_source.cc",
+    "src/btif_activity_attribution.cc",
     "src/btif_av.cc",
 
     # TODO(abps) - Move this abstraction elsewhere
diff --git a/system/common/metrics_linux.cc b/system/common/metrics_linux.cc
index aa01cbc..f363827 100644
--- a/system/common/metrics_linux.cc
+++ b/system/common/metrics_linux.cc
@@ -111,6 +111,12 @@
                               int num_dropped_encoded_frames,
                               int num_dropped_encoded_bytes) {}
 
+void LogA2dpPlaybackEvent(const RawAddress& address, int playback_state,
+                          int audio_coding_mode) {}
+
+void LogBluetoothHalCrashReason(const RawAddress& address, uint32_t error_code,
+                                uint32_t vendor_error_code) {}
+
 void LogReadRssiResult(const RawAddress& address, uint16_t handle,
                        uint32_t cmd_status, int8_t rssi) {}
 
diff --git a/system/gd/BUILD.gn b/system/gd/BUILD.gn
index cd48264..3201a0f 100644
--- a/system/gd/BUILD.gn
+++ b/system/gd/BUILD.gn
@@ -66,6 +66,7 @@
     "//bt/gd/common:BluetoothCommonSources",
     "//bt/gd/crypto_toolbox:BluetoothCryptoToolboxSources",
     "//bt/gd/dumpsys:BluetoothDumpsysSources",
+    "//bt/gd/btaa:BluetoothBtaaSources_linux",
     "//bt/gd/hal:BluetoothHalSources",
     "//bt/gd/hal:BluetoothHalSources_hci_host",
     "//bt/gd/l2cap:BluetoothL2capSources",
diff --git a/system/gd/btaa/BUILD.gn b/system/gd/btaa/BUILD.gn
new file mode 100644
index 0000000..342a4e3
--- /dev/null
+++ b/system/gd/btaa/BUILD.gn
@@ -0,0 +1,22 @@
+#
+#  Copyright 2021 Google, Inc.
+#
+#  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.
+#
+
+source_set("BluetoothBtaaSources_linux") {
+  sources = [ "linux/activity_attribution.cc" ]
+
+  configs += [ "//bt/gd:gd_defaults" ]
+  deps = [ "//bt/gd:gd_default_deps" ]
+}
diff --git a/system/gd/btaa/linux/activity_attribution.cc b/system/gd/btaa/linux/activity_attribution.cc
new file mode 100644
index 0000000..687e4c1
--- /dev/null
+++ b/system/gd/btaa/linux/activity_attribution.cc
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2020 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 "btaa/activity_attribution.h"
+
+// TODO: Implement for Linux.
+namespace bluetooth {
+namespace activity_attribution {
+
+const ModuleFactory ActivityAttribution::Factory = ModuleFactory([]() { return new ActivityAttribution(); });
+
+struct ActivityAttribution::impl {
+  impl(ActivityAttribution* module) {}
+
+  void on_hci_packet(hal::HciPacket packet, hal::SnoopLogger::PacketType type, uint16_t length) {}
+
+  void register_callback(ActivityAttributionCallback* callback) {}
+};
+
+void ActivityAttribution::Capture(const hal::HciPacket& packet, hal::SnoopLogger::PacketType type) {}
+
+void ActivityAttribution::RegisterActivityAttributionCallback(ActivityAttributionCallback* callback) {}
+
+std::string ActivityAttribution::ToString() const {
+  return "Btaa Module";
+}
+
+void ActivityAttribution::ListDependencies(ModuleList* list) {}
+
+void ActivityAttribution::Start() {}
+
+void ActivityAttribution::Stop() {}
+
+}  // namespace activity_attribution
+}  // namespace bluetooth
diff --git a/system/gd/os/linux/parameter_provider.cc b/system/gd/os/linux/parameter_provider.cc
index f4e9175..6b4457d 100644
--- a/system/gd/os/linux/parameter_provider.cc
+++ b/system/gd/os/linux/parameter_provider.cc
@@ -31,6 +31,7 @@
 std::mutex parameter_mutex;
 std::string config_file_path;
 std::string snoop_log_file_path;
+std::string snooz_log_file_path;
 }  // namespace
 
 // Write to $PWD/bt_stack.conf if $PWD can be found, otherwise, write to $HOME/bt_stack.conf
@@ -65,5 +66,15 @@
   snoop_log_file_path = path;
 }
 
+std::string ParameterProvider::SnoozLogFilePath() {
+  {
+    std::lock_guard<std::mutex> lock(parameter_mutex);
+    if (!snooz_log_file_path.empty()) {
+      return snooz_log_file_path;
+    }
+  }
+  return "/etc/bluetooth/btsnooz_hci.log";
+}
+
 }  // namespace os
 }  // namespace bluetooth
diff --git a/system/include/hardware/bt_activity_attribution.h b/system/include/hardware/bt_activity_attribution.h
index 74e4404..1f4becb 100644
--- a/system/include/hardware/bt_activity_attribution.h
+++ b/system/include/hardware/bt_activity_attribution.h
@@ -17,6 +17,8 @@
 #ifndef ANDROID_INCLUDE_BT_ACTIVITY_ATTRIBUTION_H
 #define ANDROID_INCLUDE_BT_ACTIVITY_ATTRIBUTION_H
 
+#include <vector>
+
 #include "raw_address.h"
 
 namespace bluetooth {
diff --git a/system/main/shim/BUILD.gn b/system/main/shim/BUILD.gn
index 7b286cb..0f8ec9e 100644
--- a/system/main/shim/BUILD.gn
+++ b/system/main/shim/BUILD.gn
@@ -19,6 +19,7 @@
     "acl.cc",
     "acl_api.cc",
     "acl_legacy_interface.cc",
+    "activity_attribution.cc",
     "btm.cc",
     "btm_api.cc",
     "config.cc",