Loading Android.mk +0 −11 Original line number Diff line number Diff line Loading @@ -587,17 +587,6 @@ LOCAL_SRC_FILES += \ lowpan/java/android/net/lowpan/ILowpanManagerListener.aidl \ lowpan/java/android/net/lowpan/ILowpanManager.aidl # StatsLog generated functions statslog_src_dir := $(call intermediates-dir-for,JAVA_LIBRARIES,framework,,COMMON)/statslog gen := $(statslog_src_dir)/android/util/StatsLog.java $(gen): PRIVATE_PATH := $(LOCAL_PATH) $(gen): PRIVATE_CUSTOM_TOOL = $(HOST_OUT_EXECUTABLES)/stats-log-api-gen --java $@ $(gen): $(HOST_OUT_EXECUTABLES)/stats-log-api-gen $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(gen) statslog_src_dir:= gen:= # FRAMEWORKS_BASE_JAVA_SRC_DIRS comes from build/core/pathmap.mk LOCAL_AIDL_INCLUDES += \ $(FRAMEWORKS_BASE_JAVA_SRC_DIRS) \ Loading cmds/statsd/Android.bpdeleted 100644 → 0 +0 −37 Original line number Diff line number Diff line // // Copyright (C) 2015 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. // // ========================================================== // Build the library for use on the host // ========================================================== cc_library_host_shared { name: "libstats_proto_host", srcs: [ "src/stats_events.proto", "src/stats_log.proto", "src/statsd_config.proto", ], shared_libs: [ "libplatformprotos", ], proto: { type: "full", export_proto_headers: true, }, } cmds/statsd/Android.mk +63 −67 Original line number Diff line number Diff line Loading @@ -14,51 +14,22 @@ LOCAL_PATH:= $(call my-dir) # ================ # proto static lib # ================ include $(CLEAR_VARS) statsd_common_src := \ ../../core/java/android/os/IStatsCompanionService.aidl \ ../../core/java/android/os/IStatsManager.aidl \ src/stats_log.proto \ src/statsd_config.proto \ src/stats_events.proto \ src/condition/CombinationConditionTracker.cpp \ src/condition/condition_util.cpp \ src/condition/SimpleConditionTracker.cpp \ src/matchers/CombinationLogMatchingTracker.cpp \ src/matchers/matcher_util.cpp \ src/matchers/SimpleLogMatchingTracker.cpp \ src/metrics/CountAnomalyTracker.cpp \ src/metrics/CountMetricProducer.cpp \ src/metrics/MetricsManager.cpp \ src/metrics/metrics_manager_util.cpp \ src/AnomalyMonitor.cpp \ src/DropboxReader.cpp \ src/DropboxWriter.cpp \ src/KernelWakelockPuller.cpp \ src/LogEntryPrinter.cpp \ src/LogReader.cpp \ src/StatsLogProcessor.cpp \ src/StatsPullerManager.cpp \ src/StatsService.cpp \ src/stats_util.cpp \ src/UidMap.cpp LOCAL_MODULE := statsd_proto LOCAL_MODULE_TAGS := optional statsd_common_c_includes := \ $(LOCAL_PATH)/src LOCAL_SRC_FILES := $(call all-proto-files-under, src) statsd_common_aidl_includes := \ $(LOCAL_PATH)/../../core/java LOCAL_PROTOC_FLAGS := LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static statsd_common_shared_libraries := \ libbase \ libbinder \ libcutils \ libincident \ liblog \ libselinux \ libutils \ libservices \ libandroidfw include $(BUILD_STATIC_LIBRARY) STATSD_PROTO_INCLUDES := $(local-generated-sources-dir)/src/$(LOCAL_PATH) # ========= # statsd Loading @@ -69,8 +40,9 @@ include $(CLEAR_VARS) LOCAL_MODULE := statsd LOCAL_SRC_FILES := \ $(statsd_common_src) \ src/main.cpp ../../core/java/android/os/IStatsCompanionService.aidl \ ../../core/java/android/os/IStatsManager.aidl \ $(call all-cpp-files-under,src) \ LOCAL_CFLAGS += \ -Wall \ Loading @@ -88,12 +60,24 @@ else LOCAL_CFLAGS += \ -Os endif LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static LOCAL_AIDL_INCLUDES := $(statsd_common_c_includes) LOCAL_C_INCLUDES += $(statsd_common_c_includes) LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/../../core/java LOCAL_C_INCLUDES += $(LOCAL_PATH)/src \ STATSD_PROTO_INCLUDES LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) LOCAL_STATIC_LIBRARIES := statsd_proto LOCAL_SHARED_LIBRARIES := \ libbase \ libbinder \ libcutils \ libincident \ liblog \ libselinux \ libutils \ libservices \ libandroidfw \ libprotobuf-cpp-lite \ LOCAL_MODULE_CLASS := EXECUTABLES Loading @@ -101,7 +85,6 @@ LOCAL_MODULE_CLASS := EXECUTABLES include $(BUILD_EXECUTABLE) # ============== # statsd_test # ============== Loading @@ -112,8 +95,8 @@ LOCAL_MODULE := statsd_test LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_MODULE_TAGS := tests LOCAL_AIDL_INCLUDES := $(statsd_common_c_includes) LOCAL_C_INCLUDES += $(statsd_common_c_includes) LOCAL_C_INCLUDES += $(LOCAL_PATH)/src \ STATSD_PROTO_INCLUDES LOCAL_CFLAGS += \ -Wall \ Loading @@ -124,25 +107,38 @@ LOCAL_CFLAGS += \ -Wno-unused-parameter LOCAL_SRC_FILES := \ $(statsd_common_src) \ tests/indexed_priority_queue_test.cpp \ tests/LogReader_test.cpp \ tests/MetricsManager_test.cpp \ tests/UidMap_test.cpp \ tests/LogEntryMatcher_test.cpp \ tests/AnomalyMonitor_test.cpp \ tests/ConditionTracker_test.cpp src/stats_log.proto \ src/statsd_config.proto \ ../../core/java/android/os/IStatsCompanionService.aidl \ ../../core/java/android/os/IStatsManager.aidl \ src/StatsService.cpp \ src/AnomalyMonitor.cpp \ src/stats_util.cpp \ src/LogEntryPrinter.cpp \ src/LogReader.cpp \ src/matchers/matcher_util.cpp \ src/condition/SimpleConditionTracker.cpp \ src/condition/CombinationConditionTracker.cpp \ src/matchers/SimpleLogMatchingTracker.cpp \ src/matchers/CombinationLogMatchingTracker.cpp \ src/metrics/metrics_manager_util.cpp \ src/metrics/CountMetricProducer.cpp \ src/metrics/CountAnomalyTracker.cpp \ src/condition/condition_util.cpp \ src/UidMap.cpp \ $(call all-cpp-files-under, tests) \ LOCAL_STATIC_LIBRARIES := \ libgmock LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) libgmock \ statsd_proto \ LOCAL_PROTOC_OPTIMIZE_TYPE := lite statsd_common_src:= statsd_common_aidl_includes:= statsd_common_c_includes:= LOCAL_SHARED_LIBRARIES := \ libbase \ libbinder \ libcutils \ liblog \ libselinux \ libutils \ libprotobuf-cpp-lite \ include $(BUILD_NATIVE_TEST) cmds/statsd/src/LogEntryPrinter.cpp +10 −23 Original line number Diff line number Diff line Loading @@ -20,11 +20,6 @@ #include <log/logprint.h> #include <utils/Errors.h> #include "matchers/matcher_util.h" #define PRINT_WITH_LIBLOG 0 #define PRINT_WITH_LOG_EVENT_WRAPPER 1 using namespace android; namespace android { Loading @@ -49,7 +44,6 @@ LogEntryPrinter::~LogEntryPrinter() { } void LogEntryPrinter::OnLogEvent(const log_msg& msg) { if (PRINT_WITH_LIBLOG) { status_t err; AndroidLogEntry entry; char buf[1024]; Loading @@ -64,13 +58,6 @@ void LogEntryPrinter::OnLogEvent(const log_msg& msg) { } } if (PRINT_WITH_LOG_EVENT_WRAPPER) { LogEventWrapper event = parseLogEvent(msg); printf("event: %s\n", event.toString().c_str()); fflush(stdout); } } } // namespace statsd } // namespace os } // namespace android cmds/statsd/src/matchers/matcher_util.cpp +26 −55 Original line number Diff line number Diff line Loading @@ -26,11 +26,8 @@ #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" #include "stats_util.h" #include <sstream> using std::set; using std::string; using std::ostringstream; using std::unordered_map; using std::vector; Loading @@ -38,42 +35,6 @@ namespace android { namespace os { namespace statsd { string LogEventWrapper::toString() const { std::ostringstream result; result << "{ " << timestamp_ns << " (" << tagId << ")"; for (int index = 1; ; index++) { auto intVal = intMap.find(index); auto strVal = strMap.find(index); auto boolVal = boolMap.find(index); auto floatVal = floatMap.find(index); if (intVal != intMap.end()) { result << " "; result << std::to_string(index); result << "->"; result << std::to_string(intVal->second); } else if (strVal != strMap.end()) { result << " "; result << std::to_string(index); result << "->"; result << strVal->second; } else if (boolVal != boolMap.end()) { result << " "; result << std::to_string(index); result << "->"; result << std::to_string(boolVal->second); } else if (floatVal != floatMap.end()) { result << " "; result << std::to_string(index); result << "->"; result << std::to_string(floatVal->second); } else { break; } } result << " }"; return result.str(); } LogEventWrapper parseLogEvent(log_msg msg) { LogEventWrapper wrapper; wrapper.timestamp_ns = msg.entry_v1.sec * NS_PER_SEC + msg.entry_v1.nsec; Loading @@ -87,32 +48,38 @@ LogEventWrapper parseLogEvent(log_msg msg) { if (context) { memset(&elem, 0, sizeof(elem)); // TODO: The log is actually structured inside one list. This is convenient // because we'll be able to use it to put the attribution (WorkSource) block first // without doing our own tagging scheme. Until that change is in, just drop the // list-related log elements and the order we get there is our index-keyed data // structure. int32_t key = 1; size_t index = 0; int32_t key = -1; do { elem = android_log_read_next(context); switch ((int)elem.type) { case EVENT_TYPE_INT: if (index % 2 == 0) { key = elem.data.int32; } else { wrapper.intMap[key] = elem.data.int32; key++; } index++; break; case EVENT_TYPE_FLOAT: if (index % 2 == 1) { wrapper.floatMap[key] = elem.data.float32; key++; } index++; break; case EVENT_TYPE_STRING: if (index % 2 == 1) { // without explicit calling string() constructor, there will be an // additional 0 in the end of the string. wrapper.strMap[key] = string(elem.data.string); key++; } index++; break; case EVENT_TYPE_LONG: if (index % 2 == 1) { wrapper.intMap[key] = elem.data.int64; key++; } index++; break; case EVENT_TYPE_LIST: break; Loading @@ -124,6 +91,10 @@ LogEventWrapper parseLogEvent(log_msg msg) { elem.complete = true; break; } if (elem.complete) { break; } } while ((elem.type != EVENT_TYPE_UNKNOWN) && !elem.complete); android_log_destroy(&context); Loading Loading
Android.mk +0 −11 Original line number Diff line number Diff line Loading @@ -587,17 +587,6 @@ LOCAL_SRC_FILES += \ lowpan/java/android/net/lowpan/ILowpanManagerListener.aidl \ lowpan/java/android/net/lowpan/ILowpanManager.aidl # StatsLog generated functions statslog_src_dir := $(call intermediates-dir-for,JAVA_LIBRARIES,framework,,COMMON)/statslog gen := $(statslog_src_dir)/android/util/StatsLog.java $(gen): PRIVATE_PATH := $(LOCAL_PATH) $(gen): PRIVATE_CUSTOM_TOOL = $(HOST_OUT_EXECUTABLES)/stats-log-api-gen --java $@ $(gen): $(HOST_OUT_EXECUTABLES)/stats-log-api-gen $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(gen) statslog_src_dir:= gen:= # FRAMEWORKS_BASE_JAVA_SRC_DIRS comes from build/core/pathmap.mk LOCAL_AIDL_INCLUDES += \ $(FRAMEWORKS_BASE_JAVA_SRC_DIRS) \ Loading
cmds/statsd/Android.bpdeleted 100644 → 0 +0 −37 Original line number Diff line number Diff line // // Copyright (C) 2015 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. // // ========================================================== // Build the library for use on the host // ========================================================== cc_library_host_shared { name: "libstats_proto_host", srcs: [ "src/stats_events.proto", "src/stats_log.proto", "src/statsd_config.proto", ], shared_libs: [ "libplatformprotos", ], proto: { type: "full", export_proto_headers: true, }, }
cmds/statsd/Android.mk +63 −67 Original line number Diff line number Diff line Loading @@ -14,51 +14,22 @@ LOCAL_PATH:= $(call my-dir) # ================ # proto static lib # ================ include $(CLEAR_VARS) statsd_common_src := \ ../../core/java/android/os/IStatsCompanionService.aidl \ ../../core/java/android/os/IStatsManager.aidl \ src/stats_log.proto \ src/statsd_config.proto \ src/stats_events.proto \ src/condition/CombinationConditionTracker.cpp \ src/condition/condition_util.cpp \ src/condition/SimpleConditionTracker.cpp \ src/matchers/CombinationLogMatchingTracker.cpp \ src/matchers/matcher_util.cpp \ src/matchers/SimpleLogMatchingTracker.cpp \ src/metrics/CountAnomalyTracker.cpp \ src/metrics/CountMetricProducer.cpp \ src/metrics/MetricsManager.cpp \ src/metrics/metrics_manager_util.cpp \ src/AnomalyMonitor.cpp \ src/DropboxReader.cpp \ src/DropboxWriter.cpp \ src/KernelWakelockPuller.cpp \ src/LogEntryPrinter.cpp \ src/LogReader.cpp \ src/StatsLogProcessor.cpp \ src/StatsPullerManager.cpp \ src/StatsService.cpp \ src/stats_util.cpp \ src/UidMap.cpp LOCAL_MODULE := statsd_proto LOCAL_MODULE_TAGS := optional statsd_common_c_includes := \ $(LOCAL_PATH)/src LOCAL_SRC_FILES := $(call all-proto-files-under, src) statsd_common_aidl_includes := \ $(LOCAL_PATH)/../../core/java LOCAL_PROTOC_FLAGS := LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static statsd_common_shared_libraries := \ libbase \ libbinder \ libcutils \ libincident \ liblog \ libselinux \ libutils \ libservices \ libandroidfw include $(BUILD_STATIC_LIBRARY) STATSD_PROTO_INCLUDES := $(local-generated-sources-dir)/src/$(LOCAL_PATH) # ========= # statsd Loading @@ -69,8 +40,9 @@ include $(CLEAR_VARS) LOCAL_MODULE := statsd LOCAL_SRC_FILES := \ $(statsd_common_src) \ src/main.cpp ../../core/java/android/os/IStatsCompanionService.aidl \ ../../core/java/android/os/IStatsManager.aidl \ $(call all-cpp-files-under,src) \ LOCAL_CFLAGS += \ -Wall \ Loading @@ -88,12 +60,24 @@ else LOCAL_CFLAGS += \ -Os endif LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static LOCAL_AIDL_INCLUDES := $(statsd_common_c_includes) LOCAL_C_INCLUDES += $(statsd_common_c_includes) LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/../../core/java LOCAL_C_INCLUDES += $(LOCAL_PATH)/src \ STATSD_PROTO_INCLUDES LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) LOCAL_STATIC_LIBRARIES := statsd_proto LOCAL_SHARED_LIBRARIES := \ libbase \ libbinder \ libcutils \ libincident \ liblog \ libselinux \ libutils \ libservices \ libandroidfw \ libprotobuf-cpp-lite \ LOCAL_MODULE_CLASS := EXECUTABLES Loading @@ -101,7 +85,6 @@ LOCAL_MODULE_CLASS := EXECUTABLES include $(BUILD_EXECUTABLE) # ============== # statsd_test # ============== Loading @@ -112,8 +95,8 @@ LOCAL_MODULE := statsd_test LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_MODULE_TAGS := tests LOCAL_AIDL_INCLUDES := $(statsd_common_c_includes) LOCAL_C_INCLUDES += $(statsd_common_c_includes) LOCAL_C_INCLUDES += $(LOCAL_PATH)/src \ STATSD_PROTO_INCLUDES LOCAL_CFLAGS += \ -Wall \ Loading @@ -124,25 +107,38 @@ LOCAL_CFLAGS += \ -Wno-unused-parameter LOCAL_SRC_FILES := \ $(statsd_common_src) \ tests/indexed_priority_queue_test.cpp \ tests/LogReader_test.cpp \ tests/MetricsManager_test.cpp \ tests/UidMap_test.cpp \ tests/LogEntryMatcher_test.cpp \ tests/AnomalyMonitor_test.cpp \ tests/ConditionTracker_test.cpp src/stats_log.proto \ src/statsd_config.proto \ ../../core/java/android/os/IStatsCompanionService.aidl \ ../../core/java/android/os/IStatsManager.aidl \ src/StatsService.cpp \ src/AnomalyMonitor.cpp \ src/stats_util.cpp \ src/LogEntryPrinter.cpp \ src/LogReader.cpp \ src/matchers/matcher_util.cpp \ src/condition/SimpleConditionTracker.cpp \ src/condition/CombinationConditionTracker.cpp \ src/matchers/SimpleLogMatchingTracker.cpp \ src/matchers/CombinationLogMatchingTracker.cpp \ src/metrics/metrics_manager_util.cpp \ src/metrics/CountMetricProducer.cpp \ src/metrics/CountAnomalyTracker.cpp \ src/condition/condition_util.cpp \ src/UidMap.cpp \ $(call all-cpp-files-under, tests) \ LOCAL_STATIC_LIBRARIES := \ libgmock LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) libgmock \ statsd_proto \ LOCAL_PROTOC_OPTIMIZE_TYPE := lite statsd_common_src:= statsd_common_aidl_includes:= statsd_common_c_includes:= LOCAL_SHARED_LIBRARIES := \ libbase \ libbinder \ libcutils \ liblog \ libselinux \ libutils \ libprotobuf-cpp-lite \ include $(BUILD_NATIVE_TEST)
cmds/statsd/src/LogEntryPrinter.cpp +10 −23 Original line number Diff line number Diff line Loading @@ -20,11 +20,6 @@ #include <log/logprint.h> #include <utils/Errors.h> #include "matchers/matcher_util.h" #define PRINT_WITH_LIBLOG 0 #define PRINT_WITH_LOG_EVENT_WRAPPER 1 using namespace android; namespace android { Loading @@ -49,7 +44,6 @@ LogEntryPrinter::~LogEntryPrinter() { } void LogEntryPrinter::OnLogEvent(const log_msg& msg) { if (PRINT_WITH_LIBLOG) { status_t err; AndroidLogEntry entry; char buf[1024]; Loading @@ -64,13 +58,6 @@ void LogEntryPrinter::OnLogEvent(const log_msg& msg) { } } if (PRINT_WITH_LOG_EVENT_WRAPPER) { LogEventWrapper event = parseLogEvent(msg); printf("event: %s\n", event.toString().c_str()); fflush(stdout); } } } // namespace statsd } // namespace os } // namespace android
cmds/statsd/src/matchers/matcher_util.cpp +26 −55 Original line number Diff line number Diff line Loading @@ -26,11 +26,8 @@ #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" #include "stats_util.h" #include <sstream> using std::set; using std::string; using std::ostringstream; using std::unordered_map; using std::vector; Loading @@ -38,42 +35,6 @@ namespace android { namespace os { namespace statsd { string LogEventWrapper::toString() const { std::ostringstream result; result << "{ " << timestamp_ns << " (" << tagId << ")"; for (int index = 1; ; index++) { auto intVal = intMap.find(index); auto strVal = strMap.find(index); auto boolVal = boolMap.find(index); auto floatVal = floatMap.find(index); if (intVal != intMap.end()) { result << " "; result << std::to_string(index); result << "->"; result << std::to_string(intVal->second); } else if (strVal != strMap.end()) { result << " "; result << std::to_string(index); result << "->"; result << strVal->second; } else if (boolVal != boolMap.end()) { result << " "; result << std::to_string(index); result << "->"; result << std::to_string(boolVal->second); } else if (floatVal != floatMap.end()) { result << " "; result << std::to_string(index); result << "->"; result << std::to_string(floatVal->second); } else { break; } } result << " }"; return result.str(); } LogEventWrapper parseLogEvent(log_msg msg) { LogEventWrapper wrapper; wrapper.timestamp_ns = msg.entry_v1.sec * NS_PER_SEC + msg.entry_v1.nsec; Loading @@ -87,32 +48,38 @@ LogEventWrapper parseLogEvent(log_msg msg) { if (context) { memset(&elem, 0, sizeof(elem)); // TODO: The log is actually structured inside one list. This is convenient // because we'll be able to use it to put the attribution (WorkSource) block first // without doing our own tagging scheme. Until that change is in, just drop the // list-related log elements and the order we get there is our index-keyed data // structure. int32_t key = 1; size_t index = 0; int32_t key = -1; do { elem = android_log_read_next(context); switch ((int)elem.type) { case EVENT_TYPE_INT: if (index % 2 == 0) { key = elem.data.int32; } else { wrapper.intMap[key] = elem.data.int32; key++; } index++; break; case EVENT_TYPE_FLOAT: if (index % 2 == 1) { wrapper.floatMap[key] = elem.data.float32; key++; } index++; break; case EVENT_TYPE_STRING: if (index % 2 == 1) { // without explicit calling string() constructor, there will be an // additional 0 in the end of the string. wrapper.strMap[key] = string(elem.data.string); key++; } index++; break; case EVENT_TYPE_LONG: if (index % 2 == 1) { wrapper.intMap[key] = elem.data.int64; key++; } index++; break; case EVENT_TYPE_LIST: break; Loading @@ -124,6 +91,10 @@ LogEventWrapper parseLogEvent(log_msg msg) { elem.complete = true; break; } if (elem.complete) { break; } } while ((elem.type != EVENT_TYPE_UNKNOWN) && !elem.complete); android_log_destroy(&context); Loading