Files
frameworks_base/libs/services/include/android/os/StatsLogEventWrapper.h
Chenjie Yu ab53020345 pull PowerProfile into statsd
pull constants from PowerProfile into statsd for power model
calculations. The data is mostly from power_profile.xml

power_profile {
  power_profile_proto {
    cpu_suspend: 5.734
    cpu_idle: 1.389
    cpu_active: 18.76
    wifi_controller_idle: 2.0
    wifi_controller_rx: 107.0
    wifi_controller_tx: 371.0
    wifi_controller_operating_voltage: 3700.0
    bluetooth_controller_idle: 0.01
    bluetooth_controller_rx: 8.0
    bluetooth_controller_tx: 7.0
    bluetooth_controller_operating_voltage: 3300.0
    modem_controller_idle: 105.0
    modem_controller_rx: 175.0
    modem_controller_tx: 176.0
    modem_controller_tx: 216.0
    modem_controller_tx: 300.0
    modem_controller_tx: 427.0
    modem_controller_tx: 604.0
    modem_controller_operating_voltage: 3700.0
    gps_signal_quality_based: 49.0
    gps_signal_quality_based: 11.0
    gps_operating_voltage: 3700.0
    screen_on: 178.708
    screen_full: 240.79
    audio: 75.6
    video: 50.93
    flashlight: 298.498
    camera: 1152.292
    battery_capacity: 3450.0
    cpu_cluster {
      cores: 2
      speed: 307200
      speed: 384000
      speed: 460800
      speed: 537600
      speed: 614400
      speed: 691200
      speed: 768000
      speed: 844800
      speed: 902600
      speed: 979200
      speed: 1056000
      speed: 1132800
      speed: 1209600
      speed: 1286400
      speed: 1363200
      speed: 1440000
      speed: 1516800
      speed: 1593600
      core_power: 11.272
      core_power: 14.842
      core_power: 18.497
      core_power: 22.518
      core_power: 25.967
      core_power: 31.694
      core_power: 37.673
      core_power: 42.859
      core_power: 46.872
      core_power: 57.92
      core_power: 67.561
      core_power: 76.303
      core_power: 87.613
      core_power: 97.045
      core_power: 109.544
      core_power: 122.054
      core_power: 136.345
      core_power: 154.435
    }
    cpu_cluster {
      id: 1
      cores: 2
      speed: 307200
      speed: 384000
      speed: 460800
      speed: 537600
      speed: 614400
      speed: 691200
      speed: 748800
      speed: 825600
      speed: 902400
      speed: 979200
      speed: 1056000
      speed: 1132800
      speed: 1209600
      speed: 1286400
      speed: 1363200
      speed: 1440000
      speed: 1516800
      speed: 1593600
      speed: 1670400
      speed: 1747200
      speed: 1824000
      speed: 1900800
      speed: 1977600
      speed: 2054400
      speed: 2150400
      core_power: 7.055
      core_power: 11.483
      core_power: 14.979
      core_power: 19.642
      core_power: 23.167
      core_power: 27.479
      core_power: 31.632
      core_power: 39.192
      core_power: 47.817
      core_power: 55.659
      core_power: 64.908
      core_power: 73.824
      core_power: 85.299
      core_power: 96.036
      core_power: 109.233
      core_power: 118.56
      core_power: 132.959
      core_power: 143.692
      core_power: 161.378
      core_power: 180.616
      core_power: 193.897
      core_power: 214.361
      core_power: 238.338
      core_power: 265.759
      core_power: 297.918
    }
  }
}

Bug: 113353350
Test: manual test on statsd
Change-Id: I1edd4db255c0440ddbff1d40e1515caaccbc73f8
2018-10-03 10:39:49 -07:00

119 lines
2.6 KiB
C++

/*
* 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.
*/
#ifndef STATS_LOG_EVENT_WRAPPER_H
#define STATS_LOG_EVENT_WRAPPER_H
#include <binder/Parcel.h>
#include <binder/Parcelable.h>
#include <binder/Status.h>
#include <utils/RefBase.h>
#include <vector>
namespace android {
namespace os {
/**
* A wrapper for a union type to contain multiple types of values.
*
*/
struct StatsLogValue {
// Keep in sync with FieldValue.h
enum STATS_LOG_VALUE_TYPE {
UNKNOWN = 0,
INT = 1,
LONG = 2,
FLOAT = 3,
DOUBLE = 4,
STRING = 5,
STORAGE = 6
};
StatsLogValue() : type(UNKNOWN) {}
StatsLogValue(int32_t v) {
int_value = v;
type = INT;
}
StatsLogValue(int64_t v) {
long_value = v;
type = LONG;
}
StatsLogValue(float v) {
float_value = v;
type = FLOAT;
}
StatsLogValue(double v) {
double_value = v;
type = DOUBLE;
}
StatsLogValue(const std::string& v) {
str_value = v;
type = STRING;
}
void setType(STATS_LOG_VALUE_TYPE t) { type = t; }
union {
int32_t int_value;
int64_t long_value;
float float_value;
double double_value;
};
std::string str_value;
std::vector<uint8_t> storage_value;
STATS_LOG_VALUE_TYPE type;
};
// Represents a parcelable object. Only used to send data from Android OS to statsd.
class StatsLogEventWrapper : public android::Parcelable {
public:
StatsLogEventWrapper();
StatsLogEventWrapper(StatsLogEventWrapper&& in) = default;
android::status_t writeToParcel(android::Parcel* out) const;
android::status_t readFromParcel(const android::Parcel* in);
int getTagId() const { return mTagId; }
int64_t getElapsedRealTimeNs() const { return mElapsedRealTimeNs; }
int64_t getWallClockTimeNs() const { return mWallClockTimeNs; }
std::vector<StatsLogValue> getElements() const { return mElements; }
private:
int mTagId;
int64_t mElapsedRealTimeNs;
int64_t mWallClockTimeNs;
std::vector<StatsLogValue> mElements;
};
} // Namespace os
} // Namespace android
#endif // STATS_LOG_EVENT_WRAPPER_H