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

Commit cdb1a0ed authored by Stefan Lafon's avatar Stefan Lafon Committed by Yao Chen
Browse files

Check in new protos and constants.

Test: Started statsd and verified it outputs data. Also ran statsd tests.

Change-Id: I2a438b2ddfcb1576e21acb6159bea607fed7caaa
parent 353a02a5
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ LOCAL_SRC_FILES := \
    src/StatsLogProcessor.cpp \
    src/stats_log.proto \
    src/statsd_config.proto \
    src/stats_constants.proto \
    src/DropboxReader.cpp \
    src/matchers/LogEntryMatcherManager.cpp \

@@ -122,7 +121,6 @@ LOCAL_CFLAGS += \
LOCAL_SRC_FILES := \
    src/stats_log.proto \
    src/statsd_config.proto \
    src/stats_constants.proto \
    ../../core/java/android/os/IStatsCompanionService.aidl \
    ../../core/java/android/os/IStatsManager.aidl \
    src/StatsService.cpp \
+4 −8
Original line number Diff line number Diff line
@@ -105,16 +105,12 @@ bool DropboxReader::parseFromFile(const unique_fd& fd, StatsLogReport& logReport
}

void DropboxReader::printLog(FILE* out, const StatsLogReport& logReport) {
    fprintf(out, "start_time_msec=%lld, end_time_msec=%lld, ", logReport.start_report_millis(),
            logReport.end_report_millis());
    fprintf(out, "start_time_ns=%lld, end_time_ns=%lld, ", logReport.start_report_nanos(),
            logReport.end_report_nanos());
    for (int i = 0; i < logReport.event_metrics().data_size(); i++) {
        EventMetricData eventMetricData = logReport.event_metrics().data(i);
        for (int j = 0; j < eventMetricData.key_value_pair_size(); j++) {
            fprintf(out, "key=%d, ", eventMetricData.key_value_pair(j).key());
            fprintf(out, "value_str=%s ", eventMetricData.key_value_pair(j).value_str().c_str());
            fprintf(out, "value_int=%lld ", eventMetricData.key_value_pair(j).value_int());
            fprintf(out, "value_float=%f ", eventMetricData.key_value_pair(j).value_float());
        }
        // TODO: Pretty-print the proto.
        // fprintf(out, "EventMetricData=%s", eventMetricData.SerializeAsString().c_str());
    }
    fprintf(out, "\n");
}
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#ifndef STATS_LOG_PROCESSOR_H
#define STATS_LOG_PROCESSOR_H

#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
#include "parse_util.h"

#include <unordered_map>
@@ -47,7 +48,7 @@ private:
    DropboxWriter m_dropbox_writer;

    /**
     * Configs that have been specified, keyed by the source. This allows us to over-ride the config
     * Configs that have been specified, keyed by the source. This allows us to override the config
     * from a source later.
     */
    std::unordered_map<int, StatsdConfig> m_configs;
+23 −21
Original line number Diff line number Diff line
@@ -17,13 +17,8 @@
#include <log/log_event_list.h>
#include <parse_util.h>

using android::os::statsd::EVENT_TIMESTAMP;
using android::os::statsd::EventMetricData;
using android::os::statsd::KeyId;
using android::os::statsd::KeyId_IsValid;
using android::os::statsd::KeyValuePair;
using android::os::statsd::TagId;
using android::os::statsd::TagId_IsValid;

static inline uint32_t get4LE(const char* src) {
    return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
@@ -38,16 +33,11 @@ EventMetricData parse(log_msg msg)
    // set tag.
    char* eventData = msg.msg();
    uint32_t tag = get4LE(eventData);
    if (!TagId_IsValid(tag)) {
        // return when an invalid tag is found.
        return eventMetricData;
    }
    eventMetricData.set_tag(static_cast<TagId>(tag));
    // TODO: Replace the following line when we can serialize on the fly.
    //eventMetricData.set_tag(tag);

    // set timestamp of the event.
    KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair();
    keyValuePair->set_key(EVENT_TIMESTAMP);
    keyValuePair->set_value_int(msg.entry_v1.sec * NS_PER_SEC + msg.entry_v1.nsec);
    eventMetricData.set_timestamp_nanos(msg.entry_v1.sec * NS_PER_SEC + msg.entry_v1.nsec);

    // start iterating k,v pairs.
    android_log_context context =
@@ -66,38 +56,50 @@ EventMetricData parse(log_msg msg)
                case EVENT_TYPE_INT:
                    if (index % 2 == 0) {
                        key = elem.data.int32;
                    } else if (KeyId_IsValid(key)) {
                    } else {
                        // TODO: Fix the following lines when we can serialize on the fly.
                        /*
                        int32_t val = elem.data.int32;
                        KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair();
                        keyValuePair->set_key(static_cast<KeyId>(key));
                        keyValuePair->set_key(key);
                        keyValuePair->set_value_int(val);
                        */
                    }
                    index++;
                    break;
                case EVENT_TYPE_FLOAT:
                    if (index % 2 == 1 && KeyId_IsValid(key)) {
                    if (index % 2 == 1) {
                        // TODO: Fix the following lines when we can serialize on the fly.
                        /*
                        float val = elem.data.float32;
                        KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair();
                        keyValuePair->set_key(static_cast<KeyId>(key));
                        keyValuePair->set_key(key);
                        keyValuePair->set_value_float(val);
                        */
                    }
                    index++;
                    break;
                case EVENT_TYPE_STRING:
                    if (index % 2 == 1 && KeyId_IsValid(key)) {
                    if (index % 2 == 1) {
                        // TODO: Fix the following lines when we can serialize on the fly.
                        /*
                        char* val = elem.data.string;
                        KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair();
                        keyValuePair->set_key(static_cast<KeyId>(key));
                        keyValuePair->set_key(key);
                        keyValuePair->set_value_str(val);
                        */
                    }
                    index++;
                    break;
                case EVENT_TYPE_LONG:
                    if (index % 2 == 1 && KeyId_IsValid(key)) {
                    if (index % 2 == 1) {
                        // TODO: Fix the following lines when we can serialize on the fly.
                        /*
                        int64_t val = elem.data.int64;
                        KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair();
                        keyValuePair->set_key(static_cast<KeyId>(key));
                        keyValuePair->set_key(key);
                        keyValuePair->set_value_int(val);
                        */
                    }
                    index++;
                    break;
+57 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

syntax = "proto2";
option optimize_for = LITE_RUNTIME;

package android.os.statsd;

option java_package = "com.android.os";
option java_outer_classname = "StatsEventProto";

message StatsEvent {
  oneof log_entry_event {
    ScreenStateChange screen_state_change = 2;
    ProcessStateChange process_state_change = 1112;
  }
}

message ScreenStateChange {
  enum State {
    STATE_UNKNOWN = 0;
    STATE_OFF = 1;
    STATE_ON = 2;
    STATE_DOZE = 3;
    STATE_DOZE_SUSPEND = 4;
    STATE_VR = 5;
  }
  optional State display_state = 1;
}

message ProcessStateChange {
  enum State {
    START = 1;
    CRASH = 2;
  }
  optional State state = 1;

  optional int32 uid = 2;

  optional string package_name = 1002;

  optional int32 package_version = 3;
  optional string package_version_string = 4;
}
Loading