Merge "Remove kAtomsWithUidField from atoms_info" into rvc-dev am: 04d2f143cd
Change-Id: I3369d14bd2fd7f7c0c09204727035ffa0a5f6e35
This commit is contained in:
@@ -120,9 +120,9 @@ bool isAttributionUidField(const FieldValue& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t getUidIfExists(const FieldValue& value) {
|
int32_t getUidIfExists(const FieldValue& value) {
|
||||||
// the field is uid field if the field is the uid field in attribution node or marked as
|
// the field is uid field if the field is the uid field in attribution node
|
||||||
// is_uid in atoms.proto
|
// or annotated as such in the atom
|
||||||
bool isUid = isAttributionUidField(value) || isUidField(value.mField, value.mValue);
|
bool isUid = isAttributionUidField(value) || isUidField(value);
|
||||||
return isUid ? value.mValue.int_value : -1;
|
return isUid ? value.mValue.int_value : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,16 +134,8 @@ bool isAttributionUidField(const Field& field, const Value& value) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isUidField(const Field& field, const Value& value) {
|
bool isUidField(const FieldValue& fieldValue) {
|
||||||
auto it = android::util::AtomsInfo::kAtomsWithUidField.find(field.getTag());
|
return fieldValue.mAnnotations.isUidField();
|
||||||
|
|
||||||
if (it != android::util::AtomsInfo::kAtomsWithUidField.end()) {
|
|
||||||
int uidField = it->second; // uidField is the field number in proto
|
|
||||||
return field.getDepth() == 0 && field.getPosAtDepth(0) == uidField &&
|
|
||||||
value.getType() == INT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const Value& from) {
|
Value::Value(const Value& from) {
|
||||||
|
|||||||
@@ -367,7 +367,8 @@ public:
|
|||||||
enum {
|
enum {
|
||||||
NESTED_POS = 0x0,
|
NESTED_POS = 0x0,
|
||||||
PRIMARY_POS = 0x1,
|
PRIMARY_POS = 0x1,
|
||||||
EXCLUSIVE_POS = 0x2
|
EXCLUSIVE_POS = 0x2,
|
||||||
|
UID_POS = 0x3
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setNested(bool nested) { setBitmaskAtPos(NESTED_POS, nested); }
|
inline void setNested(bool nested) { setBitmaskAtPos(NESTED_POS, nested); }
|
||||||
@@ -376,6 +377,8 @@ public:
|
|||||||
|
|
||||||
inline void setExclusiveState(bool exclusive) { setBitmaskAtPos(EXCLUSIVE_POS, exclusive); }
|
inline void setExclusiveState(bool exclusive) { setBitmaskAtPos(EXCLUSIVE_POS, exclusive); }
|
||||||
|
|
||||||
|
inline void setUidField(bool isUid) { setBitmaskAtPos(UID_POS, isUid); }
|
||||||
|
|
||||||
inline void setResetState(int resetState) { mResetState = resetState; }
|
inline void setResetState(int resetState) { mResetState = resetState; }
|
||||||
|
|
||||||
// Default value = false
|
// Default value = false
|
||||||
@@ -387,6 +390,9 @@ public:
|
|||||||
// Default value = false
|
// Default value = false
|
||||||
inline bool isExclusiveState() const { return getValueFromBitmask(EXCLUSIVE_POS); }
|
inline bool isExclusiveState() const { return getValueFromBitmask(EXCLUSIVE_POS); }
|
||||||
|
|
||||||
|
// Default value = false
|
||||||
|
inline bool isUidField() const { return getValueFromBitmask(UID_POS); }
|
||||||
|
|
||||||
// If a reset state is not sent in the StatsEvent, returns -1. Note that a
|
// If a reset state is not sent in the StatsEvent, returns -1. Note that a
|
||||||
// reset satate is only sent if and only if a reset should be triggered.
|
// reset satate is only sent if and only if a reset should be triggered.
|
||||||
inline int getResetState() const { return mResetState; }
|
inline int getResetState() const { return mResetState; }
|
||||||
@@ -402,7 +408,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This is a bitmask over all annotations stored in boolean form. Because
|
// This is a bitmask over all annotations stored in boolean form. Because
|
||||||
// there are only 3 booleans, just one byte is required.
|
// there are only 4 booleans, just one byte is required.
|
||||||
uint8_t mBooleanBitmask = 0;
|
uint8_t mBooleanBitmask = 0;
|
||||||
|
|
||||||
int mResetState = -1;
|
int mResetState = -1;
|
||||||
@@ -449,7 +455,7 @@ int getUidIfExists(const FieldValue& value);
|
|||||||
void translateFieldMatcher(const FieldMatcher& matcher, std::vector<Matcher>* output);
|
void translateFieldMatcher(const FieldMatcher& matcher, std::vector<Matcher>* output);
|
||||||
|
|
||||||
bool isAttributionUidField(const Field& field, const Value& value);
|
bool isAttributionUidField(const Field& field, const Value& value);
|
||||||
bool isUidField(const Field& field, const Value& value);
|
bool isUidField(const FieldValue& fieldValue);
|
||||||
|
|
||||||
bool equalDimensions(const std::vector<Matcher>& dimension_a,
|
bool equalDimensions(const std::vector<Matcher>& dimension_a,
|
||||||
const std::vector<Matcher>& dimension_b);
|
const std::vector<Matcher>& dimension_b);
|
||||||
|
|||||||
@@ -138,13 +138,6 @@ void StatsLogProcessor::onPeriodicAlarmFired(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateUid(Value* value, int hostUid) {
|
|
||||||
int uid = value->int_value;
|
|
||||||
if (uid != hostUid) {
|
|
||||||
value->setInt(hostUid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const {
|
void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const {
|
||||||
if (android::util::AtomsInfo::kAtomsWithAttributionChain.find(event->GetTagId()) !=
|
if (android::util::AtomsInfo::kAtomsWithAttributionChain.find(event->GetTagId()) !=
|
||||||
android::util::AtomsInfo::kAtomsWithAttributionChain.end()) {
|
android::util::AtomsInfo::kAtomsWithAttributionChain.end()) {
|
||||||
@@ -154,22 +147,15 @@ void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event
|
|||||||
}
|
}
|
||||||
if (isAttributionUidField(value)) {
|
if (isAttributionUidField(value)) {
|
||||||
const int hostUid = mUidMap->getHostUidOrSelf(value.mValue.int_value);
|
const int hostUid = mUidMap->getHostUidOrSelf(value.mValue.int_value);
|
||||||
updateUid(&value.mValue, hostUid);
|
value.mValue.setInt(hostUid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto it = android::util::AtomsInfo::kAtomsWithUidField.find(event->GetTagId());
|
int uidFieldIndex = event->getUidFieldIndex();
|
||||||
if (it != android::util::AtomsInfo::kAtomsWithUidField.end()) {
|
if (uidFieldIndex != -1) {
|
||||||
int uidField = it->second; // uidField is the field number in proto,
|
Value& value = (*event->getMutableValues())[uidFieldIndex].mValue;
|
||||||
// starting from 1
|
const int hostUid = mUidMap->getHostUidOrSelf(value.int_value);
|
||||||
if (uidField > 0 && (int)event->getValues().size() >= uidField &&
|
value.setInt(hostUid);
|
||||||
(event->getValues())[uidField - 1].mValue.getType() == INT) {
|
|
||||||
Value& value = (*event->getMutableValues())[uidField - 1].mValue;
|
|
||||||
const int hostUid = mUidMap->getHostUidOrSelf(value.int_value);
|
|
||||||
updateUid(&value, hostUid);
|
|
||||||
} else {
|
|
||||||
ALOGE("Malformed log, uid not found. %s", event->ToString().c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
cmds/statsd/src/external/puller_util.cpp
vendored
32
cmds/statsd/src/external/puller_util.cpp
vendored
@@ -49,10 +49,14 @@ using namespace std;
|
|||||||
*/
|
*/
|
||||||
void mapAndMergeIsolatedUidsToHostUid(vector<shared_ptr<LogEvent>>& data, const sp<UidMap>& uidMap,
|
void mapAndMergeIsolatedUidsToHostUid(vector<shared_ptr<LogEvent>>& data, const sp<UidMap>& uidMap,
|
||||||
int tagId, const vector<int>& additiveFieldsVec) {
|
int tagId, const vector<int>& additiveFieldsVec) {
|
||||||
if ((android::util::AtomsInfo::kAtomsWithAttributionChain.find(tagId) ==
|
bool hasAttributionChain = (android::util::AtomsInfo::kAtomsWithAttributionChain.find(tagId) !=
|
||||||
android::util::AtomsInfo::kAtomsWithAttributionChain.end()) &&
|
android::util::AtomsInfo::kAtomsWithAttributionChain.end());
|
||||||
(android::util::AtomsInfo::kAtomsWithUidField.find(tagId) ==
|
// To check if any LogEvent has a uid field, we can just check the first
|
||||||
android::util::AtomsInfo::kAtomsWithUidField.end())) {
|
// LogEvent because all atoms with this tagId should have the uid
|
||||||
|
// annotation.
|
||||||
|
bool hasUidField = (data[0]->getUidFieldIndex() != -1);
|
||||||
|
|
||||||
|
if (!hasAttributionChain && !hasUidField) {
|
||||||
VLOG("No uid or attribution chain to merge, atom %d", tagId);
|
VLOG("No uid or attribution chain to merge, atom %d", tagId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -75,19 +79,13 @@ void mapAndMergeIsolatedUidsToHostUid(vector<shared_ptr<LogEvent>>& data, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto it = android::util::AtomsInfo::kAtomsWithUidField.find(tagId);
|
int uidFieldIndex = event->getUidFieldIndex();
|
||||||
if (it != android::util::AtomsInfo::kAtomsWithUidField.end()) {
|
if (uidFieldIndex != -1) {
|
||||||
int uidField = it->second; // uidField is the field number in proto,
|
Value& value = (*event->getMutableValues())[uidFieldIndex].mValue;
|
||||||
// starting from 1
|
const int hostUid = uidMap->getHostUidOrSelf(value.int_value);
|
||||||
if (uidField > 0 && (int)event->getValues().size() >= uidField &&
|
value.setInt(hostUid);
|
||||||
(event->getValues())[uidField - 1].mValue.getType() == INT) {
|
} else {
|
||||||
Value& value = (*event->getMutableValues())[uidField - 1].mValue;
|
ALOGE("Malformed log, uid not found. %s", event->ToString().c_str());
|
||||||
const int hostUid = uidMap->getHostUidOrSelf(value.int_value);
|
|
||||||
value.setInt(hostUid);
|
|
||||||
} else {
|
|
||||||
ALOGE("Malformed log, uid not found. %s", event->ToString().c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,14 +240,20 @@ void LogEvent::parseAttributionChain(int32_t* pos, int32_t depth, bool* last,
|
|||||||
last[1] = last[2] = false;
|
last[1] = last[2] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assumes that mValues is not empty
|
||||||
|
bool LogEvent::checkPreviousValueType(Type expected) {
|
||||||
|
return mValues[mValues.size() - 1].mValue.getType() == expected;
|
||||||
|
}
|
||||||
|
|
||||||
void LogEvent::parseIsUidAnnotation(uint8_t annotationType) {
|
void LogEvent::parseIsUidAnnotation(uint8_t annotationType) {
|
||||||
if (mValues.empty() || annotationType != BOOL_TYPE) {
|
if (mValues.empty() || !checkPreviousValueType(INT) || annotationType != BOOL_TYPE) {
|
||||||
mValid = false;
|
mValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isUid = readNextValue<uint8_t>();
|
bool isUid = readNextValue<uint8_t>();
|
||||||
if (isUid) mUidFieldIndex = mValues.size() - 1;
|
if (isUid) mUidFieldIndex = mValues.size() - 1;
|
||||||
|
mValues[mValues.size() - 1].mAnnotations.setUidField(isUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEvent::parseTruncateTimestampAnnotation(uint8_t annotationType) {
|
void LogEvent::parseTruncateTimestampAnnotation(uint8_t annotationType) {
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ private:
|
|||||||
void parseExclusiveStateAnnotation(uint8_t annotationType);
|
void parseExclusiveStateAnnotation(uint8_t annotationType);
|
||||||
void parseTriggerStateResetAnnotation(uint8_t annotationType);
|
void parseTriggerStateResetAnnotation(uint8_t annotationType);
|
||||||
void parseStateNestedAnnotation(uint8_t annotationType);
|
void parseStateNestedAnnotation(uint8_t annotationType);
|
||||||
|
bool checkPreviousValueType(Type expected);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The below three variables are only valid during the execution of
|
* The below three variables are only valid during the execution of
|
||||||
|
|||||||
@@ -81,18 +81,17 @@ bool combinationMatch(const vector<int>& children, const LogicalOperation& opera
|
|||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tryMatchString(const UidMap& uidMap, const Field& field, const Value& value,
|
bool tryMatchString(const UidMap& uidMap, const FieldValue& fieldValue, const string& str_match) {
|
||||||
const string& str_match) {
|
if (isAttributionUidField(fieldValue) || isUidField(fieldValue)) {
|
||||||
if (isAttributionUidField(field, value) || isUidField(field, value)) {
|
int uid = fieldValue.mValue.int_value;
|
||||||
int uid = value.int_value;
|
|
||||||
auto aidIt = UidMap::sAidToUidMapping.find(str_match);
|
auto aidIt = UidMap::sAidToUidMapping.find(str_match);
|
||||||
if (aidIt != UidMap::sAidToUidMapping.end()) {
|
if (aidIt != UidMap::sAidToUidMapping.end()) {
|
||||||
return ((int)aidIt->second) == uid;
|
return ((int)aidIt->second) == uid;
|
||||||
}
|
}
|
||||||
std::set<string> packageNames = uidMap.getAppNamesFromUid(uid, true /* normalize*/);
|
std::set<string> packageNames = uidMap.getAppNamesFromUid(uid, true /* normalize*/);
|
||||||
return packageNames.find(str_match) != packageNames.end();
|
return packageNames.find(str_match) != packageNames.end();
|
||||||
} else if (value.getType() == STRING) {
|
} else if (fieldValue.mValue.getType() == STRING) {
|
||||||
return value.str_value == str_match;
|
return fieldValue.mValue.str_value == str_match;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -228,8 +227,7 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher,
|
|||||||
}
|
}
|
||||||
case FieldValueMatcher::ValueMatcherCase::kEqString: {
|
case FieldValueMatcher::ValueMatcherCase::kEqString: {
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
if (tryMatchString(uidMap, values[i].mField, values[i].mValue,
|
if (tryMatchString(uidMap, values[i], matcher.eq_string())) {
|
||||||
matcher.eq_string())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +238,7 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher,
|
|||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
bool notEqAll = true;
|
bool notEqAll = true;
|
||||||
for (const auto& str : str_list.str_value()) {
|
for (const auto& str : str_list.str_value()) {
|
||||||
if (tryMatchString(uidMap, values[i].mField, values[i].mValue, str)) {
|
if (tryMatchString(uidMap, values[i], str)) {
|
||||||
notEqAll = false;
|
notEqAll = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -255,7 +253,7 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher,
|
|||||||
const auto& str_list = matcher.eq_any_string();
|
const auto& str_list = matcher.eq_any_string();
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
for (const auto& str : str_list.str_value()) {
|
for (const auto& str : str_list.str_value()) {
|
||||||
if (tryMatchString(uidMap, values[i].mField, values[i].mValue, str)) {
|
if (tryMatchString(uidMap, values[i], str)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <log/logprint.h>
|
#include <log/logprint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "annotations.h"
|
||||||
#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
|
#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
|
||||||
#include "matchers/matcher_util.h"
|
#include "matchers/matcher_util.h"
|
||||||
#include "stats_event.h"
|
#include "stats_event.h"
|
||||||
@@ -73,14 +74,13 @@ void makeStringLogEvent(LogEvent* logEvent, const int32_t atomId, const int64_t
|
|||||||
parseStatsEventToLogEvent(statsEvent, logEvent);
|
parseStatsEventToLogEvent(statsEvent, logEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeIntStringLogEvent(LogEvent* logEvent, const int32_t atomId, const int64_t timestamp,
|
void makeIntWithBoolAnnotationLogEvent(LogEvent* logEvent, const int32_t atomId,
|
||||||
const int32_t value, const string& name) {
|
const int32_t field, const uint8_t annotationId,
|
||||||
|
const bool annotationValue) {
|
||||||
AStatsEvent* statsEvent = AStatsEvent_obtain();
|
AStatsEvent* statsEvent = AStatsEvent_obtain();
|
||||||
AStatsEvent_setAtomId(statsEvent, atomId);
|
AStatsEvent_setAtomId(statsEvent, atomId);
|
||||||
AStatsEvent_overwriteTimestamp(statsEvent, timestamp);
|
AStatsEvent_writeInt32(statsEvent, field);
|
||||||
|
AStatsEvent_addBoolAnnotation(statsEvent, annotationId, annotationValue);
|
||||||
AStatsEvent_writeInt32(statsEvent, value);
|
|
||||||
AStatsEvent_writeString(statsEvent, name.c_str());
|
|
||||||
|
|
||||||
parseStatsEventToLogEvent(statsEvent, logEvent);
|
parseStatsEventToLogEvent(statsEvent, logEvent);
|
||||||
}
|
}
|
||||||
@@ -376,21 +376,20 @@ TEST(AtomMatcherTest, TestUidFieldMatcher) {
|
|||||||
simpleMatcher->add_field_value_matcher()->set_field(1);
|
simpleMatcher->add_field_value_matcher()->set_field(1);
|
||||||
simpleMatcher->mutable_field_value_matcher(0)->set_eq_string("pkg0");
|
simpleMatcher->mutable_field_value_matcher(0)->set_eq_string("pkg0");
|
||||||
|
|
||||||
// Set up the event
|
// Make event without is_uid annotation.
|
||||||
LogEvent event1(/*uid=*/0, /*pid=*/0);
|
LogEvent event1(/*uid=*/0, /*pid=*/0);
|
||||||
makeIntLogEvent(&event1, TAG_ID, 0, 1111);
|
makeIntLogEvent(&event1, TAG_ID, 0, 1111);
|
||||||
|
|
||||||
LogEvent event2(/*uid=*/0, /*pid=*/0);
|
|
||||||
makeIntStringLogEvent(&event2, TAG_ID_2, 0, 1111, "some value");
|
|
||||||
|
|
||||||
// Tag not in kAtomsWithUidField
|
|
||||||
EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event1));
|
EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event1));
|
||||||
|
|
||||||
// Tag found in kAtomsWithUidField and has matching uid
|
// Make event with is_uid annotation.
|
||||||
|
LogEvent event2(/*uid=*/0, /*pid=*/0);
|
||||||
|
makeIntWithBoolAnnotationLogEvent(&event2, TAG_ID_2, 1111, ANNOTATION_ID_IS_UID, true);
|
||||||
|
|
||||||
|
// Event has is_uid annotation, so mapping from uid to package name occurs.
|
||||||
simpleMatcher->set_atom_id(TAG_ID_2);
|
simpleMatcher->set_atom_id(TAG_ID_2);
|
||||||
EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event2));
|
EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event2));
|
||||||
|
|
||||||
// Tag found in kAtomsWithUidField but has non-matching uid
|
// Event has is_uid annotation, but uid maps to different package name.
|
||||||
simpleMatcher->mutable_field_value_matcher(0)->set_eq_string("Pkg2");
|
simpleMatcher->mutable_field_value_matcher(0)->set_eq_string("Pkg2");
|
||||||
EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event2));
|
EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event2));
|
||||||
}
|
}
|
||||||
|
|||||||
20
cmds/statsd/tests/external/puller_util_test.cpp
vendored
20
cmds/statsd/tests/external/puller_util_test.cpp
vendored
@@ -21,6 +21,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../metrics/metrics_test_helper.h"
|
#include "../metrics/metrics_test_helper.h"
|
||||||
|
#include "annotations.h"
|
||||||
#include "stats_event.h"
|
#include "stats_event.h"
|
||||||
#include "statslog_statsdtest.h"
|
#include "statslog_statsdtest.h"
|
||||||
#include "tests/statsd_test_util.h"
|
#include "tests/statsd_test_util.h"
|
||||||
@@ -53,15 +54,15 @@ int hostNonAdditiveData = 22;
|
|||||||
|
|
||||||
void extractIntoVector(vector<shared_ptr<LogEvent>> events,
|
void extractIntoVector(vector<shared_ptr<LogEvent>> events,
|
||||||
vector<vector<int>>& ret) {
|
vector<vector<int>>& ret) {
|
||||||
ret.clear();
|
ret.clear();
|
||||||
status_t err;
|
status_t err;
|
||||||
for (const auto& event : events) {
|
for (const auto& event : events) {
|
||||||
vector<int> vec;
|
vector<int> vec;
|
||||||
vec.push_back(event->GetInt(1, &err));
|
vec.push_back(event->GetInt(1, &err));
|
||||||
vec.push_back(event->GetInt(2, &err));
|
vec.push_back(event->GetInt(2, &err));
|
||||||
vec.push_back(event->GetInt(3, &err));
|
vec.push_back(event->GetInt(3, &err));
|
||||||
ret.push_back(vec);
|
ret.push_back(vec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<LogEvent> makeUidLogEvent(uint64_t timestampNs, int uid, int data1, int data2) {
|
std::shared_ptr<LogEvent> makeUidLogEvent(uint64_t timestampNs, int uid, int data1, int data2) {
|
||||||
@@ -70,6 +71,7 @@ std::shared_ptr<LogEvent> makeUidLogEvent(uint64_t timestampNs, int uid, int dat
|
|||||||
AStatsEvent_overwriteTimestamp(statsEvent, timestampNs);
|
AStatsEvent_overwriteTimestamp(statsEvent, timestampNs);
|
||||||
|
|
||||||
AStatsEvent_writeInt32(statsEvent, uid);
|
AStatsEvent_writeInt32(statsEvent, uid);
|
||||||
|
AStatsEvent_addBoolAnnotation(statsEvent, ANNOTATION_ID_IS_UID, true);
|
||||||
AStatsEvent_writeInt32(statsEvent, data1);
|
AStatsEvent_writeInt32(statsEvent, data1);
|
||||||
AStatsEvent_writeInt32(statsEvent, data2);
|
AStatsEvent_writeInt32(statsEvent, data2);
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ static void write_atoms_info_header_body(FILE* out, const Atoms& atoms) {
|
|||||||
fprintf(out,
|
fprintf(out,
|
||||||
" const static std::set<int> "
|
" const static std::set<int> "
|
||||||
"kTruncatingTimestampAtomBlackList;\n");
|
"kTruncatingTimestampAtomBlackList;\n");
|
||||||
fprintf(out, " const static std::map<int, int> kAtomsWithUidField;\n");
|
|
||||||
fprintf(out, " const static std::set<int> kAtomsWithAttributionChain;\n");
|
fprintf(out, " const static std::set<int> kAtomsWithAttributionChain;\n");
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
" const static std::map<int, StateAtomFieldOptions> "
|
" const static std::map<int, StateAtomFieldOptions> "
|
||||||
@@ -101,28 +100,6 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|||||||
fprintf(out, "};\n");
|
fprintf(out, "};\n");
|
||||||
fprintf(out, "\n");
|
fprintf(out, "\n");
|
||||||
|
|
||||||
fprintf(out, "static std::map<int, int> getAtomUidField() {\n");
|
|
||||||
fprintf(out, " std::map<int, int> uidField;\n");
|
|
||||||
for (AtomDeclSet::const_iterator atomIt = atoms.decls.begin(); atomIt != atoms.decls.end();
|
|
||||||
atomIt++) {
|
|
||||||
if ((*atomIt)->uidField == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
fprintf(out,
|
|
||||||
"\n // Adding uid field for atom "
|
|
||||||
"(%d)%s\n",
|
|
||||||
(*atomIt)->code, (*atomIt)->name.c_str());
|
|
||||||
fprintf(out, " uidField[%d /* %s */] = %d;\n", (*atomIt)->code,
|
|
||||||
make_constant_name((*atomIt)->name).c_str(), (*atomIt)->uidField);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(out, " return uidField;\n");
|
|
||||||
fprintf(out, "};\n");
|
|
||||||
|
|
||||||
fprintf(out,
|
|
||||||
"const std::map<int, int> AtomsInfo::kAtomsWithUidField = "
|
|
||||||
"getAtomUidField();\n");
|
|
||||||
|
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
"static std::map<int, StateAtomFieldOptions> "
|
"static std::map<int, StateAtomFieldOptions> "
|
||||||
"getStateAtomFieldOptions() {\n");
|
"getStateAtomFieldOptions() {\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user