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

Commit e35b282c authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Reset the condition to the initial state.

For conditions without a condition, the initial state is true, not
unknown.

Test: atest statsd_test
Change-Id: Iba27a8ea82af9b9e5e1f8ee17f091f344674d14a
parent 5d38dc3f
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -69,7 +69,7 @@ public:
          mTimeBaseNs(timeBaseNs),
          mTimeBaseNs(timeBaseNs),
          mCurrentBucketStartTimeNs(timeBaseNs),
          mCurrentBucketStartTimeNs(timeBaseNs),
          mCurrentBucketNum(0),
          mCurrentBucketNum(0),
          mCondition(conditionIndex >= 0 ? ConditionState::kUnknown : ConditionState::kTrue),
          mCondition(initialCondition(conditionIndex)),
          mConditionSliced(false),
          mConditionSliced(false),
          mWizard(wizard),
          mWizard(wizard),
          mConditionTrackerIndex(conditionIndex),
          mConditionTrackerIndex(conditionIndex),
@@ -82,6 +82,10 @@ public:


    virtual ~MetricProducer(){};
    virtual ~MetricProducer(){};


    ConditionState initialCondition(const int conditionIndex) const {
        return conditionIndex >= 0 ? ConditionState::kUnknown : ConditionState::kTrue;
    }

    /**
    /**
     * Forces this metric to split into a partial bucket right now. If we're past a full bucket, we
     * Forces this metric to split into a partial bucket right now. If we're past a full bucket, we
     * first call the standard flushing code to flush up to the latest full bucket. Then we call
     * first call the standard flushing code to flush up to the latest full bucket. Then we call
+1 −1
Original line number Original line Diff line number Diff line
@@ -394,7 +394,7 @@ void ValueMetricProducer::onConditionChangedLocked(const bool condition,
        invalidateCurrentBucket();
        invalidateCurrentBucket();
        // Something weird happened. If we received another event if the future, the condition might
        // Something weird happened. If we received another event if the future, the condition might
        // be wrong.
        // be wrong.
        mCondition = ConditionState::kUnknown;
        mCondition = initialCondition(mConditionTrackerIndex);
    }
    }


    // This part should alway be called.
    // This part should alway be called.