Loading Android.mk +10 −11 Original line number Diff line number Diff line Loading @@ -945,21 +945,21 @@ $(LOCAL_LIGHT_GREYLIST): $(LOCAL_SRC_ALL) $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) $(call assert-has-no-overlap,$@,$(LOCAL_SRC_FORCE_BLACKLIST)) # Generate dark greylist as remaining members of classes on the light greylist, # as well as the members of their inner classes. # Generate dark greylist as remaining classes and class members in the same # package as classes listed in the light greylist. # The algorithm is as follows: # (1) extract the class descriptor from each entry in LOCAL_LIGHT_GREYLIST # (2) strip the final semicolon and anything after (and including) a dollar sign, # e.g. 'Lpackage/class$inner;' turns into 'Lpackage/class' # (3) insert all entries from LOCAL_SRC_PRIVATE_API which begin with the stripped # descriptor followed by a semi-colon or a dollar sign, e.g. matching a regex # '^Lpackage/class[;$]' # (2) strip everything after the last forward-slash, # e.g. 'Lpackage/subpackage/class$inner;' turns into 'Lpackage/subpackage/' # (3) insert all entries from LOCAL_SRC_PRIVATE_API which begin with the package # name but do not contain another forward-slash in the class name, e.g. # matching '^Lpackage/subpackage/[^/;]*;' # (4) subtract entries shared with LOCAL_LIGHT_GREYLIST $(LOCAL_DARK_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST) comm -13 <(sort $(LOCAL_LIGHT_GREYLIST) $(LOCAL_SRC_FORCE_BLACKLIST)) \ <(sed 's/;\->.*//' $(LOCAL_LIGHT_GREYLIST) | sed 's/$$.*//' | sort | uniq | \ while read CLASS_DESC; do \ grep -E "^$${CLASS_DESC}[;$$]" $(LOCAL_SRC_PRIVATE_API); \ <(sed 's/\->.*//' $(LOCAL_LIGHT_GREYLIST) | sed 's/\(.*\/\).*/\1/' | sort | uniq | \ while read PKG_NAME; do \ grep -E "^$${PKG_NAME}[^/;]*;" $(LOCAL_SRC_PRIVATE_API); \ done | sort | uniq) \ > $@ $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) Loading Loading @@ -988,4 +988,3 @@ include $(call first-makefiles-under,$(LOCAL_PATH)) endif endif # ANDROID_BUILD_EMBEDDED cmds/statsd/src/StatsLogProcessor.cpp +5 −10 Original line number Diff line number Diff line Loading @@ -306,7 +306,6 @@ void StatsLogProcessor::dumpStates(FILE* out, bool verbose) { */ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTimeStampNs, const bool include_current_partial_bucket, const bool include_string, const DumpReportReason dumpReportReason, vector<uint8_t>* outData) { std::lock_guard<std::mutex> lock(mMetricsMutex); Loading Loading @@ -334,7 +333,7 @@ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTim uint64_t reportsToken = proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_REPORTS); onConfigMetricsReportLocked(key, dumpTimeStampNs, include_current_partial_bucket, include_string, dumpReportReason, &proto); dumpReportReason, &proto); proto.end(reportsToken); // End of ConfigMetricsReport (reports). } else { Loading Loading @@ -363,7 +362,6 @@ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTim void StatsLogProcessor::onConfigMetricsReportLocked(const ConfigKey& key, const int64_t dumpTimeStampNs, const bool include_current_partial_bucket, const bool include_string, const DumpReportReason dumpReportReason, ProtoOutputStream* proto) { // We already checked whether key exists in mMetricsManagers in Loading Loading @@ -402,12 +400,10 @@ void StatsLogProcessor::onConfigMetricsReportLocked(const ConfigKey& key, // Dump report reason proto->write(FIELD_TYPE_INT32 | FIELD_ID_DUMP_REPORT_REASON, dumpReportReason); if (include_string) { for (const auto& str : str_set) { proto->write(FIELD_TYPE_STRING | FIELD_COUNT_REPEATED | FIELD_ID_STRINGS, str); } } } void StatsLogProcessor::resetConfigsLocked(const int64_t timestampNs, const std::vector<ConfigKey>& configs) { Loading Loading @@ -508,9 +504,8 @@ void StatsLogProcessor::WriteDataToDiskLocked(const ConfigKey& key, return; } ProtoOutputStream proto; onConfigMetricsReportLocked(key, timestampNs, true /* include_current_partial_bucket*/, false /* include strings */, dumpReportReason, &proto); onConfigMetricsReportLocked(key, timestampNs, true /* include_current_partial_bucket*/, dumpReportReason, &proto); string file_name = StringPrintf("%s/%ld_%d_%lld", STATS_DATA_DIR, (long)getWallClockSec(), key.GetUid(), (long long)key.GetId()); android::base::unique_fd fd(open(file_name.c_str(), Loading cmds/statsd/src/StatsLogProcessor.h +1 −2 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public: size_t GetMetricsSize(const ConfigKey& key) const; void onDumpReport(const ConfigKey& key, const int64_t dumpTimeNs, const bool include_current_partial_bucket, const bool include_string, const bool include_current_partial_bucket, const DumpReportReason dumpReportReason, vector<uint8_t>* outData); /* Tells MetricsManager that the alarms in alarmSet have fired. Modifies anomaly alarmSet. */ Loading Loading @@ -143,7 +143,6 @@ private: void onConfigMetricsReportLocked(const ConfigKey& key, const int64_t dumpTimeStampNs, const bool include_current_partial_bucket, const bool include_string, const DumpReportReason dumpReportReason, util::ProtoOutputStream* proto); Loading cmds/statsd/src/StatsService.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -602,8 +602,7 @@ status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String if (good) { vector<uint8_t> data; mProcessor->onDumpReport(ConfigKey(uid, StrToInt64(name)), getElapsedRealtimeNs(), false /* include_current_bucket*/, true /* include strings */, ADB_DUMP, &data); false /* include_current_bucket*/, ADB_DUMP, &data); // TODO: print the returned StatsLogReport to file instead of printing to logcat. if (proto) { for (size_t i = 0; i < data.size(); i ++) { Loading Loading @@ -892,8 +891,7 @@ Status StatsService::getData(int64_t key, const String16& packageName, vector<ui IPCThreadState* ipc = IPCThreadState::self(); VLOG("StatsService::getData with Pid %i, Uid %i", ipc->getCallingPid(), ipc->getCallingUid()); ConfigKey configKey(ipc->getCallingUid(), key); mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(), false /* include_current_bucket*/, true /* include strings */, mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(), false /* include_current_bucket*/, GET_DATA_CALLED, output); return Status::ok(); } Loading cmds/statsd/src/metrics/GaugeMetricProducer.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,8 @@ GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric mDimensionHardLimit(StatsdStats::kAtomDimensionKeySizeLimitMap.find(pullTagId) != StatsdStats::kAtomDimensionKeySizeLimitMap.end() ? StatsdStats::kAtomDimensionKeySizeLimitMap.at(pullTagId).second : StatsdStats::kDimensionKeySizeHardLimit) { : StatsdStats::kDimensionKeySizeHardLimit), mGaugeAtomsPerDimensionLimit(metric.max_num_gauge_atoms_per_bucket()) { mCurrentSlicedBucket = std::make_shared<DimToGaugeAtomsMap>(); mCurrentSlicedBucketForAnomaly = std::make_shared<DimToValMap>(); int64_t bucketSizeMills = 0; Loading Loading @@ -433,6 +434,9 @@ void GaugeMetricProducer::onMatchedLogEventInternalLocked( if (hitGuardRailLocked(eventKey)) { return; } if ((*mCurrentSlicedBucket)[eventKey].size() >= mGaugeAtomsPerDimensionLimit) { return; } GaugeAtom gaugeAtom(getGaugeFields(event), eventTimeNs, getWallClockNs()); (*mCurrentSlicedBucket)[eventKey].push_back(gaugeAtom); // Anomaly detection on gauge metric only works when there is one numeric Loading Loading
Android.mk +10 −11 Original line number Diff line number Diff line Loading @@ -945,21 +945,21 @@ $(LOCAL_LIGHT_GREYLIST): $(LOCAL_SRC_ALL) $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) $(call assert-has-no-overlap,$@,$(LOCAL_SRC_FORCE_BLACKLIST)) # Generate dark greylist as remaining members of classes on the light greylist, # as well as the members of their inner classes. # Generate dark greylist as remaining classes and class members in the same # package as classes listed in the light greylist. # The algorithm is as follows: # (1) extract the class descriptor from each entry in LOCAL_LIGHT_GREYLIST # (2) strip the final semicolon and anything after (and including) a dollar sign, # e.g. 'Lpackage/class$inner;' turns into 'Lpackage/class' # (3) insert all entries from LOCAL_SRC_PRIVATE_API which begin with the stripped # descriptor followed by a semi-colon or a dollar sign, e.g. matching a regex # '^Lpackage/class[;$]' # (2) strip everything after the last forward-slash, # e.g. 'Lpackage/subpackage/class$inner;' turns into 'Lpackage/subpackage/' # (3) insert all entries from LOCAL_SRC_PRIVATE_API which begin with the package # name but do not contain another forward-slash in the class name, e.g. # matching '^Lpackage/subpackage/[^/;]*;' # (4) subtract entries shared with LOCAL_LIGHT_GREYLIST $(LOCAL_DARK_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST) comm -13 <(sort $(LOCAL_LIGHT_GREYLIST) $(LOCAL_SRC_FORCE_BLACKLIST)) \ <(sed 's/;\->.*//' $(LOCAL_LIGHT_GREYLIST) | sed 's/$$.*//' | sort | uniq | \ while read CLASS_DESC; do \ grep -E "^$${CLASS_DESC}[;$$]" $(LOCAL_SRC_PRIVATE_API); \ <(sed 's/\->.*//' $(LOCAL_LIGHT_GREYLIST) | sed 's/\(.*\/\).*/\1/' | sort | uniq | \ while read PKG_NAME; do \ grep -E "^$${PKG_NAME}[^/;]*;" $(LOCAL_SRC_PRIVATE_API); \ done | sort | uniq) \ > $@ $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) Loading Loading @@ -988,4 +988,3 @@ include $(call first-makefiles-under,$(LOCAL_PATH)) endif endif # ANDROID_BUILD_EMBEDDED
cmds/statsd/src/StatsLogProcessor.cpp +5 −10 Original line number Diff line number Diff line Loading @@ -306,7 +306,6 @@ void StatsLogProcessor::dumpStates(FILE* out, bool verbose) { */ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTimeStampNs, const bool include_current_partial_bucket, const bool include_string, const DumpReportReason dumpReportReason, vector<uint8_t>* outData) { std::lock_guard<std::mutex> lock(mMetricsMutex); Loading Loading @@ -334,7 +333,7 @@ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTim uint64_t reportsToken = proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_REPORTS); onConfigMetricsReportLocked(key, dumpTimeStampNs, include_current_partial_bucket, include_string, dumpReportReason, &proto); dumpReportReason, &proto); proto.end(reportsToken); // End of ConfigMetricsReport (reports). } else { Loading Loading @@ -363,7 +362,6 @@ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTim void StatsLogProcessor::onConfigMetricsReportLocked(const ConfigKey& key, const int64_t dumpTimeStampNs, const bool include_current_partial_bucket, const bool include_string, const DumpReportReason dumpReportReason, ProtoOutputStream* proto) { // We already checked whether key exists in mMetricsManagers in Loading Loading @@ -402,12 +400,10 @@ void StatsLogProcessor::onConfigMetricsReportLocked(const ConfigKey& key, // Dump report reason proto->write(FIELD_TYPE_INT32 | FIELD_ID_DUMP_REPORT_REASON, dumpReportReason); if (include_string) { for (const auto& str : str_set) { proto->write(FIELD_TYPE_STRING | FIELD_COUNT_REPEATED | FIELD_ID_STRINGS, str); } } } void StatsLogProcessor::resetConfigsLocked(const int64_t timestampNs, const std::vector<ConfigKey>& configs) { Loading Loading @@ -508,9 +504,8 @@ void StatsLogProcessor::WriteDataToDiskLocked(const ConfigKey& key, return; } ProtoOutputStream proto; onConfigMetricsReportLocked(key, timestampNs, true /* include_current_partial_bucket*/, false /* include strings */, dumpReportReason, &proto); onConfigMetricsReportLocked(key, timestampNs, true /* include_current_partial_bucket*/, dumpReportReason, &proto); string file_name = StringPrintf("%s/%ld_%d_%lld", STATS_DATA_DIR, (long)getWallClockSec(), key.GetUid(), (long long)key.GetId()); android::base::unique_fd fd(open(file_name.c_str(), Loading
cmds/statsd/src/StatsLogProcessor.h +1 −2 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public: size_t GetMetricsSize(const ConfigKey& key) const; void onDumpReport(const ConfigKey& key, const int64_t dumpTimeNs, const bool include_current_partial_bucket, const bool include_string, const bool include_current_partial_bucket, const DumpReportReason dumpReportReason, vector<uint8_t>* outData); /* Tells MetricsManager that the alarms in alarmSet have fired. Modifies anomaly alarmSet. */ Loading Loading @@ -143,7 +143,6 @@ private: void onConfigMetricsReportLocked(const ConfigKey& key, const int64_t dumpTimeStampNs, const bool include_current_partial_bucket, const bool include_string, const DumpReportReason dumpReportReason, util::ProtoOutputStream* proto); Loading
cmds/statsd/src/StatsService.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -602,8 +602,7 @@ status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String if (good) { vector<uint8_t> data; mProcessor->onDumpReport(ConfigKey(uid, StrToInt64(name)), getElapsedRealtimeNs(), false /* include_current_bucket*/, true /* include strings */, ADB_DUMP, &data); false /* include_current_bucket*/, ADB_DUMP, &data); // TODO: print the returned StatsLogReport to file instead of printing to logcat. if (proto) { for (size_t i = 0; i < data.size(); i ++) { Loading Loading @@ -892,8 +891,7 @@ Status StatsService::getData(int64_t key, const String16& packageName, vector<ui IPCThreadState* ipc = IPCThreadState::self(); VLOG("StatsService::getData with Pid %i, Uid %i", ipc->getCallingPid(), ipc->getCallingUid()); ConfigKey configKey(ipc->getCallingUid(), key); mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(), false /* include_current_bucket*/, true /* include strings */, mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(), false /* include_current_bucket*/, GET_DATA_CALLED, output); return Status::ok(); } Loading
cmds/statsd/src/metrics/GaugeMetricProducer.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,8 @@ GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric mDimensionHardLimit(StatsdStats::kAtomDimensionKeySizeLimitMap.find(pullTagId) != StatsdStats::kAtomDimensionKeySizeLimitMap.end() ? StatsdStats::kAtomDimensionKeySizeLimitMap.at(pullTagId).second : StatsdStats::kDimensionKeySizeHardLimit) { : StatsdStats::kDimensionKeySizeHardLimit), mGaugeAtomsPerDimensionLimit(metric.max_num_gauge_atoms_per_bucket()) { mCurrentSlicedBucket = std::make_shared<DimToGaugeAtomsMap>(); mCurrentSlicedBucketForAnomaly = std::make_shared<DimToValMap>(); int64_t bucketSizeMills = 0; Loading Loading @@ -433,6 +434,9 @@ void GaugeMetricProducer::onMatchedLogEventInternalLocked( if (hitGuardRailLocked(eventKey)) { return; } if ((*mCurrentSlicedBucket)[eventKey].size() >= mGaugeAtomsPerDimensionLimit) { return; } GaugeAtom gaugeAtom(getGaugeFields(event), eventTimeNs, getWallClockNs()); (*mCurrentSlicedBucket)[eventKey].push_back(gaugeAtom); // Anomaly detection on gauge metric only works when there is one numeric Loading