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

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

Merge "use custom Parcel format to pull data"

parents bd5fed39 12e5e675
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -147,6 +147,9 @@ Value::Value(const Value& from) {
        case STRING:
            str_value = from.str_value;
            break;
        case STORAGE:
            storage_value = from.storage_value;
            break;
        default:
            break;
    }
@@ -164,6 +167,8 @@ std::string Value::toString() const {
            return std::to_string(double_value) + "[D]";
        case STRING:
            return str_value + "[S]";
        case STORAGE:
            return "bytes of size " + std::to_string(storage_value.size()) + "[ST]";
        default:
            return "[UNKNOWN]";
    }
@@ -183,6 +188,8 @@ bool Value::operator==(const Value& that) const {
            return double_value == that.double_value;
        case STRING:
            return str_value == that.str_value;
        case STORAGE:
            return storage_value == that.storage_value;
        default:
            return false;
    }
@@ -201,6 +208,8 @@ bool Value::operator!=(const Value& that) const {
            return double_value != that.double_value;
        case STRING:
            return str_value != that.str_value;
        case STORAGE:
            return storage_value != that.storage_value;
        default:
            return false;
    }
@@ -220,6 +229,8 @@ bool Value::operator<(const Value& that) const {
            return double_value < that.double_value;
        case STRING:
            return str_value < that.str_value;
        case STORAGE:
            return storage_value < that.storage_value;
        default:
            return false;
    }
@@ -239,6 +250,8 @@ bool Value::operator>(const Value& that) const {
            return double_value > that.double_value;
        case STRING:
            return str_value > that.str_value;
        case STORAGE:
            return storage_value > that.storage_value;
        default:
            return false;
    }
@@ -258,6 +271,8 @@ bool Value::operator>=(const Value& that) const {
            return double_value >= that.double_value;
        case STRING:
            return str_value >= that.str_value;
        case STORAGE:
            return storage_value >= that.storage_value;
        default:
            return false;
    }
@@ -274,6 +289,11 @@ Value Value::operator-(const Value& that) const {
        return v;
    }

    if (type == STORAGE) {
        ALOGE("Can't operate on storage value type");
        return v;
    }

    switch (type) {
        case INT:
            v.setInt(int_value - that.int_value);
@@ -311,6 +331,9 @@ Value& Value::operator=(const Value& that) {
        case STRING:
            str_value = that.str_value;
            break;
        case STORAGE:
            storage_value = that.storage_value;
            break;
        default:
            break;
    }
@@ -326,6 +349,10 @@ Value& Value::operator+=(const Value& that) {
        ALOGE("Can't operate on string value type");
        return *this;
    }
    if (type == STORAGE) {
        ALOGE("Can't operate on storage value type");
        return *this;
    }

    switch (type) {
        case INT:
+7 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ const int32_t kLastBitMask = 0x80;
const int32_t kClearLastBitDeco = 0x7f;
const int32_t kClearAllPositionMatcherMask = 0xffff00ff;

enum Type { UNKNOWN, INT, LONG, FLOAT, DOUBLE, STRING };
enum Type { UNKNOWN, INT, LONG, FLOAT, DOUBLE, STRING, STORAGE };

int32_t getEncodedField(int32_t pos[], int32_t depth, bool includeDepth);

@@ -293,6 +293,11 @@ struct Value {
        type = STRING;
    }

    Value(const std::vector<uint8_t>& v) {
        storage_value = v;
        type = STORAGE;
    }

    void setInt(int32_t v) {
        int_value = v;
        type = INT;
@@ -320,6 +325,7 @@ struct Value {
        double double_value;
    };
    std::string str_value;
    std::vector<uint8_t> storage_value;

    Type type;

+8 −1
Original line number Diff line number Diff line
@@ -170,9 +170,9 @@ message Atom {
        DirectoryUsage directory_usage = 10026;
        AppSize app_size = 10027;
        CategorySize category_size = 10028;
        android.service.procstats.ProcessStatsSectionProto proc_stats = 10029;
        BatteryVoltage battery_voltage = 10030;
        NumFingerprints num_fingerprints = 10031;
        ProcStats proc_stats = 10029;
    }

    // DO NOT USE field numbers above 100,000 in AOSP. Field numbers above
@@ -2479,3 +2479,10 @@ message NumFingerprints {
    // Number of fingerprints registered to that user.
    optional int32 num_fingerprints = 2;
}

/**
 * Pulled from ProcessStatsService.java
 */
message ProcStats {
    optional android.service.procstats.ProcessStatsSectionProto proc_stats_section = 1;
}
+2 −12
Original line number Diff line number Diff line
@@ -36,8 +36,6 @@ namespace android {
namespace os {
namespace statsd {

const int kLogMsgHeaderSize = 28;

// The reading and parsing are implemented in Java. It is not difficult to port over. But for now
// let StatsCompanionService handle that and send the data back.
StatsCompanionServicePuller::StatsCompanionServicePuller(int tagId) : StatsPuller(tagId) {
@@ -56,20 +54,12 @@ bool StatsCompanionServicePuller::PullInternal(vector<shared_ptr<LogEvent> >* da
        vector<StatsLogEventWrapper> returned_value;
        Status status = statsCompanionServiceCopy->pullData(mTagId, &returned_value);
        if (!status.isOk()) {
            ALOGW("error pulling for %d", mTagId);
            ALOGW("StatsCompanionServicePuller::pull failed to pull for %d", mTagId);
            return false;
        }
        data->clear();
        int32_t timestampSec = getWallClockSec();
        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 = timestampSec;
            // And set the received bytes starting after the 28 bytes reserved for header.
            std::copy(it.bytes.begin(), it.bytes.end(), tmp.buf + kLogMsgHeaderSize);
            data->push_back(make_shared<LogEvent>(tmp));
            data->push_back(make_shared<LogEvent>(it));
        }
        VLOG("StatsCompanionServicePuller::pull succeeded for %d", mTagId);
        return true;
+3 −12
Original line number Diff line number Diff line
@@ -195,22 +195,13 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
          new StatsCompanionServicePuller(android::util::LOOPER_STATS)}},
        // Disk Stats
        {android::util::DISK_STATS,
         {{},
          {},
          1 * NS_PER_SEC,
          new StatsCompanionServicePuller(android::util::DISK_STATS)}},
         {{}, {}, 1 * NS_PER_SEC, new StatsCompanionServicePuller(android::util::DISK_STATS)}},
        // Directory usage
        {android::util::DIRECTORY_USAGE,
         {{},
          {},
          1 * NS_PER_SEC,
          new StatsCompanionServicePuller(android::util::DIRECTORY_USAGE)}},
         {{}, {}, 1 * NS_PER_SEC, new StatsCompanionServicePuller(android::util::DIRECTORY_USAGE)}},
        // Size of app's code, data, and cache
        {android::util::APP_SIZE,
         {{},
          {},
          1 * NS_PER_SEC,
          new StatsCompanionServicePuller(android::util::APP_SIZE)}},
         {{}, {}, 1 * NS_PER_SEC, new StatsCompanionServicePuller(android::util::APP_SIZE)}},
        // Size of specific categories of files. Eg. Music.
        {android::util::CATEGORY_SIZE,
         {{},
Loading