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

Commit 6842a8c6 authored by Chenjie Yu's avatar Chenjie Yu
Browse files

bug fix for StatsLogEventWraper tag id

bug fix for ConfigManager fake config

Test: cts test
Change-Id: Ia07992dffb6520074c908151c96da1aa931f97f0
parent 3383a889
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -214,7 +214,8 @@ StatsdConfig build_fake_config() {
    int UID_PROCESS_STATE_UID_KEY = 1;

    int KERNEL_WAKELOCK_TAG_ID = 1004;
    int KERNEL_WAKELOCK_NAME_KEY = 4;
    int KERNEL_WAKELOCK_COUNT_KEY = 2;
    int KERNEL_WAKELOCK_NAME_KEY = 1;

    int DEVICE_TEMPERATURE_TAG_ID = 33;
    int DEVICE_TEMPERATURE_KEY = 1;
@@ -338,7 +339,7 @@ StatsdConfig build_fake_config() {
    ValueMetric* valueMetric = config.add_value_metric();
    valueMetric->set_name("METRIC_6");
    valueMetric->set_what("KERNEL_WAKELOCK");
    valueMetric->set_value_field(1);
    valueMetric->set_value_field(KERNEL_WAKELOCK_COUNT_KEY);
    valueMetric->set_condition("SCREEN_IS_ON");
    keyMatcher = valueMetric->add_dimension();
    keyMatcher->set_key(KERNEL_WAKELOCK_NAME_KEY);
+2 −2
Original line number Diff line number Diff line
@@ -49,15 +49,15 @@ bool StatsCompanionServicePuller::Pull(const int tagId, vector<shared_ptr<LogEve
            return false;
        }
        data->clear();
        long timestamp = time(nullptr);
        int timestamp = time(nullptr);
        for (const StatsLogEventWrapper& it : returned_value) {
            log_msg tmp;
            tmp.entry_v1.len = it.bytes.size();
            // Manually set the header size to 28 bytes to match the pushed log events.
            tmp.entry.hdr_size = kLogMsgHeaderSize;
            tmp.entry_v1.sec = timestamp;
            // And set the received bytes starting after the 28 bytes reserved for header.
            std::copy(it.bytes.begin(), it.bytes.end(), tmp.buf + kLogMsgHeaderSize);
            tmp.entry_v1.sec = timestamp;
            data->push_back(make_shared<LogEvent>(tmp));
        }
        ALOGD("StatsCompanionServicePuller::pull succeeded for %d", tagId);
+8 −1
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ public final class StatsLogEventWrapper implements Parcelable {
    private static final int EVENT_TYPE_LIST = 3;
    private static final int EVENT_TYPE_FLOAT = 4;

    // Keep this in sync with system/core/logcat/event.logtags
    private static final int STATS_BUFFER_TAG_ID = 1937006964;
    /**
     * Creates a log_event that is binary-encoded as implemented in
     * system/core/liblog/log_event_list.c; this allows us to use the same parsing logic in statsd
@@ -46,9 +48,14 @@ public final class StatsLogEventWrapper implements Parcelable {
     */
    public StatsLogEventWrapper(int tag, int fields) {
        // Write four bytes from tag, starting with least-significant bit.
        write4Bytes(tag);
        // For pulled data, this tag number is not really used. We use the same tag number as
        // pushed ones to be consistent.
        write4Bytes(STATS_BUFFER_TAG_ID);
        mStorage.write(EVENT_TYPE_LIST); // This is required to start the log entry.
        mStorage.write(fields); // Indicate number of elements in this list.
        mStorage.write(EVENT_TYPE_INT);
        // The first element is the real atom tag number
        write4Bytes(tag);
    }

    /**