Linux build fix

* add missing LOG_TAG definition
* add missing LOG_TAG inside LOG statements
* remove unnecessary includes of cutils/*.h files
* update libchrome/BUILD.gn to be on par with latest version of
  library used in Android

Bug: 28094186
Change-Id: I19a07afac20789b42a070995f6aa9da68b1bb940
diff --git a/btif/BUILD.gn b/btif/BUILD.gn
index f0d3ef8..8a459c8 100644
--- a/btif/BUILD.gn
+++ b/btif/BUILD.gn
@@ -21,6 +21,7 @@
     #TODO(jpawlowski): heavily depends on Android,
     #   "src/btif_avrcp_audio_track.cpp",
     "src/btif_config.c",
+    "src/btif_config_transcode.cpp",
     "src/btif_core.c",
     "src/btif_debug.c",
     "src/btif_debug_btsnoop.c",
diff --git a/btif/src/btif_avrcp_audio_track.cpp b/btif/src/btif_avrcp_audio_track.cpp
index 73ad649..4d8e8dd 100644
--- a/btif/src/btif_avrcp_audio_track.cpp
+++ b/btif/src/btif_avrcp_audio_track.cpp
@@ -15,6 +15,8 @@
  */
 
 //#define LOG_NDEBUG 0
+#define LOG_TAG "bt_btif_avrcp_audio_track"
+
 #include "btif_avrcp_audio_track.h"
 
 #include <media/AudioTrack.h>
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c
index 64b5818..7eb5da3 100644
--- a/btif/src/btif_config.c
+++ b/btif/src/btif_config.c
@@ -40,15 +40,7 @@
 #include "osi/include/config.h"
 #include "osi/include/log.h"
 #include "osi/include/osi.h"
-
-/**
- * TODO(apanicke): cutils/properties.h is only being used to pull-in runtime
- * settings on Android. Remove this conditional include once we have a generic
- * way to obtain system properties.
- */
-#if !defined(OS_GENERIC)
-#include <cutils/properties.h>
-#endif  /* !defined(OS_GENERIC) */
+#include "osi/include/properties.h"
 
 // TODO(armansito): Find a better way than searching by a hardcoded path.
 #if defined(OS_GENERIC)
@@ -131,23 +123,23 @@
   config = config_new(CONFIG_FILE_PATH);
   btif_config_source = ORIGINAL;
   if (!config) {
-    LOG_WARN("%s unable to load config file: %s; using backup.",
+    LOG_WARN(LOG_TAG, "%s unable to load config file: %s; using backup.",
               __func__, CONFIG_FILE_PATH);
     config = config_new(CONFIG_BACKUP_PATH);
     btif_config_source = BACKUP;
   }
   if (!config) {
-    LOG_WARN("%s unable to load backup; attempting to transcode legacy file.", __func__);
+    LOG_WARN(LOG_TAG, "%s unable to load backup; attempting to transcode legacy file.", __func__);
     config = btif_config_transcode(CONFIG_LEGACY_FILE_PATH);
     btif_config_source = LEGACY;
   }
   if (!config) {
-    LOG_ERROR("%s unable to transcode legacy file; creating empty config.", __func__);
+    LOG_ERROR(LOG_TAG, "%s unable to transcode legacy file; creating empty config.", __func__);
     config = config_new_empty();
     btif_config_source = NEW_FILE;
   }
   if (!config) {
-    LOG_ERROR("%s unable to allocate a config object.", __func__);
+    LOG_ERROR(LOG_TAG, "%s unable to allocate a config object.", __func__);
     goto error;
   }
 
@@ -501,12 +493,12 @@
 
 static bool is_factory_reset(void) {
   char factory_reset[PROPERTY_VALUE_MAX] = {0};
-  property_get("persist.bluetooth.factoryreset", factory_reset, "false");
+  osi_property_get("persist.bluetooth.factoryreset", factory_reset, "false");
   return strncmp(factory_reset, "true", 4) == 0;
 }
 
 static void delete_config_files(void) {
   remove(CONFIG_FILE_PATH);
   remove(CONFIG_BACKUP_PATH);
-  property_set("persist.bluetooth.factoryreset", "false");
+  osi_property_set("persist.bluetooth.factoryreset", "false");
 }
diff --git a/btif/src/btif_config_transcode.cpp b/btif/src/btif_config_transcode.cpp
index e9d859e..e8bd1a2 100644
--- a/btif/src/btif_config_transcode.cpp
+++ b/btif/src/btif_config_transcode.cpp
@@ -31,19 +31,19 @@
   XMLDocument document;
   int error = document.LoadFile(xml_filename);
   if (error != XML_SUCCESS) {
-    LOG_ERROR("%s unable to load XML file '%s': %d", __func__, xml_filename, error);
+    LOG_ERROR(LOG_TAG, "%s unable to load XML file '%s': %d", __func__, xml_filename, error);
     return NULL;
   }
 
   XMLElement *rootElement = document.RootElement();
   if (!rootElement) {
-    LOG_ERROR("%s unable to find root element; assuming corrupted config file.", __func__);
+    LOG_ERROR(LOG_TAG, "%s unable to find root element; assuming corrupted config file.", __func__);
     return NULL;
   }
 
   config_t *config = config_new_empty();
   if (!config) {
-    LOG_ERROR("%s unable to allocate config object.", __func__);
+    LOG_ERROR(LOG_TAG, "%s unable to allocate config object.", __func__);
     return NULL;
   }
 
diff --git a/build/secondary/third_party/libchrome/BUILD.gn b/build/secondary/third_party/libchrome/BUILD.gn
index 167cb40..d95ced9 100644
--- a/build/secondary/third_party/libchrome/BUILD.gn
+++ b/build/secondary/third_party/libchrome/BUILD.gn
@@ -83,6 +83,9 @@
     "base/metrics/histogram.cc",
     "base/metrics/histogram_samples.cc",
     "base/metrics/histogram_snapshot_manager.cc",
+    "base/metrics/persistent_histogram_allocator.cc",
+    "base/metrics/persistent_memory_allocator.cc",
+    "base/metrics/persistent_sample_map.cc",
     "base/metrics/sample_map.cc",
     "base/metrics/sample_vector.cc",
     "base/metrics/sparse_histogram.cc",
@@ -105,7 +108,6 @@
     "base/process/process_metrics_linux.cc",
     "base/process/process_metrics_posix.cc",
     "base/process/process_posix.cc",
-    "base/profiler/alternate_timer.cc",
     "base/profiler/scoped_profile.cc",
     "base/profiler/scoped_tracker.cc",
     "base/profiler/tracked_time.cc",
@@ -183,9 +185,7 @@
     "base/trace_event/memory_dump_session_state.cc",
     "base/trace_event/process_memory_dump.cc",
     "base/trace_event/process_memory_maps.cc",
-    "base/trace_event/process_memory_maps_dump_provider.cc",
     "base/trace_event/process_memory_totals.cc",
-    "base/trace_event/process_memory_totals_dump_provider.cc",
     "base/trace_event/trace_buffer.cc",
     "base/trace_event/trace_config.cc",
     "base/trace_event/trace_event_argument.cc",
diff --git a/device/src/classic/peer.c b/device/src/classic/peer.c
index 1bab300..a71918d 100644
--- a/device/src/classic/peer.c
+++ b/device/src/classic/peer.c
@@ -21,7 +21,6 @@
 #include "device/include/classic/peer.h"
 
 #include <assert.h>
-#include <cutils/log.h>
 #include <pthread.h>
 #include <stdbool.h>
 
diff --git a/hci/src/hci_layer.c b/hci/src/hci_layer.c
index b169b03..929987f 100644
--- a/hci/src/hci_layer.c
+++ b/hci/src/hci_layer.c
@@ -175,10 +175,7 @@
 
   pthread_mutex_init(&commands_pending_response_lock, NULL);
 
-  // TODO(armansito): cutils/properties.h is only being used to pull-in runtime
-  // settings on Android. Remove this conditional include once we have a generic
-  // way to obtain system properties. For now, always use the default timeout on
-  // non-Android builds.
+  // For now, always use the default timeout on non-Android builds.
   period_ms_t startup_timeout_ms = DEFAULT_STARTUP_TIMEOUT_MS;
 
   // Grab the override startup timeout ms, if present.
diff --git a/service/main.cpp b/service/main.cpp
index 3ab81e6..fc5eec6 100644
--- a/service/main.cpp
+++ b/service/main.cpp
@@ -23,12 +23,7 @@
 #include <base/files/scoped_file.h>
 #include <base/logging.h>
 
-// For system properties
-// TODO(icoolidge): abstraction or non-cutils stub.
-#if !defined(OS_GENERIC)
-#include <cutils/properties.h>
-#endif  // !defined(OS_GENERIC)
-
+#include "osi/include/properties.h"
 #include "service/daemon.h"
 #include "service/switches.h"