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

Commit 7f9e63b6 authored by Yi Jin's avatar Yi Jin
Browse files

Add clear method to ProtoOutputStream so it is reusable by just

rewinding its internal pointer.

Bug: 72319159
Test: atest incidentd_test and atest statsd_test
Change-Id: Id046b987a7460d68300e5d4d46ae56aec1eba2d0
parent 421822ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ void
PrivacyBuffer::clear()
{
    mSize = 0;
    mProto = ProtoOutputStream();
    mProto.clear();
}

size_t
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 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.
-->
<configuration description="Config for statsd_test">
    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
        <option name="cleanup" value="true" />
        <option name="push" value="statsd_test->/data/nativetest/statsd_test" />
    </target_preparer>
    <option name="test-suite-tag" value="apct" />
    <test class="com.android.tradefed.testtype.GTest" >
        <option name="native-test-device-path" value="/data/nativetest" />
        <option name="module-name" value="statsd_test" />
    </test>
</configuration>
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

#include "AnomalyTracker.h"
#include "external/Perfetto.h"
#include "frameworks/base/libs/incident/proto/android/os/header.pb.h"
#include "guardrail/StatsdStats.h"
#include "subscriber/IncidentdReporter.h"
#include "subscriber/SubscriberReporter.h"
+2 −8
Original line number Diff line number Diff line
@@ -59,9 +59,7 @@ EventMetricProducer::EventMetricProducer(const ConfigKey& key, const EventMetric
                               metric.links().end());
        mConditionSliced = true;
    }

    startNewProtoOutputStreamLocked();

    mProto = std::make_unique<ProtoOutputStream>();
    VLOG("metric %lld created. bucket size %lld start_time: %lld", (long long)metric.id(),
         (long long)mBucketSizeNs, (long long)mStartTimeNs);
}
@@ -70,10 +68,6 @@ EventMetricProducer::~EventMetricProducer() {
    VLOG("~EventMetricProducer() called");
}

void EventMetricProducer::startNewProtoOutputStreamLocked() {
    mProto = std::make_unique<ProtoOutputStream>();
}

void EventMetricProducer::onSlicedConditionMayChangeLocked(const uint64_t eventTime) {
}

@@ -113,7 +107,7 @@ void EventMetricProducer::onDumpReportLocked(const uint64_t dumpTimeNs,
    protoOutput->write(FIELD_TYPE_MESSAGE | FIELD_ID_EVENT_METRICS,
                       reinterpret_cast<char*>(buffer.get()->data()), buffer.get()->size());

    startNewProtoOutputStreamLocked();
    mProto->clear();
}

void EventMetricProducer::onConditionChangedLocked(const bool conditionMet,
+0 −3
Original line number Diff line number Diff line
@@ -40,9 +40,6 @@ public:

    virtual ~EventMetricProducer();

protected:
    void startNewProtoOutputStreamLocked();

private:
    void onMatchedLogEventInternalLocked(
            const size_t matcherIndex, const MetricDimensionKey& eventKey,
Loading