Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit adb4fc73 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Avoid processing log event when there is no uid field."

parents 2cef59dc 68985805
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -92,10 +92,20 @@ void StatsLogProcessor::onAnomalyAlarmFired(

void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const {
    std::vector<Field> uidFields;
    if (android::util::kAtomsWithAttributionChain.find(event->GetTagId()) !=
        android::util::kAtomsWithAttributionChain.end()) {
        findFields(
            event->getFieldValueMap(),
            buildAttributionUidFieldMatcher(event->GetTagId(), Position::ANY),
            &uidFields);
    } else if (android::util::kAtomsWithUidField.find(event->GetTagId()) !=
               android::util::kAtomsWithUidField.end()) {
        findFields(
            event->getFieldValueMap(),
            buildSimpleAtomFieldMatcher(event->GetTagId(), 1 /* uid is always the 1st field. */),
            &uidFields);
    }

    for (size_t i = 0; i < uidFields.size(); ++i) {
        DimensionsValue* value = event->findFieldValueOrNull(uidFields[i]);
        if (value != nullptr && value->value_case() == DimensionsValue::ValueCase::kValueInt) {
+3 −3
Original line number Diff line number Diff line
@@ -58,14 +58,14 @@ public:
    /**
     * Get the timestamp associated with this event.
     */
    uint64_t GetTimestampNs() const { return mTimestampNs; }
    inline uint64_t GetTimestampNs() const { return mTimestampNs; }

    /**
     * Get the tag for this event.
     */
    int GetTagId() const { return mTagId; }
    inline int GetTagId() const { return mTagId; }

    uint32_t GetUid() const {
    inline uint32_t GetUid() const {
        return mLogUid;
    }

+31 −0
Original line number Diff line number Diff line
@@ -317,6 +317,7 @@ write_stats_log_header(FILE* out, const Atoms& atoms, const AtomDecl &attributio
    fprintf(out, "\n");
    fprintf(out, "#include <stdint.h>\n");
    fprintf(out, "#include <vector>\n");
    fprintf(out, "#include <set>\n");
    fprintf(out, "\n");

    fprintf(out, "namespace android {\n");
@@ -361,6 +362,36 @@ write_stats_log_header(FILE* out, const Atoms& atoms, const AtomDecl &attributio
    fprintf(out, "};\n");
    fprintf(out, "\n");

    fprintf(out, "const static std::set<int> kAtomsWithUidField = {\n");
    for (set<AtomDecl>::const_iterator atom = atoms.decls.begin();
        atom != atoms.decls.end(); atom++) {
        for (vector<AtomField>::const_iterator field = atom->fields.begin();
                field != atom->fields.end(); field++) {
            if (field->name == "uid") {
                string constant = make_constant_name(atom->name);
                fprintf(out, " %s,\n", constant.c_str());
                break;
            }
        }
    }
    fprintf(out, "};\n");
    fprintf(out, "\n");

    fprintf(out, "const static std::set<int> kAtomsWithAttributionChain = {\n");
    for (set<AtomDecl>::const_iterator atom = atoms.decls.begin();
        atom != atoms.decls.end(); atom++) {
        for (vector<AtomField>::const_iterator field = atom->fields.begin();
                field != atom->fields.end(); field++) {
            if (field->javaType == JAVA_TYPE_ATTRIBUTION_CHAIN) {
                string constant = make_constant_name(atom->name);
                fprintf(out, " %s,\n", constant.c_str());
                break;
            }
        }
    }
    fprintf(out, "};\n");
    fprintf(out, "\n");

    fprintf(out, "const static int kMaxPushedAtomId = %d;\n\n", maxPushedAtomId);

    // Print write methods