Merge "batstats: fix wake lock tracking, service bug"
This commit is contained in:
committed by
Android (Google) Code Review
commit
024a003d4c
@@ -570,13 +570,15 @@ public abstract class BatteryStats implements Parcelable {
|
|||||||
public static final int STATE_PHONE_IN_CALL_FLAG = 1<<18;
|
public static final int STATE_PHONE_IN_CALL_FLAG = 1<<18;
|
||||||
public static final int STATE_WIFI_ON_FLAG = 1<<17;
|
public static final int STATE_WIFI_ON_FLAG = 1<<17;
|
||||||
public static final int STATE_BLUETOOTH_ON_FLAG = 1<<16;
|
public static final int STATE_BLUETOOTH_ON_FLAG = 1<<16;
|
||||||
|
|
||||||
public static final int MOST_INTERESTING_STATES =
|
public static final int MOST_INTERESTING_STATES =
|
||||||
STATE_BATTERY_PLUGGED_FLAG | STATE_SCREEN_ON_FLAG
|
STATE_BATTERY_PLUGGED_FLAG | STATE_SCREEN_ON_FLAG
|
||||||
| STATE_GPS_ON_FLAG | STATE_PHONE_IN_CALL_FLAG;
|
| STATE_GPS_ON_FLAG | STATE_PHONE_IN_CALL_FLAG;
|
||||||
|
|
||||||
public int states;
|
public int states;
|
||||||
|
|
||||||
|
public int states2;
|
||||||
|
|
||||||
// The wake lock that was acquired at this point.
|
// The wake lock that was acquired at this point.
|
||||||
public HistoryTag wakelockTag;
|
public HistoryTag wakelockTag;
|
||||||
|
|
||||||
@@ -1215,6 +1217,11 @@ public abstract class BatteryStats implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public abstract int getHighDischargeAmountSinceCharge();
|
public abstract int getHighDischargeAmountSinceCharge();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the discharge amount over the selected discharge period <var>which</var>.
|
||||||
|
*/
|
||||||
|
public abstract int getDischargeAmount(int which);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount the battery has discharged while the screen was on,
|
* Get the amount the battery has discharged while the screen was on,
|
||||||
* since the last time power was unplugged.
|
* since the last time power was unplugged.
|
||||||
|
|||||||
@@ -208,7 +208,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
int mNumHistoryTagChars = 0;
|
int mNumHistoryTagChars = 0;
|
||||||
int mHistoryBufferLastPos = -1;
|
int mHistoryBufferLastPos = -1;
|
||||||
boolean mHistoryOverflow = false;
|
boolean mHistoryOverflow = false;
|
||||||
long mLastHistoryTime = 0;
|
long mLastHistoryElapsedRealtime = 0;
|
||||||
|
long mLastHistoryUptime = 0;
|
||||||
|
|
||||||
final HistoryItem mHistoryCur = new HistoryItem();
|
final HistoryItem mHistoryCur = new HistoryItem();
|
||||||
|
|
||||||
@@ -1957,12 +1958,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addHistoryBufferLocked(long curTime) {
|
void addHistoryBufferLocked(long elapsedRealtimeMs, long uptimeMs) {
|
||||||
if (!mHaveBatteryLevel || !mRecordingHistory) {
|
if (!mHaveBatteryLevel || !mRecordingHistory) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final long timeDiff = (mHistoryBaseTime+curTime) - mHistoryLastWritten.time;
|
final long timeDiff = (mHistoryBaseTime+elapsedRealtimeMs) - mHistoryLastWritten.time;
|
||||||
final int diffStates = mHistoryLastWritten.states^mHistoryCur.states;
|
final int diffStates = mHistoryLastWritten.states^mHistoryCur.states;
|
||||||
final int lastDiffStates = mHistoryLastWritten.states^mHistoryLastLastWritten.states;
|
final int lastDiffStates = mHistoryLastWritten.states^mHistoryLastLastWritten.states;
|
||||||
if (DEBUG) Slog.i(TAG, "ADD: tdelta=" + timeDiff + " diff="
|
if (DEBUG) Slog.i(TAG, "ADD: tdelta=" + timeDiff + " diff="
|
||||||
@@ -1981,14 +1982,14 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
&& mHistoryLastWritten.batteryTemperature == mHistoryCur.batteryTemperature
|
&& mHistoryLastWritten.batteryTemperature == mHistoryCur.batteryTemperature
|
||||||
&& mHistoryLastWritten.batteryVoltage == mHistoryCur.batteryVoltage) {
|
&& mHistoryLastWritten.batteryVoltage == mHistoryCur.batteryVoltage) {
|
||||||
// We can merge this new change in with the last one. Merging is
|
// We can merge this new change in with the last one. Merging is
|
||||||
// allows as long as only the states have changed, and within those states
|
// allowed as long as only the states have changed, and within those states
|
||||||
// as long as no bit has changed both between now and the last entry, as
|
// as long as no bit has changed both between now and the last entry, as
|
||||||
// well as the last entry and the one before it (so we capture any toggles).
|
// well as the last entry and the one before it (so we capture any toggles).
|
||||||
if (DEBUG) Slog.i(TAG, "ADD: rewinding back to " + mHistoryBufferLastPos);
|
if (DEBUG) Slog.i(TAG, "ADD: rewinding back to " + mHistoryBufferLastPos);
|
||||||
mHistoryBuffer.setDataSize(mHistoryBufferLastPos);
|
mHistoryBuffer.setDataSize(mHistoryBufferLastPos);
|
||||||
mHistoryBuffer.setDataPosition(mHistoryBufferLastPos);
|
mHistoryBuffer.setDataPosition(mHistoryBufferLastPos);
|
||||||
mHistoryBufferLastPos = -1;
|
mHistoryBufferLastPos = -1;
|
||||||
curTime = mHistoryLastWritten.time - mHistoryBaseTime;
|
elapsedRealtimeMs = mHistoryLastWritten.time - mHistoryBaseTime;
|
||||||
// If the last written history had a wakelock tag, we need to retain it.
|
// If the last written history had a wakelock tag, we need to retain it.
|
||||||
// Note that the condition above made sure that we aren't in a case where
|
// Note that the condition above made sure that we aren't in a case where
|
||||||
// both it and the current history item have a wakelock tag.
|
// both it and the current history item have a wakelock tag.
|
||||||
@@ -2018,8 +2019,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
if (dataSize >= MAX_HISTORY_BUFFER) {
|
if (dataSize >= MAX_HISTORY_BUFFER) {
|
||||||
if (!mHistoryOverflow) {
|
if (!mHistoryOverflow) {
|
||||||
mHistoryOverflow = true;
|
mHistoryOverflow = true;
|
||||||
addHistoryBufferLocked(curTime, HistoryItem.CMD_UPDATE);
|
addHistoryBufferLocked(elapsedRealtimeMs, uptimeMs, HistoryItem.CMD_UPDATE);
|
||||||
addHistoryBufferLocked(curTime, HistoryItem.CMD_OVERFLOW);
|
addHistoryBufferLocked(elapsedRealtimeMs, uptimeMs, HistoryItem.CMD_OVERFLOW);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2034,22 +2035,23 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
addHistoryBufferLocked(curTime, HistoryItem.CMD_UPDATE);
|
addHistoryBufferLocked(elapsedRealtimeMs, uptimeMs, HistoryItem.CMD_UPDATE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
addHistoryBufferLocked(curTime, HistoryItem.CMD_UPDATE);
|
addHistoryBufferLocked(elapsedRealtimeMs, uptimeMs, HistoryItem.CMD_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addHistoryBufferLocked(long curTime, byte cmd) {
|
private void addHistoryBufferLocked(long elapsedRealtimeMs, long uptimeMs, byte cmd) {
|
||||||
if (mIteratingHistory) {
|
if (mIteratingHistory) {
|
||||||
throw new IllegalStateException("Can't do this while iterating history!");
|
throw new IllegalStateException("Can't do this while iterating history!");
|
||||||
}
|
}
|
||||||
mHistoryBufferLastPos = mHistoryBuffer.dataPosition();
|
mHistoryBufferLastPos = mHistoryBuffer.dataPosition();
|
||||||
mHistoryLastLastWritten.setTo(mHistoryLastWritten);
|
mHistoryLastLastWritten.setTo(mHistoryLastWritten);
|
||||||
mHistoryLastWritten.setTo(mHistoryBaseTime + curTime, cmd, mHistoryCur);
|
mHistoryLastWritten.setTo(mHistoryBaseTime + elapsedRealtimeMs, cmd, mHistoryCur);
|
||||||
writeHistoryDelta(mHistoryBuffer, mHistoryLastWritten, mHistoryLastLastWritten);
|
writeHistoryDelta(mHistoryBuffer, mHistoryLastWritten, mHistoryLastLastWritten);
|
||||||
mLastHistoryTime = curTime;
|
mLastHistoryElapsedRealtime = elapsedRealtimeMs;
|
||||||
|
mLastHistoryUptime = uptimeMs;
|
||||||
mHistoryCur.wakelockTag = null;
|
mHistoryCur.wakelockTag = null;
|
||||||
mHistoryCur.wakeReasonTag = null;
|
mHistoryCur.wakeReasonTag = null;
|
||||||
mHistoryCur.eventCode = HistoryItem.EVENT_NONE;
|
mHistoryCur.eventCode = HistoryItem.EVENT_NONE;
|
||||||
@@ -2061,8 +2063,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
|
|
||||||
int mChangedStates = 0;
|
int mChangedStates = 0;
|
||||||
|
|
||||||
void addHistoryRecordLocked(long curTime) {
|
void addHistoryRecordLocked(long elapsedRealtimeMs, long uptimeMs) {
|
||||||
addHistoryBufferLocked(curTime);
|
addHistoryBufferLocked(elapsedRealtimeMs, uptimeMs);
|
||||||
|
|
||||||
if (!USE_OLD_HISTORY) {
|
if (!USE_OLD_HISTORY) {
|
||||||
return;
|
return;
|
||||||
@@ -2077,12 +2079,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
// are now resetting back to their original value, then just collapse
|
// are now resetting back to their original value, then just collapse
|
||||||
// into one record.
|
// into one record.
|
||||||
if (mHistoryEnd != null && mHistoryEnd.cmd == HistoryItem.CMD_UPDATE
|
if (mHistoryEnd != null && mHistoryEnd.cmd == HistoryItem.CMD_UPDATE
|
||||||
&& (mHistoryBaseTime+curTime) < (mHistoryEnd.time+2000)
|
&& (mHistoryBaseTime+elapsedRealtimeMs) < (mHistoryEnd.time+1000)
|
||||||
&& ((mHistoryEnd.states^mHistoryCur.states)&mChangedStates) == 0) {
|
&& ((mHistoryEnd.states^mHistoryCur.states)&mChangedStates) == 0) {
|
||||||
// If the current is the same as the one before, then we no
|
// If the current is the same as the one before, then we no
|
||||||
// longer need the entry.
|
// longer need the entry.
|
||||||
if (mHistoryLastEnd != null && mHistoryLastEnd.cmd == HistoryItem.CMD_UPDATE
|
if (mHistoryLastEnd != null && mHistoryLastEnd.cmd == HistoryItem.CMD_UPDATE
|
||||||
&& (mHistoryBaseTime+curTime) < (mHistoryEnd.time+500)
|
&& (mHistoryBaseTime+elapsedRealtimeMs) < (mHistoryEnd.time+500)
|
||||||
&& mHistoryLastEnd.sameNonEvent(mHistoryCur)) {
|
&& mHistoryLastEnd.sameNonEvent(mHistoryCur)) {
|
||||||
mHistoryLastEnd.next = null;
|
mHistoryLastEnd.next = null;
|
||||||
mHistoryEnd.next = mHistoryCache;
|
mHistoryEnd.next = mHistoryCache;
|
||||||
@@ -2100,7 +2102,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
|
|
||||||
if (mNumHistoryItems == MAX_HISTORY_ITEMS
|
if (mNumHistoryItems == MAX_HISTORY_ITEMS
|
||||||
|| mNumHistoryItems == MAX_MAX_HISTORY_ITEMS) {
|
|| mNumHistoryItems == MAX_MAX_HISTORY_ITEMS) {
|
||||||
addHistoryRecordLocked(curTime, HistoryItem.CMD_OVERFLOW);
|
addHistoryRecordLocked(elapsedRealtimeMs, HistoryItem.CMD_OVERFLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNumHistoryItems >= MAX_HISTORY_ITEMS) {
|
if (mNumHistoryItems >= MAX_HISTORY_ITEMS) {
|
||||||
@@ -2117,25 +2119,26 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addHistoryRecordLocked(curTime, HistoryItem.CMD_UPDATE);
|
addHistoryRecordLocked(elapsedRealtimeMs, HistoryItem.CMD_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addHistoryEventLocked(long curTime, int code, String name, int uid) {
|
void addHistoryEventLocked(long elapsedRealtimeMs, long uptimeMs, int code,
|
||||||
|
String name, int uid) {
|
||||||
mHistoryCur.eventCode = code;
|
mHistoryCur.eventCode = code;
|
||||||
mHistoryCur.eventTag = mHistoryCur.localEventTag;
|
mHistoryCur.eventTag = mHistoryCur.localEventTag;
|
||||||
mHistoryCur.eventTag.string = name;
|
mHistoryCur.eventTag.string = name;
|
||||||
mHistoryCur.eventTag.uid = uid;
|
mHistoryCur.eventTag.uid = uid;
|
||||||
addHistoryBufferLocked(curTime);
|
addHistoryBufferLocked(elapsedRealtimeMs, uptimeMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addHistoryRecordLocked(long curTime, byte cmd) {
|
void addHistoryRecordLocked(long elapsedRealtimeMs, long uptimeMs, byte cmd) {
|
||||||
HistoryItem rec = mHistoryCache;
|
HistoryItem rec = mHistoryCache;
|
||||||
if (rec != null) {
|
if (rec != null) {
|
||||||
mHistoryCache = rec.next;
|
mHistoryCache = rec.next;
|
||||||
} else {
|
} else {
|
||||||
rec = new HistoryItem();
|
rec = new HistoryItem();
|
||||||
}
|
}
|
||||||
rec.setTo(mHistoryBaseTime + curTime, cmd, mHistoryCur);
|
rec.setTo(mHistoryBaseTime + elapsedRealtimeMs, cmd, mHistoryCur);
|
||||||
|
|
||||||
addHistoryRecordLocked(rec);
|
addHistoryRecordLocked(rec);
|
||||||
}
|
}
|
||||||
@@ -2164,7 +2167,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mHistoryBaseTime = 0;
|
mHistoryBaseTime = 0;
|
||||||
mLastHistoryTime = 0;
|
mLastHistoryElapsedRealtime = 0;
|
||||||
|
mLastHistoryUptime = 0;
|
||||||
|
|
||||||
mHistoryBuffer.setDataSize(0);
|
mHistoryBuffer.setDataSize(0);
|
||||||
mHistoryBuffer.setDataPosition(0);
|
mHistoryBuffer.setDataPosition(0);
|
||||||
@@ -2262,7 +2266,9 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
active.remove(name);
|
active.remove(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addHistoryEventLocked(SystemClock.elapsedRealtime(), code, name, uid);
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
|
addHistoryEventLocked(elapsedRealtime, uptime, code, name, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestWakelockCpuUpdate() {
|
private void requestWakelockCpuUpdate() {
|
||||||
@@ -2273,7 +2279,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void noteStartWakeLocked(int uid, int pid, String name, String historyName, int type,
|
public void noteStartWakeLocked(int uid, int pid, String name, String historyName, int type,
|
||||||
boolean unimportantForLogging, long elapsedRealtime) {
|
boolean unimportantForLogging, long elapsedRealtime, long uptime) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
if (type == WAKE_TYPE_PARTIAL) {
|
if (type == WAKE_TYPE_PARTIAL) {
|
||||||
// Only care about partial wake locks, since full wake locks
|
// Only care about partial wake locks, since full wake locks
|
||||||
@@ -2286,7 +2292,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mHistoryCur.wakelockTag.string = historyName != null ? historyName : name;
|
mHistoryCur.wakelockTag.string = historyName != null ? historyName : name;
|
||||||
mHistoryCur.wakelockTag.uid = uid;
|
mHistoryCur.wakelockTag.uid = uid;
|
||||||
mWakeLockImportant = !unimportantForLogging;
|
mWakeLockImportant = !unimportantForLogging;
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
} else if (!mWakeLockImportant && !unimportantForLogging) {
|
} else if (!mWakeLockImportant && !unimportantForLogging) {
|
||||||
if (mHistoryLastWritten.wakelockTag != null) {
|
if (mHistoryLastWritten.wakelockTag != null) {
|
||||||
// We'll try to update the last tag.
|
// We'll try to update the last tag.
|
||||||
@@ -2294,19 +2300,23 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag;
|
mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag;
|
||||||
mHistoryCur.wakelockTag.string = historyName != null ? historyName : name;
|
mHistoryCur.wakelockTag.string = historyName != null ? historyName : name;
|
||||||
mHistoryCur.wakelockTag.uid = uid;
|
mHistoryCur.wakelockTag.uid = uid;
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
mWakeLockImportant = true;
|
mWakeLockImportant = true;
|
||||||
}
|
}
|
||||||
mWakeLockNesting++;
|
mWakeLockNesting++;
|
||||||
}
|
}
|
||||||
if (uid >= 0) {
|
if (uid >= 0) {
|
||||||
|
//if (uid == 0) {
|
||||||
|
// Slog.wtf(TAG, "Acquiring wake lock from root: " + name);
|
||||||
|
//}
|
||||||
requestWakelockCpuUpdate();
|
requestWakelockCpuUpdate();
|
||||||
getUidStatsLocked(uid).noteStartWakeLocked(pid, name, type, elapsedRealtime);
|
getUidStatsLocked(uid).noteStartWakeLocked(pid, name, type, elapsedRealtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void noteStopWakeLocked(int uid, int pid, String name, int type, long elapsedRealtime) {
|
public void noteStopWakeLocked(int uid, int pid, String name, int type, long elapsedRealtime,
|
||||||
|
long uptime) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
if (type == WAKE_TYPE_PARTIAL) {
|
if (type == WAKE_TYPE_PARTIAL) {
|
||||||
mWakeLockNesting--;
|
mWakeLockNesting--;
|
||||||
@@ -2314,7 +2324,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mHistoryCur.states &= ~HistoryItem.STATE_WAKE_LOCK_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_WAKE_LOCK_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Stop wake lock to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Stop wake lock to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (uid >= 0) {
|
if (uid >= 0) {
|
||||||
@@ -2326,10 +2336,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteStartWakeFromSourceLocked(WorkSource ws, int pid, String name,
|
public void noteStartWakeFromSourceLocked(WorkSource ws, int pid, String name,
|
||||||
String historyName, int type, boolean unimportantForLogging) {
|
String historyName, int type, boolean unimportantForLogging) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
final int N = ws.size();
|
final int N = ws.size();
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
noteStartWakeLocked(ws.get(i), pid, name, historyName, type, unimportantForLogging,
|
noteStartWakeLocked(ws.get(i), pid, name, historyName, type, unimportantForLogging,
|
||||||
elapsedRealtime);
|
elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2337,36 +2348,39 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
WorkSource newWs, int newPid, String newName,
|
WorkSource newWs, int newPid, String newName,
|
||||||
String newHistoryName, int newType, boolean newUnimportantForLogging) {
|
String newHistoryName, int newType, boolean newUnimportantForLogging) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
// For correct semantics, we start the need worksources first, so that we won't
|
// For correct semantics, we start the need worksources first, so that we won't
|
||||||
// make inappropriate history items as if all wake locks went away and new ones
|
// make inappropriate history items as if all wake locks went away and new ones
|
||||||
// appeared. This is okay because tracking of wake locks allows nesting.
|
// appeared. This is okay because tracking of wake locks allows nesting.
|
||||||
final int NN = ws.size();
|
final int NN = newWs.size();
|
||||||
for (int i=0; i<NN; i++) {
|
for (int i=0; i<NN; i++) {
|
||||||
noteStartWakeLocked(newWs.get(i), newPid, newName, newHistoryName, newType,
|
noteStartWakeLocked(newWs.get(i), newPid, newName, newHistoryName, newType,
|
||||||
newUnimportantForLogging, elapsedRealtime);
|
newUnimportantForLogging, elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
final int NO = ws.size();
|
final int NO = ws.size();
|
||||||
for (int i=0; i<NO; i++) {
|
for (int i=0; i<NO; i++) {
|
||||||
noteStopWakeLocked(ws.get(i), pid, name, type, elapsedRealtime);
|
noteStopWakeLocked(ws.get(i), pid, name, type, elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void noteStopWakeFromSourceLocked(WorkSource ws, int pid, String name, int type) {
|
public void noteStopWakeFromSourceLocked(WorkSource ws, int pid, String name, int type) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
final int N = ws.size();
|
final int N = ws.size();
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
noteStopWakeLocked(ws.get(i), pid, name, type, elapsedRealtime);
|
noteStopWakeLocked(ws.get(i), pid, name, type, elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void noteWakeupReasonLocked(int irq, String reason) {
|
public void noteWakeupReasonLocked(int irq, String reason) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Wakeup reason irq #" + irq + "\"" + reason +"\": "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Wakeup reason irq #" + irq + "\"" + reason +"\": "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
mHistoryCur.wakeReasonTag = mHistoryCur.localWakeReasonTag;
|
mHistoryCur.wakeReasonTag = mHistoryCur.localWakeReasonTag;
|
||||||
mHistoryCur.wakeReasonTag.string = reason;
|
mHistoryCur.wakeReasonTag.string = reason;
|
||||||
mHistoryCur.wakeReasonTag.uid = irq;
|
mHistoryCur.wakeReasonTag.uid = irq;
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int startAddingCpuLocked() {
|
public int startAddingCpuLocked() {
|
||||||
@@ -2511,11 +2525,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteStartSensorLocked(int uid, int sensor) {
|
public void noteStartSensorLocked(int uid, int sensor) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mSensorNesting == 0) {
|
if (mSensorNesting == 0) {
|
||||||
mHistoryCur.states |= HistoryItem.STATE_SENSOR_ON_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_SENSOR_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Start sensor to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Start sensor to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
mSensorNesting++;
|
mSensorNesting++;
|
||||||
getUidStatsLocked(uid).noteStartSensor(sensor, elapsedRealtime);
|
getUidStatsLocked(uid).noteStartSensor(sensor, elapsedRealtime);
|
||||||
@@ -2524,12 +2539,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteStopSensorLocked(int uid, int sensor) {
|
public void noteStopSensorLocked(int uid, int sensor) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mSensorNesting--;
|
mSensorNesting--;
|
||||||
if (mSensorNesting == 0) {
|
if (mSensorNesting == 0) {
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_SENSOR_ON_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_SENSOR_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Stop sensor to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Stop sensor to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
getUidStatsLocked(uid).noteStopSensor(sensor, elapsedRealtime);
|
getUidStatsLocked(uid).noteStopSensor(sensor, elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2539,11 +2555,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteStartGpsLocked(int uid) {
|
public void noteStartGpsLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mGpsNesting == 0) {
|
if (mGpsNesting == 0) {
|
||||||
mHistoryCur.states |= HistoryItem.STATE_GPS_ON_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_GPS_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Start GPS to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Start GPS to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
mGpsNesting++;
|
mGpsNesting++;
|
||||||
getUidStatsLocked(uid).noteStartGps(elapsedRealtime);
|
getUidStatsLocked(uid).noteStartGps(elapsedRealtime);
|
||||||
@@ -2552,12 +2569,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteStopGpsLocked(int uid) {
|
public void noteStopGpsLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mGpsNesting--;
|
mGpsNesting--;
|
||||||
if (mGpsNesting == 0) {
|
if (mGpsNesting == 0) {
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_GPS_ON_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_GPS_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Stop GPS to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Stop GPS to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
getUidStatsLocked(uid).noteStopGps(elapsedRealtime);
|
getUidStatsLocked(uid).noteStopGps(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2565,10 +2583,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteScreenOnLocked() {
|
public void noteScreenOnLocked() {
|
||||||
if (!mScreenOn) {
|
if (!mScreenOn) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states |= HistoryItem.STATE_SCREEN_ON_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_SCREEN_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Screen on to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Screen on to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mScreenOn = true;
|
mScreenOn = true;
|
||||||
mScreenOnTimer.startRunningLocked(elapsedRealtime);
|
mScreenOnTimer.startRunningLocked(elapsedRealtime);
|
||||||
if (mScreenBrightnessBin >= 0) {
|
if (mScreenBrightnessBin >= 0) {
|
||||||
@@ -2580,7 +2599,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
|
|
||||||
// Fake a wake lock, so we consider the device waked as long
|
// Fake a wake lock, so we consider the device waked as long
|
||||||
// as the screen is on.
|
// as the screen is on.
|
||||||
noteStartWakeLocked(-1, -1, "screen", null, WAKE_TYPE_PARTIAL, false, elapsedRealtime);
|
noteStartWakeLocked(-1, -1, "screen", null, WAKE_TYPE_PARTIAL, false,
|
||||||
|
elapsedRealtime, uptime);
|
||||||
|
|
||||||
// Update discharge amounts.
|
// Update discharge amounts.
|
||||||
if (mOnBatteryInternal) {
|
if (mOnBatteryInternal) {
|
||||||
@@ -2592,17 +2612,19 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteScreenOffLocked() {
|
public void noteScreenOffLocked() {
|
||||||
if (mScreenOn) {
|
if (mScreenOn) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_SCREEN_ON_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_SCREEN_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Screen off to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Screen off to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mScreenOn = false;
|
mScreenOn = false;
|
||||||
mScreenOnTimer.stopRunningLocked(elapsedRealtime);
|
mScreenOnTimer.stopRunningLocked(elapsedRealtime);
|
||||||
if (mScreenBrightnessBin >= 0) {
|
if (mScreenBrightnessBin >= 0) {
|
||||||
mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
|
mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
noteStopWakeLocked(-1, -1, "screen", WAKE_TYPE_PARTIAL, elapsedRealtime);
|
noteStopWakeLocked(-1, -1, "screen", WAKE_TYPE_PARTIAL,
|
||||||
|
elapsedRealtime, uptime);
|
||||||
|
|
||||||
updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(), true,
|
updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(), true,
|
||||||
SystemClock.uptimeMillis() * 1000, elapsedRealtime * 1000);
|
SystemClock.uptimeMillis() * 1000, elapsedRealtime * 1000);
|
||||||
@@ -2621,11 +2643,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
else if (bin >= NUM_SCREEN_BRIGHTNESS_BINS) bin = NUM_SCREEN_BRIGHTNESS_BINS-1;
|
else if (bin >= NUM_SCREEN_BRIGHTNESS_BINS) bin = NUM_SCREEN_BRIGHTNESS_BINS-1;
|
||||||
if (mScreenBrightnessBin != bin) {
|
if (mScreenBrightnessBin != bin) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_BRIGHTNESS_MASK)
|
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_BRIGHTNESS_MASK)
|
||||||
| (bin << HistoryItem.STATE_BRIGHTNESS_SHIFT);
|
| (bin << HistoryItem.STATE_BRIGHTNESS_SHIFT);
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Screen brightness " + bin + " to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Screen brightness " + bin + " to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
if (mScreenOn) {
|
if (mScreenOn) {
|
||||||
if (mScreenBrightnessBin >= 0) {
|
if (mScreenBrightnessBin >= 0) {
|
||||||
mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
|
mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
|
||||||
@@ -2650,12 +2673,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteDataConnectionActive(int type, boolean active) {
|
public void noteDataConnectionActive(int type, boolean active) {
|
||||||
if (ConnectivityManager.isNetworkTypeMobile(type)) {
|
if (ConnectivityManager.isNetworkTypeMobile(type)) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mMobileRadioActive != active) {
|
if (mMobileRadioActive != active) {
|
||||||
if (active) mHistoryCur.states |= HistoryItem.STATE_MOBILE_RADIO_ACTIVE_FLAG;
|
if (active) mHistoryCur.states |= HistoryItem.STATE_MOBILE_RADIO_ACTIVE_FLAG;
|
||||||
else mHistoryCur.states &= ~HistoryItem.STATE_MOBILE_RADIO_ACTIVE_FLAG;
|
else mHistoryCur.states &= ~HistoryItem.STATE_MOBILE_RADIO_ACTIVE_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Mobile network active " + active + " to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Mobile network active " + active + " to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mMobileRadioActive = active;
|
mMobileRadioActive = active;
|
||||||
if (active) {
|
if (active) {
|
||||||
mMobileRadioActiveTimer.startRunningLocked(elapsedRealtime);
|
mMobileRadioActiveTimer.startRunningLocked(elapsedRealtime);
|
||||||
@@ -2672,10 +2696,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void notePhoneOnLocked() {
|
public void notePhoneOnLocked() {
|
||||||
if (!mPhoneOn) {
|
if (!mPhoneOn) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states |= HistoryItem.STATE_PHONE_IN_CALL_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_PHONE_IN_CALL_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Phone on to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Phone on to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mPhoneOn = true;
|
mPhoneOn = true;
|
||||||
mPhoneOnTimer.startRunningLocked(elapsedRealtime);
|
mPhoneOnTimer.startRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2684,10 +2709,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void notePhoneOffLocked() {
|
public void notePhoneOffLocked() {
|
||||||
if (mPhoneOn) {
|
if (mPhoneOn) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_PHONE_IN_CALL_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_PHONE_IN_CALL_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Phone off to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Phone off to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mPhoneOn = false;
|
mPhoneOn = false;
|
||||||
mPhoneOnTimer.stopRunningLocked(elapsedRealtime);
|
mPhoneOnTimer.stopRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2727,6 +2753,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mPhoneSignalStrengthBinRaw = strengthBin;
|
mPhoneSignalStrengthBinRaw = strengthBin;
|
||||||
|
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
|
|
||||||
if (simState == TelephonyManager.SIM_STATE_ABSENT) {
|
if (simState == TelephonyManager.SIM_STATE_ABSENT) {
|
||||||
// In this case we will always be STATE_OUT_OF_SERVICE, so need
|
// In this case we will always be STATE_OUT_OF_SERVICE, so need
|
||||||
@@ -2800,7 +2827,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newHistory) {
|
if (newHistory) {
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2875,11 +2902,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
if (DEBUG) Log.i(TAG, "Phone Data Connection -> " + dataType + " = " + hasData);
|
if (DEBUG) Log.i(TAG, "Phone Data Connection -> " + dataType + " = " + hasData);
|
||||||
if (mPhoneDataConnectionType != bin) {
|
if (mPhoneDataConnectionType != bin) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_DATA_CONNECTION_MASK)
|
mHistoryCur.states = (mHistoryCur.states&~HistoryItem.STATE_DATA_CONNECTION_MASK)
|
||||||
| (bin << HistoryItem.STATE_DATA_CONNECTION_SHIFT);
|
| (bin << HistoryItem.STATE_DATA_CONNECTION_SHIFT);
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Data connection " + bin + " to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Data connection " + bin + " to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
if (mPhoneDataConnectionType >= 0) {
|
if (mPhoneDataConnectionType >= 0) {
|
||||||
mPhoneDataConnectionsTimer[mPhoneDataConnectionType].stopRunningLocked(
|
mPhoneDataConnectionsTimer[mPhoneDataConnectionType].stopRunningLocked(
|
||||||
elapsedRealtime);
|
elapsedRealtime);
|
||||||
@@ -2892,10 +2920,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteWifiOnLocked() {
|
public void noteWifiOnLocked() {
|
||||||
if (!mWifiOn) {
|
if (!mWifiOn) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states |= HistoryItem.STATE_WIFI_ON_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_WIFI_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI on to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI on to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mWifiOn = true;
|
mWifiOn = true;
|
||||||
mWifiOnTimer.startRunningLocked(elapsedRealtime);
|
mWifiOnTimer.startRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2903,11 +2932,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
|
|
||||||
public void noteWifiOffLocked() {
|
public void noteWifiOffLocked() {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mWifiOn) {
|
if (mWifiOn) {
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_ON_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI off to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI off to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mWifiOn = false;
|
mWifiOn = false;
|
||||||
mWifiOnTimer.stopRunningLocked(elapsedRealtime);
|
mWifiOnTimer.stopRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2916,11 +2946,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteAudioOnLocked(int uid) {
|
public void noteAudioOnLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (!mAudioOn) {
|
if (!mAudioOn) {
|
||||||
mHistoryCur.states |= HistoryItem.STATE_AUDIO_ON_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_AUDIO_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Audio on to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Audio on to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mAudioOn = true;
|
mAudioOn = true;
|
||||||
mAudioOnTimer.startRunningLocked(elapsedRealtime);
|
mAudioOnTimer.startRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2930,11 +2961,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteAudioOffLocked(int uid) {
|
public void noteAudioOffLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mAudioOn) {
|
if (mAudioOn) {
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_AUDIO_ON_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_AUDIO_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Audio off to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Audio off to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mAudioOn = false;
|
mAudioOn = false;
|
||||||
mAudioOnTimer.stopRunningLocked(elapsedRealtime);
|
mAudioOnTimer.stopRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2944,11 +2976,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteVideoOnLocked(int uid) {
|
public void noteVideoOnLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (!mVideoOn) {
|
if (!mVideoOn) {
|
||||||
mHistoryCur.states |= HistoryItem.STATE_VIDEO_ON_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_VIDEO_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Video on to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Video on to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mVideoOn = true;
|
mVideoOn = true;
|
||||||
mVideoOnTimer.startRunningLocked(elapsedRealtime);
|
mVideoOnTimer.startRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2958,11 +2991,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteVideoOffLocked(int uid) {
|
public void noteVideoOffLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mVideoOn) {
|
if (mVideoOn) {
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_VIDEO_ON_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_VIDEO_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Video off to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Video off to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mVideoOn = false;
|
mVideoOn = false;
|
||||||
mVideoOnTimer.stopRunningLocked(elapsedRealtime);
|
mVideoOnTimer.stopRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -2992,10 +3026,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteWifiRunningLocked(WorkSource ws) {
|
public void noteWifiRunningLocked(WorkSource ws) {
|
||||||
if (!mGlobalWifiRunning) {
|
if (!mGlobalWifiRunning) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states |= HistoryItem.STATE_WIFI_RUNNING_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_WIFI_RUNNING_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI running to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI running to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mGlobalWifiRunning = true;
|
mGlobalWifiRunning = true;
|
||||||
mGlobalWifiRunningTimer.startRunningLocked(elapsedRealtime);
|
mGlobalWifiRunningTimer.startRunningLocked(elapsedRealtime);
|
||||||
int N = ws.size();
|
int N = ws.size();
|
||||||
@@ -3029,10 +3064,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteWifiStoppedLocked(WorkSource ws) {
|
public void noteWifiStoppedLocked(WorkSource ws) {
|
||||||
if (mGlobalWifiRunning) {
|
if (mGlobalWifiRunning) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_RUNNING_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_RUNNING_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI stopped to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI stopped to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mGlobalWifiRunning = false;
|
mGlobalWifiRunning = false;
|
||||||
mGlobalWifiRunningTimer.stopRunningLocked(elapsedRealtime);
|
mGlobalWifiRunningTimer.stopRunningLocked(elapsedRealtime);
|
||||||
int N = ws.size();
|
int N = ws.size();
|
||||||
@@ -3060,10 +3096,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteBluetoothOnLocked() {
|
public void noteBluetoothOnLocked() {
|
||||||
if (!mBluetoothOn) {
|
if (!mBluetoothOn) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states |= HistoryItem.STATE_BLUETOOTH_ON_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_BLUETOOTH_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Bluetooth on to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Bluetooth on to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mBluetoothOn = true;
|
mBluetoothOn = true;
|
||||||
mBluetoothOnTimer.startRunningLocked(elapsedRealtime);
|
mBluetoothOnTimer.startRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -3072,10 +3109,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteBluetoothOffLocked() {
|
public void noteBluetoothOffLocked() {
|
||||||
if (mBluetoothOn) {
|
if (mBluetoothOn) {
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_BLUETOOTH_ON_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_BLUETOOTH_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Bluetooth off to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Bluetooth off to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
mBluetoothOn = false;
|
mBluetoothOn = false;
|
||||||
mBluetoothOnTimer.stopRunningLocked(elapsedRealtime);
|
mBluetoothOnTimer.stopRunningLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -3098,11 +3136,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteFullWifiLockAcquiredLocked(int uid) {
|
public void noteFullWifiLockAcquiredLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mWifiFullLockNesting == 0) {
|
if (mWifiFullLockNesting == 0) {
|
||||||
mHistoryCur.states |= HistoryItem.STATE_WIFI_FULL_LOCK_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_WIFI_FULL_LOCK_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI full lock on to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI full lock on to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
mWifiFullLockNesting++;
|
mWifiFullLockNesting++;
|
||||||
getUidStatsLocked(uid).noteFullWifiLockAcquiredLocked(elapsedRealtime);
|
getUidStatsLocked(uid).noteFullWifiLockAcquiredLocked(elapsedRealtime);
|
||||||
@@ -3111,12 +3150,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteFullWifiLockReleasedLocked(int uid) {
|
public void noteFullWifiLockReleasedLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mWifiFullLockNesting--;
|
mWifiFullLockNesting--;
|
||||||
if (mWifiFullLockNesting == 0) {
|
if (mWifiFullLockNesting == 0) {
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_FULL_LOCK_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_FULL_LOCK_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI full lock off to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI full lock off to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
getUidStatsLocked(uid).noteFullWifiLockReleasedLocked(elapsedRealtime);
|
getUidStatsLocked(uid).noteFullWifiLockReleasedLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -3126,11 +3166,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteWifiScanStartedLocked(int uid) {
|
public void noteWifiScanStartedLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mWifiScanNesting == 0) {
|
if (mWifiScanNesting == 0) {
|
||||||
mHistoryCur.states |= HistoryItem.STATE_WIFI_SCAN_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_WIFI_SCAN_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI scan started for: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI scan started for: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
mWifiScanNesting++;
|
mWifiScanNesting++;
|
||||||
getUidStatsLocked(uid).noteWifiScanStartedLocked(elapsedRealtime);
|
getUidStatsLocked(uid).noteWifiScanStartedLocked(elapsedRealtime);
|
||||||
@@ -3139,12 +3180,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteWifiScanStoppedLocked(int uid) {
|
public void noteWifiScanStoppedLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mWifiScanNesting--;
|
mWifiScanNesting--;
|
||||||
if (mWifiScanNesting == 0) {
|
if (mWifiScanNesting == 0) {
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_SCAN_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_SCAN_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI scan stopped for: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI scan stopped for: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
getUidStatsLocked(uid).noteWifiScanStoppedLocked(elapsedRealtime);
|
getUidStatsLocked(uid).noteWifiScanStoppedLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -3166,11 +3208,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteWifiMulticastEnabledLocked(int uid) {
|
public void noteWifiMulticastEnabledLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (mWifiMulticastNesting == 0) {
|
if (mWifiMulticastNesting == 0) {
|
||||||
mHistoryCur.states |= HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI multicast on to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI multicast on to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
mWifiMulticastNesting++;
|
mWifiMulticastNesting++;
|
||||||
getUidStatsLocked(uid).noteWifiMulticastEnabledLocked(elapsedRealtime);
|
getUidStatsLocked(uid).noteWifiMulticastEnabledLocked(elapsedRealtime);
|
||||||
@@ -3179,12 +3222,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void noteWifiMulticastDisabledLocked(int uid) {
|
public void noteWifiMulticastDisabledLocked(int uid) {
|
||||||
uid = mapUid(uid);
|
uid = mapUid(uid);
|
||||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
mWifiMulticastNesting--;
|
mWifiMulticastNesting--;
|
||||||
if (mWifiMulticastNesting == 0) {
|
if (mWifiMulticastNesting == 0) {
|
||||||
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG;
|
mHistoryCur.states &= ~HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI multicast off to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "WIFI multicast off to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(elapsedRealtime);
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
getUidStatsLocked(uid).noteWifiMulticastDisabledLocked(elapsedRealtime);
|
getUidStatsLocked(uid).noteWifiMulticastDisabledLocked(elapsedRealtime);
|
||||||
}
|
}
|
||||||
@@ -5627,12 +5671,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
|
|
||||||
public void resetAllStatsCmdLocked() {
|
public void resetAllStatsCmdLocked() {
|
||||||
resetAllStatsLocked();
|
resetAllStatsLocked();
|
||||||
long uptime = SystemClock.uptimeMillis() * 1000;
|
final long mSecUptime = SystemClock.uptimeMillis();
|
||||||
|
long uptime = mSecUptime * 1000;
|
||||||
long mSecRealtime = SystemClock.elapsedRealtime();
|
long mSecRealtime = SystemClock.elapsedRealtime();
|
||||||
long realtime = mSecRealtime * 1000;
|
long realtime = mSecRealtime * 1000;
|
||||||
mDischargeStartLevel = mHistoryCur.batteryLevel;
|
mDischargeStartLevel = mHistoryCur.batteryLevel;
|
||||||
pullPendingStateUpdatesLocked();
|
pullPendingStateUpdatesLocked();
|
||||||
addHistoryRecordLocked(mSecRealtime);
|
addHistoryRecordLocked(mSecRealtime, mSecUptime);
|
||||||
mDischargeCurrentLevel = mDischargeUnplugLevel = mHistoryCur.batteryLevel;
|
mDischargeCurrentLevel = mDischargeUnplugLevel = mHistoryCur.batteryLevel;
|
||||||
mOnBatteryTimeBase.reset(uptime, realtime);
|
mOnBatteryTimeBase.reset(uptime, realtime);
|
||||||
mOnBatteryScreenOffTimeBase.reset(uptime, realtime);
|
mOnBatteryScreenOffTimeBase.reset(uptime, realtime);
|
||||||
@@ -5647,7 +5692,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mDischargeAmountScreenOn = 0;
|
mDischargeAmountScreenOn = 0;
|
||||||
mDischargeAmountScreenOff = 0;
|
mDischargeAmountScreenOff = 0;
|
||||||
}
|
}
|
||||||
initActiveHistoryEventsLocked(mSecRealtime);
|
initActiveHistoryEventsLocked(mSecRealtime, mSecUptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetAllStatsLocked() {
|
private void resetAllStatsLocked() {
|
||||||
@@ -5705,7 +5750,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
clearHistoryLocked();
|
clearHistoryLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initActiveHistoryEventsLocked(long nowRealtime) {
|
private void initActiveHistoryEventsLocked(long elapsedRealtimeMs, long uptimeMs) {
|
||||||
for (int i=0; i<HistoryItem.EVENT_COUNT; i++) {
|
for (int i=0; i<HistoryItem.EVENT_COUNT; i++) {
|
||||||
HashMap<String, SparseBooleanArray> active = mActiveEvents[i];
|
HashMap<String, SparseBooleanArray> active = mActiveEvents[i];
|
||||||
if (active == null) {
|
if (active == null) {
|
||||||
@@ -5715,7 +5760,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
SparseBooleanArray uids = ent.getValue();
|
SparseBooleanArray uids = ent.getValue();
|
||||||
for (int j=0; j<uids.size(); j++) {
|
for (int j=0; j<uids.size(); j++) {
|
||||||
if (uids.valueAt(j)) {
|
if (uids.valueAt(j)) {
|
||||||
addHistoryEventLocked(nowRealtime, i, ent.getKey(), uids.keyAt(j));
|
addHistoryEventLocked(elapsedRealtimeMs, uptimeMs, i, ent.getKey(),
|
||||||
|
uids.keyAt(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5753,16 +5799,16 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOnBatteryLocked(boolean onBattery, int oldStatus, int level) {
|
void setOnBatteryLocked(final long mSecRealtime, final long mSecUptime, final boolean onBattery,
|
||||||
|
final int oldStatus, final int level) {
|
||||||
boolean doWrite = false;
|
boolean doWrite = false;
|
||||||
Message m = mHandler.obtainMessage(MSG_REPORT_POWER_CHANGE);
|
Message m = mHandler.obtainMessage(MSG_REPORT_POWER_CHANGE);
|
||||||
m.arg1 = onBattery ? 1 : 0;
|
m.arg1 = onBattery ? 1 : 0;
|
||||||
mHandler.sendMessage(m);
|
mHandler.sendMessage(m);
|
||||||
mOnBattery = mOnBatteryInternal = onBattery;
|
mOnBattery = mOnBatteryInternal = onBattery;
|
||||||
|
|
||||||
long uptime = SystemClock.uptimeMillis() * 1000;
|
final long uptime = mSecUptime * 1000;
|
||||||
long mSecRealtime = SystemClock.elapsedRealtime();
|
final long realtime = mSecRealtime * 1000;
|
||||||
long realtime = mSecRealtime * 1000;
|
|
||||||
if (onBattery) {
|
if (onBattery) {
|
||||||
// We will reset our status if we are unplugging after the
|
// We will reset our status if we are unplugging after the
|
||||||
// battery was last full, or the level is at 100, or
|
// battery was last full, or the level is at 100, or
|
||||||
@@ -5783,9 +5829,9 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Battery unplugged to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Battery unplugged to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
mHistoryCur.currentTime = System.currentTimeMillis();
|
mHistoryCur.currentTime = System.currentTimeMillis();
|
||||||
addHistoryBufferLocked(mSecRealtime, HistoryItem.CMD_CURRENT_TIME);
|
addHistoryBufferLocked(mSecRealtime, mSecUptime, HistoryItem.CMD_CURRENT_TIME);
|
||||||
mHistoryCur.currentTime = 0;
|
mHistoryCur.currentTime = 0;
|
||||||
addHistoryRecordLocked(mSecRealtime);
|
addHistoryRecordLocked(mSecRealtime, mSecUptime);
|
||||||
mDischargeCurrentLevel = mDischargeUnplugLevel = level;
|
mDischargeCurrentLevel = mDischargeUnplugLevel = level;
|
||||||
if (mScreenOn) {
|
if (mScreenOn) {
|
||||||
mDischargeScreenOnUnplugLevel = level;
|
mDischargeScreenOnUnplugLevel = level;
|
||||||
@@ -5798,7 +5844,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mDischargeAmountScreenOff = 0;
|
mDischargeAmountScreenOff = 0;
|
||||||
updateTimeBasesLocked(true, !mScreenOn, uptime, realtime);
|
updateTimeBasesLocked(true, !mScreenOn, uptime, realtime);
|
||||||
if (reset) {
|
if (reset) {
|
||||||
initActiveHistoryEventsLocked(mSecRealtime);
|
initActiveHistoryEventsLocked(mSecRealtime, mSecUptime);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pullPendingStateUpdatesLocked();
|
pullPendingStateUpdatesLocked();
|
||||||
@@ -5806,7 +5852,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mHistoryCur.states |= HistoryItem.STATE_BATTERY_PLUGGED_FLAG;
|
mHistoryCur.states |= HistoryItem.STATE_BATTERY_PLUGGED_FLAG;
|
||||||
if (DEBUG_HISTORY) Slog.v(TAG, "Battery plugged to: "
|
if (DEBUG_HISTORY) Slog.v(TAG, "Battery plugged to: "
|
||||||
+ Integer.toHexString(mHistoryCur.states));
|
+ Integer.toHexString(mHistoryCur.states));
|
||||||
addHistoryRecordLocked(mSecRealtime);
|
addHistoryRecordLocked(mSecRealtime, mSecUptime);
|
||||||
mDischargeCurrentLevel = level;
|
mDischargeCurrentLevel = level;
|
||||||
if (level < mDischargeUnplugLevel) {
|
if (level < mDischargeUnplugLevel) {
|
||||||
mLowDischargeAmountSinceCharge += mDischargeUnplugLevel-level-1;
|
mLowDischargeAmountSinceCharge += mDischargeUnplugLevel-level-1;
|
||||||
@@ -5828,7 +5874,9 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
public void setBatteryState(int status, int health, int plugType, int level,
|
public void setBatteryState(int status, int health, int plugType, int level,
|
||||||
int temp, int volt) {
|
int temp, int volt) {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
boolean onBattery = plugType == BATTERY_PLUGGED_NONE;
|
final boolean onBattery = plugType == BATTERY_PLUGGED_NONE;
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
int oldStatus = mHistoryCur.batteryStatus;
|
int oldStatus = mHistoryCur.batteryStatus;
|
||||||
if (!mHaveBatteryLevel) {
|
if (!mHaveBatteryLevel) {
|
||||||
mHaveBatteryLevel = true;
|
mHaveBatteryLevel = true;
|
||||||
@@ -5856,7 +5904,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
mHistoryCur.batteryPlugType = (byte)plugType;
|
mHistoryCur.batteryPlugType = (byte)plugType;
|
||||||
mHistoryCur.batteryTemperature = (short)temp;
|
mHistoryCur.batteryTemperature = (short)temp;
|
||||||
mHistoryCur.batteryVoltage = (char)volt;
|
mHistoryCur.batteryVoltage = (char)volt;
|
||||||
setOnBatteryLocked(onBattery, oldStatus, level);
|
setOnBatteryLocked(elapsedRealtime, uptime, onBattery, oldStatus, level);
|
||||||
} else {
|
} else {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
if (mHistoryCur.batteryLevel != level) {
|
if (mHistoryCur.batteryLevel != level) {
|
||||||
@@ -5886,7 +5934,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
addHistoryRecordLocked(SystemClock.elapsedRealtime());
|
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!onBattery && status == BatteryManager.BATTERY_STATUS_FULL) {
|
if (!onBattery && status == BatteryManager.BATTERY_STATUS_FULL) {
|
||||||
@@ -6161,7 +6209,18 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDischargeAmount(int which) {
|
||||||
|
int dischargeAmount = which == STATS_SINCE_CHARGED
|
||||||
|
? getHighDischargeAmountSinceCharge()
|
||||||
|
: (getDischargeStartLevel() - getDischargeCurrentLevel());
|
||||||
|
if (dischargeAmount < 0) {
|
||||||
|
dischargeAmount = 0;
|
||||||
|
}
|
||||||
|
return dischargeAmount;
|
||||||
|
}
|
||||||
|
|
||||||
public int getDischargeAmountScreenOn() {
|
public int getDischargeAmountScreenOn() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
int val = mDischargeAmountScreenOn;
|
int val = mDischargeAmountScreenOn;
|
||||||
@@ -6438,13 +6497,14 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mHistoryBuffer.dataPosition() > 0) {
|
if (mHistoryBuffer.dataPosition() > 0) {
|
||||||
long now = SystemClock.elapsedRealtime();
|
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||||
|
final long uptime = SystemClock.uptimeMillis();
|
||||||
if (USE_OLD_HISTORY) {
|
if (USE_OLD_HISTORY) {
|
||||||
addHistoryRecordLocked(now, HistoryItem.CMD_START);
|
addHistoryRecordLocked(elapsedRealtime, uptime, HistoryItem.CMD_START);
|
||||||
}
|
}
|
||||||
addHistoryBufferLocked(now, HistoryItem.CMD_START);
|
addHistoryBufferLocked(elapsedRealtime, uptime, HistoryItem.CMD_START);
|
||||||
mHistoryCur.currentTime = System.currentTimeMillis();
|
mHistoryCur.currentTime = System.currentTimeMillis();
|
||||||
addHistoryBufferLocked(now, HistoryItem.CMD_CURRENT_TIME);
|
addHistoryBufferLocked(elapsedRealtime, uptime, HistoryItem.CMD_CURRENT_TIME);
|
||||||
mHistoryCur.currentTime = 0;
|
mHistoryCur.currentTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6540,11 +6600,11 @@ public final class BatteryStatsImpl extends BatteryStats {
|
|||||||
StringBuilder sb = new StringBuilder(128);
|
StringBuilder sb = new StringBuilder(128);
|
||||||
sb.append("****************** WRITING mHistoryBaseTime: ");
|
sb.append("****************** WRITING mHistoryBaseTime: ");
|
||||||
TimeUtils.formatDuration(mHistoryBaseTime, sb);
|
TimeUtils.formatDuration(mHistoryBaseTime, sb);
|
||||||
sb.append(" mLastHistoryTime: ");
|
sb.append(" mLastHistoryElapsedRealtime: ");
|
||||||
TimeUtils.formatDuration(mLastHistoryTime, sb);
|
TimeUtils.formatDuration(mLastHistoryElapsedRealtime, sb);
|
||||||
Slog.i(TAG, sb.toString());
|
Slog.i(TAG, sb.toString());
|
||||||
}
|
}
|
||||||
out.writeLong(mHistoryBaseTime + mLastHistoryTime);
|
out.writeLong(mHistoryBaseTime + mLastHistoryElapsedRealtime);
|
||||||
out.writeInt(mHistoryTagPool.size());
|
out.writeInt(mHistoryTagPool.size());
|
||||||
for (HashMap.Entry<HistoryTag, Integer> ent : mHistoryTagPool.entrySet()) {
|
for (HashMap.Entry<HistoryTag, Integer> ent : mHistoryTagPool.entrySet()) {
|
||||||
HistoryTag tag = ent.getKey();
|
HistoryTag tag = ent.getKey();
|
||||||
|
|||||||
@@ -2087,10 +2087,12 @@ public final class ActiveServices {
|
|||||||
|
|
||||||
// Sanity check: if the service listed for the app is not one
|
// Sanity check: if the service listed for the app is not one
|
||||||
// we actually are maintaining, just let it drop.
|
// we actually are maintaining, just let it drop.
|
||||||
if (smap.mServicesByName.get(sr.name) != sr) {
|
final ServiceRecord curRec = smap.mServicesByName.get(sr.name);
|
||||||
ServiceRecord cur = smap.mServicesByName.get(sr.name);
|
if (curRec != sr) {
|
||||||
Slog.wtf(TAG, "Service " + sr + " in process " + app
|
if (curRec != null) {
|
||||||
+ " not same as in map: " + cur);
|
Slog.wtf(TAG, "Service " + sr + " in process " + app
|
||||||
|
+ " not same as in map: " + curRec);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,14 +135,15 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
|
|||||||
enforceCallingPermission();
|
enforceCallingPermission();
|
||||||
synchronized (mStats) {
|
synchronized (mStats) {
|
||||||
mStats.noteStartWakeLocked(uid, pid, name, historyName, type, unimportantForLogging,
|
mStats.noteStartWakeLocked(uid, pid, name, historyName, type, unimportantForLogging,
|
||||||
SystemClock.elapsedRealtime());
|
SystemClock.elapsedRealtime(), SystemClock.uptimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void noteStopWakelock(int uid, int pid, String name, int type) {
|
public void noteStopWakelock(int uid, int pid, String name, int type) {
|
||||||
enforceCallingPermission();
|
enforceCallingPermission();
|
||||||
synchronized (mStats) {
|
synchronized (mStats) {
|
||||||
mStats.noteStopWakeLocked(uid, pid, name, type, SystemClock.elapsedRealtime());
|
mStats.noteStopWakeLocked(uid, pid, name, type, SystemClock.elapsedRealtime(),
|
||||||
|
SystemClock.uptimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user