Merge "BatteryStats: Remove reading of cpu power" into oc-dev
diff --git a/api/current.txt b/api/current.txt
index 902f168..6e30fd8 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -31929,7 +31929,7 @@
field public static final int MEASUREMENT_BLUETOOTH_TX_MS = 10022; // 0x2726
field public static final int MEASUREMENT_BLUETOOTH_TX_PACKETS = 10059; // 0x274b
field public static final int MEASUREMENT_BUTTON_USER_ACTIVITY_COUNT = 10046; // 0x273e
- field public static final int MEASUREMENT_CPU_POWER_MAMS = 10064; // 0x2750
+ field public static final deprecated int MEASUREMENT_CPU_POWER_MAMS = 10064; // 0x2750
field public static final int MEASUREMENT_MOBILE_IDLE_MS = 10024; // 0x2728
field public static final int MEASUREMENT_MOBILE_POWER_MAMS = 10027; // 0x272b
field public static final int MEASUREMENT_MOBILE_RX_BYTES = 10048; // 0x2740
diff --git a/api/system-current.txt b/api/system-current.txt
index 9ed5338..b0eb10d 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -34814,7 +34814,7 @@
field public static final int MEASUREMENT_BLUETOOTH_TX_MS = 10022; // 0x2726
field public static final int MEASUREMENT_BLUETOOTH_TX_PACKETS = 10059; // 0x274b
field public static final int MEASUREMENT_BUTTON_USER_ACTIVITY_COUNT = 10046; // 0x273e
- field public static final int MEASUREMENT_CPU_POWER_MAMS = 10064; // 0x2750
+ field public static final deprecated int MEASUREMENT_CPU_POWER_MAMS = 10064; // 0x2750
field public static final int MEASUREMENT_MOBILE_IDLE_MS = 10024; // 0x2728
field public static final int MEASUREMENT_MOBILE_POWER_MAMS = 10027; // 0x272b
field public static final int MEASUREMENT_MOBILE_RX_BYTES = 10048; // 0x2740
diff --git a/api/test-current.txt b/api/test-current.txt
index 29d4080..52a07fa 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -32061,7 +32061,7 @@
field public static final int MEASUREMENT_BLUETOOTH_TX_MS = 10022; // 0x2726
field public static final int MEASUREMENT_BLUETOOTH_TX_PACKETS = 10059; // 0x274b
field public static final int MEASUREMENT_BUTTON_USER_ACTIVITY_COUNT = 10046; // 0x273e
- field public static final int MEASUREMENT_CPU_POWER_MAMS = 10064; // 0x2750
+ field public static final deprecated int MEASUREMENT_CPU_POWER_MAMS = 10064; // 0x2750
field public static final int MEASUREMENT_MOBILE_IDLE_MS = 10024; // 0x2728
field public static final int MEASUREMENT_MOBILE_POWER_MAMS = 10027; // 0x272b
field public static final int MEASUREMENT_MOBILE_RX_BYTES = 10048; // 0x2740
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 4c6d22a..a87cb092 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -594,11 +594,6 @@
public abstract long getSystemCpuTimeUs(int which);
/**
- * Get the total cpu power consumed (in milli-ampere-microseconds).
- */
- public abstract long getCpuPowerMaUs(int which);
-
- /**
* Returns the approximate cpu time (in milliseconds) spent at a certain CPU speed for a
* given CPU cluster.
* @param cluster the index of the CPU cluster.
@@ -3467,10 +3462,9 @@
final long userCpuTimeUs = u.getUserCpuTimeUs(which);
final long systemCpuTimeUs = u.getSystemCpuTimeUs(which);
- final long powerCpuMaUs = u.getCpuPowerMaUs(which);
- if (userCpuTimeUs > 0 || systemCpuTimeUs > 0 || powerCpuMaUs > 0) {
+ if (userCpuTimeUs > 0 || systemCpuTimeUs > 0) {
dumpLine(pw, uid, category, CPU_DATA, userCpuTimeUs / 1000, systemCpuTimeUs / 1000,
- powerCpuMaUs / 1000);
+ 0 /* old cpu power, keep for compatibility */);
}
final ArrayMap<String, ? extends BatteryStats.Uid.Proc> processStats
@@ -4758,17 +4752,13 @@
final long userCpuTimeUs = u.getUserCpuTimeUs(which);
final long systemCpuTimeUs = u.getSystemCpuTimeUs(which);
- final long powerCpuMaUs = u.getCpuPowerMaUs(which);
- if (userCpuTimeUs > 0 || systemCpuTimeUs > 0 || powerCpuMaUs > 0) {
+ if (userCpuTimeUs > 0 || systemCpuTimeUs > 0) {
sb.setLength(0);
sb.append(prefix);
sb.append(" Total cpu time: u=");
formatTimeMs(sb, userCpuTimeUs / 1000);
sb.append("s=");
formatTimeMs(sb, systemCpuTimeUs / 1000);
- sb.append("p=");
- printmAh(sb, powerCpuMaUs / (1000.0 * 1000.0 * 60.0 * 60.0));
- sb.append("mAh");
pw.println(sb.toString());
}
diff --git a/core/java/android/os/health/UidHealthStats.java b/core/java/android/os/health/UidHealthStats.java
index a702cdb..afc9d78 100644
--- a/core/java/android/os/health/UidHealthStats.java
+++ b/core/java/android/os/health/UidHealthStats.java
@@ -445,7 +445,10 @@
/**
* An estimate of the number of milliamp-microsends used by this uid.
+ *
+ * @deprecated this measurement is vendor-dependent and not reliable.
*/
+ @Deprecated
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_CPU_POWER_MAMS = HealthKeys.BASE_UID + 64;
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index fe38605..03f5d66 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -114,7 +114,7 @@
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
// Current on-disk Parcel version
- private static final int VERSION = 153 + (USE_OLD_HISTORY ? 1000 : 0);
+ private static final int VERSION = 154 + (USE_OLD_HISTORY ? 1000 : 0);
// Maximum number of items we will record in the history.
private static final int MAX_HISTORY_ITEMS = 2000;
@@ -5463,7 +5463,6 @@
LongSamplingCounter mUserCpuTime;
LongSamplingCounter mSystemCpuTime;
- LongSamplingCounter mCpuPower;
LongSamplingCounter[][] mCpuClusterSpeed;
/**
@@ -5511,7 +5510,6 @@
mUserCpuTime = new LongSamplingCounter(mBsi.mOnBatteryTimeBase);
mSystemCpuTime = new LongSamplingCounter(mBsi.mOnBatteryTimeBase);
- mCpuPower = new LongSamplingCounter(mBsi.mOnBatteryTimeBase);
mWakelockStats = mBsi.new OverflowArrayMap<Wakelock>(uid) {
@Override public Wakelock instantiateObject() {
@@ -6162,11 +6160,6 @@
}
@Override
- public long getCpuPowerMaUs(int which) {
- return mCpuPower.getCountLocked(which);
- }
-
- @Override
public long getTimeAtCpuSpeed(int cluster, int step, int which) {
if (mCpuClusterSpeed != null) {
if (cluster >= 0 && cluster < mCpuClusterSpeed.length) {
@@ -6311,7 +6304,6 @@
mUserCpuTime.reset(false);
mSystemCpuTime.reset(false);
- mCpuPower.reset(false);
if (mCpuClusterSpeed != null) {
for (LongSamplingCounter[] speeds : mCpuClusterSpeed) {
@@ -6477,7 +6469,6 @@
mUserCpuTime.detach();
mSystemCpuTime.detach();
- mCpuPower.detach();
if (mCpuClusterSpeed != null) {
for (LongSamplingCounter[] cpuSpeeds : mCpuClusterSpeed) {
@@ -6677,7 +6668,6 @@
mUserCpuTime.writeToParcel(out);
mSystemCpuTime.writeToParcel(out);
- mCpuPower.writeToParcel(out);
if (mCpuClusterSpeed != null) {
out.writeInt(1);
@@ -6913,7 +6903,6 @@
mUserCpuTime = new LongSamplingCounter(mBsi.mOnBatteryTimeBase, in);
mSystemCpuTime = new LongSamplingCounter(mBsi.mOnBatteryTimeBase, in);
- mCpuPower = new LongSamplingCounter(mBsi.mOnBatteryTimeBase, in);
if (in.readInt() != 0) {
int numCpuClusters = in.readInt();
@@ -9705,8 +9694,7 @@
mKernelUidCpuTimeReader.readDelta(!mOnBatteryInternal ? null :
new KernelUidCpuTimeReader.Callback() {
@Override
- public void onUidCpuTime(int uid, long userTimeUs, long systemTimeUs,
- long powerMaUs) {
+ public void onUidCpuTime(int uid, long userTimeUs, long systemTimeUs) {
final Uid u = getUidStatsLocked(mapUid(uid));
// Accumulate the total system and user time.
@@ -9720,7 +9708,7 @@
TimeUtils.formatDuration(userTimeUs / 1000, sb);
sb.append(" s=");
TimeUtils.formatDuration(systemTimeUs / 1000, sb);
- sb.append(" p=").append(powerMaUs / 1000).append("mAms\n");
+ sb.append("\n");
}
if (numWakelocksF > 0) {
@@ -9736,13 +9724,11 @@
TimeUtils.formatDuration(userTimeUs / 1000, sb);
sb.append(" s=");
TimeUtils.formatDuration(systemTimeUs / 1000, sb);
- sb.append(" p=").append(powerMaUs / 1000).append("mAms");
Slog.d(TAG, sb.toString());
}
u.mUserCpuTime.addCountLocked(userTimeUs);
u.mSystemCpuTime.addCountLocked(systemTimeUs);
- u.mCpuPower.addCountLocked(powerMaUs);
// Add the cpu speeds to this UID. These are used as a ratio
// for computing the power this UID used.
@@ -11036,7 +11022,6 @@
u.mUserCpuTime.readSummaryFromParcelLocked(in);
u.mSystemCpuTime.readSummaryFromParcelLocked(in);
- u.mCpuPower.readSummaryFromParcelLocked(in);
if (in.readInt() != 0) {
final int numClusters = in.readInt();
@@ -11432,7 +11417,6 @@
u.mUserCpuTime.writeSummaryFromParcelLocked(out);
u.mSystemCpuTime.writeSummaryFromParcelLocked(out);
- u.mCpuPower.writeSummaryFromParcelLocked(out);
if (u.mCpuClusterSpeed != null) {
out.writeInt(1);
diff --git a/core/java/com/android/internal/os/KernelUidCpuTimeReader.java b/core/java/com/android/internal/os/KernelUidCpuTimeReader.java
index e8919ed..181e1ac 100644
--- a/core/java/com/android/internal/os/KernelUidCpuTimeReader.java
+++ b/core/java/com/android/internal/os/KernelUidCpuTimeReader.java
@@ -50,14 +50,12 @@
* @param uid UID of the app
* @param userTimeUs time spent executing in user space in microseconds
* @param systemTimeUs time spent executing in kernel space in microseconds
- * @param powerMaUs power consumed executing, in milli-ampere microseconds
*/
- void onUidCpuTime(int uid, long userTimeUs, long systemTimeUs, long powerMaUs);
+ void onUidCpuTime(int uid, long userTimeUs, long systemTimeUs);
}
private SparseLongArray mLastUserTimeUs = new SparseLongArray();
private SparseLongArray mLastSystemTimeUs = new SparseLongArray();
- private SparseLongArray mLastPowerMaUs = new SparseLongArray();
private long mLastTimeReadUs = 0;
/**
@@ -77,26 +75,18 @@
final int uid = Integer.parseInt(uidStr.substring(0, uidStr.length() - 1), 10);
final long userTimeUs = Long.parseLong(splitter.next(), 10);
final long systemTimeUs = Long.parseLong(splitter.next(), 10);
- final long powerMaUs;
- if (splitter.hasNext()) {
- powerMaUs = Long.parseLong(splitter.next(), 10) / 1000;
- } else {
- powerMaUs = 0;
- }
// Only report if there is a callback and if this is not the first read.
if (callback != null && mLastTimeReadUs != 0) {
long userTimeDeltaUs = userTimeUs;
long systemTimeDeltaUs = systemTimeUs;
- long powerDeltaMaUs = powerMaUs;
int index = mLastUserTimeUs.indexOfKey(uid);
if (index >= 0) {
userTimeDeltaUs -= mLastUserTimeUs.valueAt(index);
systemTimeDeltaUs -= mLastSystemTimeUs.valueAt(index);
- powerDeltaMaUs -= mLastPowerMaUs.valueAt(index);
final long timeDiffUs = nowUs - mLastTimeReadUs;
- if (userTimeDeltaUs < 0 || systemTimeDeltaUs < 0 || powerDeltaMaUs < 0) {
+ if (userTimeDeltaUs < 0 || systemTimeDeltaUs < 0) {
StringBuilder sb = new StringBuilder("Malformed cpu data for UID=");
sb.append(uid).append("!\n");
sb.append("Time between reads: ");
@@ -106,36 +96,28 @@
TimeUtils.formatDuration(mLastUserTimeUs.valueAt(index) / 1000, sb);
sb.append(" s=");
TimeUtils.formatDuration(mLastSystemTimeUs.valueAt(index) / 1000, sb);
- sb.append(" p=").append(mLastPowerMaUs.valueAt(index) / 1000);
- sb.append("mAms\n");
- sb.append("Current times: u=");
+ sb.append("\nCurrent times: u=");
TimeUtils.formatDuration(userTimeUs / 1000, sb);
sb.append(" s=");
TimeUtils.formatDuration(systemTimeUs / 1000, sb);
- sb.append(" p=").append(powerMaUs / 1000);
- sb.append("mAms\n");
- sb.append("Delta: u=");
+ sb.append("\nDelta: u=");
TimeUtils.formatDuration(userTimeDeltaUs / 1000, sb);
sb.append(" s=");
TimeUtils.formatDuration(systemTimeDeltaUs / 1000, sb);
- sb.append(" p=").append(powerDeltaMaUs / 1000).append("mAms");
Slog.e(TAG, sb.toString());
userTimeDeltaUs = 0;
systemTimeDeltaUs = 0;
- powerDeltaMaUs = 0;
}
}
- if (userTimeDeltaUs != 0 || systemTimeDeltaUs != 0 || powerDeltaMaUs != 0) {
- callback.onUidCpuTime(uid, userTimeDeltaUs, systemTimeDeltaUs,
- powerDeltaMaUs);
+ if (userTimeDeltaUs != 0 || systemTimeDeltaUs != 0) {
+ callback.onUidCpuTime(uid, userTimeDeltaUs, systemTimeDeltaUs);
}
}
mLastUserTimeUs.put(uid, userTimeUs);
mLastSystemTimeUs.put(uid, systemTimeUs);
- mLastPowerMaUs.put(uid, powerMaUs);
}
} catch (IOException e) {
Slog.e(TAG, "Failed to read uid_cputime: " + e.getMessage());
@@ -152,7 +134,6 @@
if (index >= 0) {
mLastUserTimeUs.removeAt(index);
mLastSystemTimeUs.removeAt(index);
- mLastPowerMaUs.removeAt(index);
}
try (FileWriter writer = new FileWriter(sRemoveUidProcFile)) {
diff --git a/services/core/java/com/android/server/am/HealthStatsBatteryStatsWriter.java b/services/core/java/com/android/server/am/HealthStatsBatteryStatsWriter.java
index 4a87941..c2f1890 100644
--- a/services/core/java/com/android/server/am/HealthStatsBatteryStatsWriter.java
+++ b/services/core/java/com/android/server/am/HealthStatsBatteryStatsWriter.java
@@ -46,6 +46,7 @@
/**
* Writes the contents of a BatteryStats.Uid into a HealthStatsWriter.
*/
+ @SuppressWarnings("deprecation")
public void writeUid(HealthStatsWriter uidWriter, BatteryStats bs, BatteryStats.Uid uid) {
int N;
BatteryStats.Timer timer;
@@ -365,8 +366,7 @@
uid.getSystemCpuTimeUs(STATS_SINCE_UNPLUGGED)/1000);
// MEASUREMENT_CPU_POWER_MAMS
- uidWriter.addMeasurement(UidHealthStats.MEASUREMENT_CPU_POWER_MAMS,
- uid.getCpuPowerMaUs(STATS_SINCE_UNPLUGGED)/1000);
+ uidWriter.addMeasurement(UidHealthStats.MEASUREMENT_CPU_POWER_MAMS, 0);
}
/**