diff options
author | Alex Deymo <deymo@google.com> | 2017-03-27 12:45:17 -0700 |
---|---|---|
committer | Alex Deymo <deymo@google.com> | 2017-03-27 12:59:11 -0700 |
commit | b610ef85f1f7a315510a1cf3c557533d043ef355 (patch) | |
tree | e2eb73dc31e38f5909cd4c437f2ea83bbf24375c | |
parent | a9a6af0e7b1caa54dad41cb184945e10e242cb38 (diff) | |
download | metricsd-b610ef85f1f7a315510a1cf3c557533d043ef355.tar.gz |
Bug: None
Test: `make checkbuild` without weave.
Change-Id: I9fa060ecdc5b563aa2c453152f86f586f75756ac
-rw-r--r-- | Android.mk | 20 | ||||
-rw-r--r-- | constants.h | 4 | ||||
-rw-r--r-- | etc/weaved/traits/metrics.json | 20 | ||||
-rw-r--r-- | metrics_collector.cc | 79 | ||||
-rw-r--r-- | metrics_collector.h | 26 | ||||
-rw-r--r-- | uploader/system_profile_cache.cc | 10 |
6 files changed, 0 insertions, 159 deletions
@@ -14,11 +14,6 @@ LOCAL_PATH := $(call my-dir) -# Default values for the USE flags. Override these USE flags from your product -# by setting BRILLO_USE_* values. Note that we define local variables like -# local_use_* to prevent leaking our default setting for other packages. -local_use_weave := $(if $(BRILLO_USE_WEAVE),$(BRILLO_USE_WEAVE),0) - metrics_cpp_extension := .cc libmetrics_sources := \ c_metrics_library.cc \ @@ -69,7 +64,6 @@ metrics_CFLAGS := -Wall \ -Werror \ -fvisibility=default metrics_CPPFLAGS := -Wno-non-virtual-dtor \ - -DUSE_WEAVE=$(local_use_weave) \ -Wno-sign-promo \ -Wno-strict-aliasing \ -fvisibility=default @@ -82,11 +76,6 @@ metrics_collector_shared_libraries := $(libmetrics_shared_libraries) \ libmetrics \ librootdev -ifeq ($(local_use_weave),1) -metrics_collector_shared_libraries += \ - libweaved -endif # local_use_weave == 1 - metrics_collector_static_libraries := libmetricscollectorservice metricsd_shared_libraries := \ @@ -231,12 +220,3 @@ ifdef BRILLO LOCAL_MODULE_TAGS := eng endif include $(BUILD_NATIVE_TEST) - -# Weave schema files -# ======================================================== -include $(CLEAR_VARS) -LOCAL_MODULE := metrics.json -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/weaved/traits -LOCAL_SRC_FILES := etc/weaved/traits/$(LOCAL_MODULE) -include $(BUILD_PREBUILT) diff --git a/constants.h b/constants.h index b702737..00cbe76 100644 --- a/constants.h +++ b/constants.h @@ -33,10 +33,6 @@ static const char kDefaultVersion[] = "0.0.0.0"; // Build time properties name. static const char kProductId[] = "product_id"; static const char kProductVersion[] = "product_version"; - -// Weave configuration. -static const char kWeaveConfigurationFile[] = "/system/etc/weaved/weaved.conf"; -static const char kModelManifestId[] = "model_id"; } // namespace metrics #endif // METRICS_CONSTANTS_H_ diff --git a/etc/weaved/traits/metrics.json b/etc/weaved/traits/metrics.json deleted file mode 100644 index 7583270..0000000 --- a/etc/weaved/traits/metrics.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "_metrics": { - "commands": { - "enableAnalyticsReporting": { - "minimalRole": "manager", - "parameters": {} - }, - "disableAnalyticsReporting": { - "minimalRole": "manager", - "parameters": {} - } - }, - "state": { - "analyticsReportingState": { - "type": "string", - "enum": [ "enabled", "disabled" ] - } - } - } -} diff --git a/metrics_collector.cc b/metrics_collector.cc index 318caa0..05f7177 100644 --- a/metrics_collector.cc +++ b/metrics_collector.cc @@ -69,11 +69,6 @@ const int kMetricMeminfoInterval = 30; // seconds const char kMeminfoFileName[] = "/proc/meminfo"; const char kVmStatFileName[] = "/proc/vmstat"; -#if USE_WEAVE -const char kWeaveComponent[] = "metrics"; -const char kWeaveTrait[] = "_metrics"; -#endif // USE_WEAVE - } // namespace // Zram sysfs entries. @@ -233,13 +228,6 @@ int MetricsCollector::OnInit() { if (testing_) return EX_OK; -#if USE_WEAVE - weave_service_subscription_ = weaved::Service::Connect( - brillo::MessageLoop::current(), - base::Bind(&MetricsCollector::OnWeaveServiceConnected, - weak_ptr_factory_.GetWeakPtr())); -#endif // USE_WEAVE - latest_cpu_use_microseconds_ = cpu_usage_collector_->GetCumulativeCpuUse(); base::MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind(&MetricsCollector::HandleUpdateStatsTimeout, @@ -249,73 +237,6 @@ int MetricsCollector::OnInit() { return EX_OK; } -#if USE_WEAVE -void MetricsCollector::OnWeaveServiceConnected( - const std::weak_ptr<weaved::Service>& service) { - service_ = service; - auto weave_service = service_.lock(); - if (!weave_service) - return; - - weave_service->AddComponent(kWeaveComponent, {kWeaveTrait}, nullptr); - weave_service->AddCommandHandler( - kWeaveComponent, kWeaveTrait, "enableAnalyticsReporting", - base::Bind(&MetricsCollector::OnEnableMetrics, - weak_ptr_factory_.GetWeakPtr())); - weave_service->AddCommandHandler( - kWeaveComponent, kWeaveTrait, "disableAnalyticsReporting", - base::Bind(&MetricsCollector::OnDisableMetrics, - weak_ptr_factory_.GetWeakPtr())); - - UpdateWeaveState(); -} - -void MetricsCollector::OnEnableMetrics( - std::unique_ptr<weaved::Command> command) { - if (base::WriteFile( - shared_metrics_directory_.Append(metrics::kConsentFileName), "", 0) != - 0) { - PLOG(ERROR) << "Could not create the consent file."; - command->Abort("metrics_error", "Could not create the consent file", - nullptr); - return; - } - - UpdateWeaveState(); - command->Complete({}, nullptr); -} - -void MetricsCollector::OnDisableMetrics( - std::unique_ptr<weaved::Command> command) { - if (!base::DeleteFile( - shared_metrics_directory_.Append(metrics::kConsentFileName), false)) { - PLOG(ERROR) << "Could not delete the consent file."; - command->Abort("metrics_error", "Could not delete the consent file", - nullptr); - return; - } - - UpdateWeaveState(); - command->Complete({}, nullptr); -} - -void MetricsCollector::UpdateWeaveState() { - auto weave_service = service_.lock(); - if (!weave_service) - return; - - std::string enabled = - metrics_lib_->AreMetricsEnabled() ? "enabled" : "disabled"; - - if (!weave_service->SetStateProperty(kWeaveComponent, kWeaveTrait, - "analyticsReportingState", - *brillo::ToValue(enabled), - nullptr)) { - LOG(ERROR) << "failed to update weave's state"; - } -} -#endif // USE_WEAVE - void MetricsCollector::ProcessUserCrash() { // Counts the active time up to now. UpdateStats(TimeTicks::Now(), Time::Now()); diff --git a/metrics_collector.h b/metrics_collector.h index 297a968..475aae4 100644 --- a/metrics_collector.h +++ b/metrics_collector.h @@ -29,10 +29,6 @@ #include <base/time/time.h> #include <brillo/binder_watcher.h> #include <brillo/daemons/daemon.h> -#if USE_WEAVE -#include <libweaved/command.h> -#include <libweaved/service.h> -#endif // USE_WEAVE #include <gtest/gtest_prod.h> // for FRIEND_TEST #include "collectors/averaged_statistics_collector.h" @@ -114,17 +110,6 @@ class MetricsCollector : public brillo::Daemon { int value; // value from /proc/meminfo }; -#if USE_WEAVE - // Enables metrics reporting. - void OnEnableMetrics(std::unique_ptr<weaved::Command> command); - - // Disables metrics reporting. - void OnDisableMetrics(std::unique_ptr<weaved::Command> command); - - // Updates the weave device state. - void UpdateWeaveState(); -#endif // USE WEAVE - // Updates the active use time and logs time between kernel crashes. void ProcessKernelCrash(); @@ -219,12 +204,6 @@ class MetricsCollector : public brillo::Daemon { // Reads a string from a file and converts it to uint64_t. static bool ReadFileToUint64(const base::FilePath& path, uint64_t* value); -#if USE_WEAVE - // Callback invoked when a connection to weaved's service is established - // over Binder interface. - void OnWeaveServiceConnected(const std::weak_ptr<weaved::Service>& service); -#endif // USE_WEAVE - // VARIABLES // Test mode. @@ -281,11 +260,6 @@ class MetricsCollector : public brillo::Daemon { unique_ptr<DiskUsageCollector> disk_usage_collector_; unique_ptr<AveragedStatisticsCollector> averaged_stats_collector_; -#if USE_WEAVE - unique_ptr<weaved::Service::Subscription> weave_service_subscription_; - std::weak_ptr<weaved::Service> service_; -#endif // USE_WEAVE - base::WeakPtrFactory<MetricsCollector> weak_ptr_factory_{this}; }; diff --git a/uploader/system_profile_cache.cc b/uploader/system_profile_cache.cc index e6f6617..ae49a75 100644 --- a/uploader/system_profile_cache.cc +++ b/uploader/system_profile_cache.cc @@ -113,16 +113,6 @@ bool SystemProfileCache::Initialize() { "client_id_test" : GetPersistentGUID(guid_path); profile_.model_manifest_id = "unknown"; - if (!testing_) { - brillo::KeyValueStore weave_config; - if (!weave_config.Load(base::FilePath(metrics::kWeaveConfigurationFile))) { - LOG(ERROR) << "Failed to load the weave configuration file."; - } else if (!weave_config.GetString(metrics::kModelManifestId, - &profile_.model_manifest_id)) { - LOG(ERROR) << "The model manifest id (model_id) is undefined in " - << metrics::kWeaveConfigurationFile; - } - } profile_.channel = ProtoChannelFromString(channel); |