Loading cmds/statsd/src/FieldValue.h +0 −1 Original line number Original line Diff line number Diff line Loading @@ -27,7 +27,6 @@ struct Matcher; struct Field; struct Field; struct FieldValue; struct FieldValue; const int32_t kAttributionField = 1; const int32_t kMaxLogDepth = 2; const int32_t kMaxLogDepth = 2; const int32_t kLastBitMask = 0x80; const int32_t kLastBitMask = 0x80; const int32_t kClearLastBitDeco = 0x7f; const int32_t kClearLastBitDeco = 0x7f; Loading cmds/statsd/src/StatsLogProcessor.cpp +7 −8 Original line number Original line Diff line number Diff line Loading @@ -138,14 +138,13 @@ void StatsLogProcessor::onPeriodicAlarmFired( } } void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const { void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const { if (event->getAttributionChainIndex() != -1) { if (std::pair<int, int> indexRange; event->hasAttributionChain(&indexRange)) { for (auto& value : *(event->getMutableValues())) { vector<FieldValue>* const fieldValues = event->getMutableValues(); if (value.mField.getPosAtDepth(0) > kAttributionField) { for (int i = indexRange.first; i <= indexRange.second; i++) { break; FieldValue& fieldValue = fieldValues->at(i); } if (isAttributionUidField(fieldValue)) { if (isAttributionUidField(value)) { const int hostUid = mUidMap->getHostUidOrSelf(fieldValue.mValue.int_value); const int hostUid = mUidMap->getHostUidOrSelf(value.mValue.int_value); fieldValue.mValue.setInt(hostUid); value.mValue.setInt(hostUid); } } } } } else { } else { Loading cmds/statsd/src/external/puller_util.cpp +9 −9 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,8 @@ void mapAndMergeIsolatedUidsToHostUid(vector<shared_ptr<LogEvent>>& data, const int tagId, const vector<int>& additiveFieldsVec) { int tagId, const vector<int>& additiveFieldsVec) { // Check the first LogEvent for attribution chain or a uid field as either all atoms with this // Check the first LogEvent for attribution chain or a uid field as either all atoms with this // tagId have them or none of them do. // tagId have them or none of them do. const bool hasAttributionChain = data[0]->getAttributionChainIndex() != -1; std::pair<int, int> attrIndexRange; const bool hasAttributionChain = data[0]->hasAttributionChain(&attrIndexRange); bool hasUidField = (data[0]->getUidFieldIndex() != -1); bool hasUidField = (data[0]->getUidFieldIndex() != -1); if (!hasAttributionChain && !hasUidField) { if (!hasAttributionChain && !hasUidField) { Loading @@ -64,14 +65,13 @@ void mapAndMergeIsolatedUidsToHostUid(vector<shared_ptr<LogEvent>>& data, const ALOGE("Wrong atom. Expecting %d, got %d", tagId, event->GetTagId()); ALOGE("Wrong atom. Expecting %d, got %d", tagId, event->GetTagId()); return; return; } } if (event->getAttributionChainIndex() != -1) { if (hasAttributionChain) { for (auto& value : *(event->getMutableValues())) { vector<FieldValue>* const fieldValues = event->getMutableValues(); if (value.mField.getPosAtDepth(0) > kAttributionField) { for (int i = attrIndexRange.first; i <= attrIndexRange.second; i++) { break; FieldValue& fieldValue = fieldValues->at(i); } if (isAttributionUidField(fieldValue)) { if (isAttributionUidField(value)) { const int hostUid = uidMap->getHostUidOrSelf(fieldValue.mValue.int_value); const int hostUid = uidMap->getHostUidOrSelf(value.mValue.int_value); fieldValue.mValue.setInt(hostUid); value.mValue.setInt(hostUid); } } } } } else { } else { Loading cmds/statsd/src/logd/LogEvent.cpp +20 −3 Original line number Original line Diff line number Diff line Loading @@ -211,8 +211,8 @@ void LogEvent::parseKeyValuePairs(int32_t* pos, int32_t depth, bool* last, uint8 void LogEvent::parseAttributionChain(int32_t* pos, int32_t depth, bool* last, void LogEvent::parseAttributionChain(int32_t* pos, int32_t depth, bool* last, uint8_t numAnnotations) { uint8_t numAnnotations) { int firstUidInChainIndex = mValues.size(); const unsigned int firstUidInChainIndex = mValues.size(); int32_t numNodes = readNextValue<uint8_t>(); const int32_t numNodes = readNextValue<uint8_t>(); for (pos[1] = 1; pos[1] <= numNodes; pos[1]++) { for (pos[1] = 1; pos[1] <= numNodes; pos[1]++) { last[1] = (pos[1] == numNodes); last[1] = (pos[1] == numNodes); Loading @@ -225,6 +225,11 @@ void LogEvent::parseAttributionChain(int32_t* pos, int32_t depth, bool* last, last[2] = true; last[2] = true; parseString(pos, /*depth=*/2, last, /*numAnnotations=*/0); parseString(pos, /*depth=*/2, last, /*numAnnotations=*/0); } } // Check if at least one node was successfully parsed. if (mValues.size() - 1 > firstUidInChainIndex) { mAttributionChainStartIndex = firstUidInChainIndex; mAttributionChainEndIndex = mValues.size() - 1; } parseAnnotations(numAnnotations, firstUidInChainIndex); parseAnnotations(numAnnotations, firstUidInChainIndex); Loading Loading @@ -401,7 +406,6 @@ bool LogEvent::parseBuffer(uint8_t* buf, size_t len) { break; break; case ATTRIBUTION_CHAIN_TYPE: case ATTRIBUTION_CHAIN_TYPE: parseAttributionChain(pos, /*depth=*/0, last, getNumAnnotations(typeInfo)); parseAttributionChain(pos, /*depth=*/0, last, getNumAnnotations(typeInfo)); if (mAttributionChainIndex == -1) mAttributionChainIndex = pos[0]; break; break; case ERROR_TYPE: case ERROR_TYPE: mErrorBitmask = readNextValue<int32_t>(); mErrorBitmask = readNextValue<int32_t>(); Loading Loading @@ -567,6 +571,19 @@ void LogEvent::ToProto(ProtoOutputStream& protoOutput) const { writeFieldValueTreeToStream(mTagId, getValues(), &protoOutput); writeFieldValueTreeToStream(mTagId, getValues(), &protoOutput); } } bool LogEvent::hasAttributionChain(std::pair<int, int>* indexRange) const { if (mAttributionChainStartIndex == -1 || mAttributionChainEndIndex == -1) { return false; } if (nullptr != indexRange) { indexRange->first = mAttributionChainStartIndex; indexRange->second = mAttributionChainEndIndex; } return true; } void writeExperimentIdsToProto(const std::vector<int64_t>& experimentIds, void writeExperimentIdsToProto(const std::vector<int64_t>& experimentIds, std::vector<uint8_t>* protoOut) { std::vector<uint8_t>* protoOut) { ProtoOutputStream proto; ProtoOutputStream proto; Loading cmds/statsd/src/logd/LogEvent.h +6 −7 Original line number Original line Diff line number Diff line Loading @@ -163,12 +163,10 @@ public: return mUidFieldIndex; return mUidFieldIndex; } } // Returns the index of (the first) attribution chain within the atom // Returns whether this LogEvent has an AttributionChain. // definition. Note that the value is 1-indexed. If there is no attribution // If it does and indexRange is not a nullptr, populate indexRange with the start and end index // chain, returns -1. // of the AttributionChain within mValues. inline int getAttributionChainIndex() { bool hasAttributionChain(std::pair<int, int>* indexRange = nullptr) const; return mAttributionChainIndex; } // Returns the index of the exclusive state field within the FieldValues vector if // Returns the index of the exclusive state field within the FieldValues vector if // an exclusive state exists. If there is no exclusive state field, returns -1. // an exclusive state exists. If there is no exclusive state field, returns -1. Loading Loading @@ -324,7 +322,8 @@ private: // Annotations // Annotations bool mTruncateTimestamp = false; bool mTruncateTimestamp = false; int mUidFieldIndex = -1; int mUidFieldIndex = -1; int mAttributionChainIndex = -1; int mAttributionChainStartIndex = -1; int mAttributionChainEndIndex = -1; int mExclusiveStateFieldIndex = -1; int mExclusiveStateFieldIndex = -1; int mResetState = -1; int mResetState = -1; }; }; Loading Loading
cmds/statsd/src/FieldValue.h +0 −1 Original line number Original line Diff line number Diff line Loading @@ -27,7 +27,6 @@ struct Matcher; struct Field; struct Field; struct FieldValue; struct FieldValue; const int32_t kAttributionField = 1; const int32_t kMaxLogDepth = 2; const int32_t kMaxLogDepth = 2; const int32_t kLastBitMask = 0x80; const int32_t kLastBitMask = 0x80; const int32_t kClearLastBitDeco = 0x7f; const int32_t kClearLastBitDeco = 0x7f; Loading
cmds/statsd/src/StatsLogProcessor.cpp +7 −8 Original line number Original line Diff line number Diff line Loading @@ -138,14 +138,13 @@ void StatsLogProcessor::onPeriodicAlarmFired( } } void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const { void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const { if (event->getAttributionChainIndex() != -1) { if (std::pair<int, int> indexRange; event->hasAttributionChain(&indexRange)) { for (auto& value : *(event->getMutableValues())) { vector<FieldValue>* const fieldValues = event->getMutableValues(); if (value.mField.getPosAtDepth(0) > kAttributionField) { for (int i = indexRange.first; i <= indexRange.second; i++) { break; FieldValue& fieldValue = fieldValues->at(i); } if (isAttributionUidField(fieldValue)) { if (isAttributionUidField(value)) { const int hostUid = mUidMap->getHostUidOrSelf(fieldValue.mValue.int_value); const int hostUid = mUidMap->getHostUidOrSelf(value.mValue.int_value); fieldValue.mValue.setInt(hostUid); value.mValue.setInt(hostUid); } } } } } else { } else { Loading
cmds/statsd/src/external/puller_util.cpp +9 −9 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,8 @@ void mapAndMergeIsolatedUidsToHostUid(vector<shared_ptr<LogEvent>>& data, const int tagId, const vector<int>& additiveFieldsVec) { int tagId, const vector<int>& additiveFieldsVec) { // Check the first LogEvent for attribution chain or a uid field as either all atoms with this // Check the first LogEvent for attribution chain or a uid field as either all atoms with this // tagId have them or none of them do. // tagId have them or none of them do. const bool hasAttributionChain = data[0]->getAttributionChainIndex() != -1; std::pair<int, int> attrIndexRange; const bool hasAttributionChain = data[0]->hasAttributionChain(&attrIndexRange); bool hasUidField = (data[0]->getUidFieldIndex() != -1); bool hasUidField = (data[0]->getUidFieldIndex() != -1); if (!hasAttributionChain && !hasUidField) { if (!hasAttributionChain && !hasUidField) { Loading @@ -64,14 +65,13 @@ void mapAndMergeIsolatedUidsToHostUid(vector<shared_ptr<LogEvent>>& data, const ALOGE("Wrong atom. Expecting %d, got %d", tagId, event->GetTagId()); ALOGE("Wrong atom. Expecting %d, got %d", tagId, event->GetTagId()); return; return; } } if (event->getAttributionChainIndex() != -1) { if (hasAttributionChain) { for (auto& value : *(event->getMutableValues())) { vector<FieldValue>* const fieldValues = event->getMutableValues(); if (value.mField.getPosAtDepth(0) > kAttributionField) { for (int i = attrIndexRange.first; i <= attrIndexRange.second; i++) { break; FieldValue& fieldValue = fieldValues->at(i); } if (isAttributionUidField(fieldValue)) { if (isAttributionUidField(value)) { const int hostUid = uidMap->getHostUidOrSelf(fieldValue.mValue.int_value); const int hostUid = uidMap->getHostUidOrSelf(value.mValue.int_value); fieldValue.mValue.setInt(hostUid); value.mValue.setInt(hostUid); } } } } } else { } else { Loading
cmds/statsd/src/logd/LogEvent.cpp +20 −3 Original line number Original line Diff line number Diff line Loading @@ -211,8 +211,8 @@ void LogEvent::parseKeyValuePairs(int32_t* pos, int32_t depth, bool* last, uint8 void LogEvent::parseAttributionChain(int32_t* pos, int32_t depth, bool* last, void LogEvent::parseAttributionChain(int32_t* pos, int32_t depth, bool* last, uint8_t numAnnotations) { uint8_t numAnnotations) { int firstUidInChainIndex = mValues.size(); const unsigned int firstUidInChainIndex = mValues.size(); int32_t numNodes = readNextValue<uint8_t>(); const int32_t numNodes = readNextValue<uint8_t>(); for (pos[1] = 1; pos[1] <= numNodes; pos[1]++) { for (pos[1] = 1; pos[1] <= numNodes; pos[1]++) { last[1] = (pos[1] == numNodes); last[1] = (pos[1] == numNodes); Loading @@ -225,6 +225,11 @@ void LogEvent::parseAttributionChain(int32_t* pos, int32_t depth, bool* last, last[2] = true; last[2] = true; parseString(pos, /*depth=*/2, last, /*numAnnotations=*/0); parseString(pos, /*depth=*/2, last, /*numAnnotations=*/0); } } // Check if at least one node was successfully parsed. if (mValues.size() - 1 > firstUidInChainIndex) { mAttributionChainStartIndex = firstUidInChainIndex; mAttributionChainEndIndex = mValues.size() - 1; } parseAnnotations(numAnnotations, firstUidInChainIndex); parseAnnotations(numAnnotations, firstUidInChainIndex); Loading Loading @@ -401,7 +406,6 @@ bool LogEvent::parseBuffer(uint8_t* buf, size_t len) { break; break; case ATTRIBUTION_CHAIN_TYPE: case ATTRIBUTION_CHAIN_TYPE: parseAttributionChain(pos, /*depth=*/0, last, getNumAnnotations(typeInfo)); parseAttributionChain(pos, /*depth=*/0, last, getNumAnnotations(typeInfo)); if (mAttributionChainIndex == -1) mAttributionChainIndex = pos[0]; break; break; case ERROR_TYPE: case ERROR_TYPE: mErrorBitmask = readNextValue<int32_t>(); mErrorBitmask = readNextValue<int32_t>(); Loading Loading @@ -567,6 +571,19 @@ void LogEvent::ToProto(ProtoOutputStream& protoOutput) const { writeFieldValueTreeToStream(mTagId, getValues(), &protoOutput); writeFieldValueTreeToStream(mTagId, getValues(), &protoOutput); } } bool LogEvent::hasAttributionChain(std::pair<int, int>* indexRange) const { if (mAttributionChainStartIndex == -1 || mAttributionChainEndIndex == -1) { return false; } if (nullptr != indexRange) { indexRange->first = mAttributionChainStartIndex; indexRange->second = mAttributionChainEndIndex; } return true; } void writeExperimentIdsToProto(const std::vector<int64_t>& experimentIds, void writeExperimentIdsToProto(const std::vector<int64_t>& experimentIds, std::vector<uint8_t>* protoOut) { std::vector<uint8_t>* protoOut) { ProtoOutputStream proto; ProtoOutputStream proto; Loading
cmds/statsd/src/logd/LogEvent.h +6 −7 Original line number Original line Diff line number Diff line Loading @@ -163,12 +163,10 @@ public: return mUidFieldIndex; return mUidFieldIndex; } } // Returns the index of (the first) attribution chain within the atom // Returns whether this LogEvent has an AttributionChain. // definition. Note that the value is 1-indexed. If there is no attribution // If it does and indexRange is not a nullptr, populate indexRange with the start and end index // chain, returns -1. // of the AttributionChain within mValues. inline int getAttributionChainIndex() { bool hasAttributionChain(std::pair<int, int>* indexRange = nullptr) const; return mAttributionChainIndex; } // Returns the index of the exclusive state field within the FieldValues vector if // Returns the index of the exclusive state field within the FieldValues vector if // an exclusive state exists. If there is no exclusive state field, returns -1. // an exclusive state exists. If there is no exclusive state field, returns -1. Loading Loading @@ -324,7 +322,8 @@ private: // Annotations // Annotations bool mTruncateTimestamp = false; bool mTruncateTimestamp = false; int mUidFieldIndex = -1; int mUidFieldIndex = -1; int mAttributionChainIndex = -1; int mAttributionChainStartIndex = -1; int mAttributionChainEndIndex = -1; int mExclusiveStateFieldIndex = -1; int mExclusiveStateFieldIndex = -1; int mResetState = -1; int mResetState = -1; }; }; Loading