Merge "Plumb display state and interactive information to BatteryStats."
This commit is contained in:
@@ -911,6 +911,8 @@ public abstract class BatteryStats implements Parcelable {
|
||||
*/
|
||||
public abstract int getScreenOnCount(int which);
|
||||
|
||||
public abstract long getInteractiveTime(long elapsedRealtimeUs, int which);
|
||||
|
||||
public static final int SCREEN_BRIGHTNESS_DARK = 0;
|
||||
public static final int SCREEN_BRIGHTNESS_DIM = 1;
|
||||
public static final int SCREEN_BRIGHTNESS_MEDIUM = 2;
|
||||
@@ -936,8 +938,6 @@ public abstract class BatteryStats implements Parcelable {
|
||||
public abstract long getScreenBrightnessTime(int brightnessBin,
|
||||
long elapsedRealtimeUs, int which);
|
||||
|
||||
public abstract int getInputEventCount(int which);
|
||||
|
||||
/**
|
||||
* Returns the time in microseconds that the phone has been on while the device was
|
||||
* running on battery.
|
||||
@@ -1571,6 +1571,7 @@ public abstract class BatteryStats implements Parcelable {
|
||||
final long totalRealtime = computeRealtime(rawRealtime, which);
|
||||
final long totalUptime = computeUptime(rawUptime, which);
|
||||
final long screenOnTime = getScreenOnTime(rawRealtime, which);
|
||||
final long interactiveTime = getInteractiveTime(rawRealtime, which);
|
||||
final long phoneOnTime = getPhoneOnTime(rawRealtime, which);
|
||||
final long wifiOnTime = getWifiOnTime(rawRealtime, which);
|
||||
final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which);
|
||||
@@ -1639,8 +1640,8 @@ public abstract class BatteryStats implements Parcelable {
|
||||
wifiRunningTime / 1000, bluetoothOnTime / 1000,
|
||||
mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes,
|
||||
fullWakeLockTimeTotal, partialWakeLockTimeTotal,
|
||||
getInputEventCount(which), getMobileRadioActiveTime(rawRealtime, which),
|
||||
getMobileRadioActiveAdjustedTime(which));
|
||||
0 /*legacy input event count*/, getMobileRadioActiveTime(rawRealtime, which),
|
||||
getMobileRadioActiveAdjustedTime(which), interactiveTime / 1000);
|
||||
|
||||
// Dump screen brightness stats
|
||||
Object[] args = new Object[NUM_SCREEN_BRIGHTNESS_BINS];
|
||||
@@ -2013,6 +2014,7 @@ public abstract class BatteryStats implements Parcelable {
|
||||
sb.append("realtime, ");
|
||||
formatTimeMs(sb, totalUptime / 1000);
|
||||
sb.append("uptime");
|
||||
pw.println(sb.toString());
|
||||
if (batteryTimeRemaining >= 0) {
|
||||
sb.setLength(0);
|
||||
sb.append(prefix);
|
||||
@@ -2031,16 +2033,25 @@ public abstract class BatteryStats implements Parcelable {
|
||||
pw.println(DateFormat.format("yyyy-MM-dd-HH-mm-ss", getStartClockTime()).toString());
|
||||
|
||||
final long screenOnTime = getScreenOnTime(rawRealtime, which);
|
||||
final long interactiveTime = getInteractiveTime(rawRealtime, which);
|
||||
final long phoneOnTime = getPhoneOnTime(rawRealtime, which);
|
||||
final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which);
|
||||
final long wifiOnTime = getWifiOnTime(rawRealtime, which);
|
||||
final long bluetoothOnTime = getBluetoothOnTime(rawRealtime, which);
|
||||
sb.setLength(0);
|
||||
sb.append(prefix);
|
||||
sb.append(" Interactive: "); formatTimeMs(sb, interactiveTime / 1000);
|
||||
sb.append("("); sb.append(formatRatioLocked(interactiveTime, whichBatteryRealtime));
|
||||
sb.append(")");
|
||||
pw.println(sb.toString());
|
||||
sb.setLength(0);
|
||||
sb.append(prefix);
|
||||
sb.append(" Screen on: "); formatTimeMs(sb, screenOnTime / 1000);
|
||||
sb.append("("); sb.append(formatRatioLocked(screenOnTime, whichBatteryRealtime));
|
||||
sb.append(") "); sb.append(getScreenOnCount(which));
|
||||
sb.append("x, Input events: "); sb.append(getInputEventCount(which));
|
||||
sb.append("x, Active phone call: "); formatTimeMs(sb, phoneOnTime / 1000);
|
||||
sb.append("("); sb.append(formatRatioLocked(phoneOnTime, whichBatteryRealtime));
|
||||
sb.append(")");
|
||||
pw.println(sb.toString());
|
||||
if (phoneOnTime != 0) {
|
||||
sb.setLength(0);
|
||||
|
||||
@@ -59,11 +59,10 @@ interface IBatteryStats {
|
||||
void noteVibratorOff(int uid);
|
||||
void noteStartGps(int uid);
|
||||
void noteStopGps(int uid);
|
||||
void noteScreenOn();
|
||||
void noteScreenState(int state);
|
||||
void noteScreenBrightness(int brightness);
|
||||
void noteScreenOff();
|
||||
void noteInputEvent();
|
||||
void noteUserActivity(int uid, int event);
|
||||
void noteInteractive(boolean interactive);
|
||||
void noteMobileRadioPowerState(int powerState, long timestampNs);
|
||||
void notePhoneOn();
|
||||
void notePhoneOff();
|
||||
|
||||
@@ -51,6 +51,7 @@ import android.util.SparseArray;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.util.TimeUtils;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.net.NetworkStatsFactory;
|
||||
@@ -88,7 +89,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
|
||||
|
||||
// Current on-disk Parcel version
|
||||
private static final int VERSION = 104 + (USE_OLD_HISTORY ? 1000 : 0);
|
||||
private static final int VERSION = 105 + (USE_OLD_HISTORY ? 1000 : 0);
|
||||
|
||||
// Maximum number of items we will record in the history.
|
||||
private static final int MAX_HISTORY_ITEMS = 2000;
|
||||
@@ -237,13 +238,14 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
int mWakeLockNesting;
|
||||
boolean mWakeLockImportant;
|
||||
|
||||
boolean mScreenOn;
|
||||
int mScreenState = Display.STATE_UNKNOWN;
|
||||
StopwatchTimer mScreenOnTimer;
|
||||
|
||||
int mScreenBrightnessBin = -1;
|
||||
final StopwatchTimer[] mScreenBrightnessTimer = new StopwatchTimer[NUM_SCREEN_BRIGHTNESS_BINS];
|
||||
|
||||
Counter mInputEventCounter;
|
||||
boolean mInteractive;
|
||||
StopwatchTimer mInteractiveTimer;
|
||||
|
||||
boolean mPhoneOn;
|
||||
StopwatchTimer mPhoneOnTimer;
|
||||
@@ -2661,58 +2663,61 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
getUidStatsLocked(uid).noteStopGps(elapsedRealtime);
|
||||
}
|
||||
|
||||
public void noteScreenOnLocked() {
|
||||
if (!mScreenOn) {
|
||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
final long uptime = SystemClock.uptimeMillis();
|
||||
mHistoryCur.states |= HistoryItem.STATE_SCREEN_ON_FLAG;
|
||||
if (DEBUG_HISTORY) Slog.v(TAG, "Screen on to: "
|
||||
+ Integer.toHexString(mHistoryCur.states));
|
||||
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||
mScreenOn = true;
|
||||
mScreenOnTimer.startRunningLocked(elapsedRealtime);
|
||||
if (mScreenBrightnessBin >= 0) {
|
||||
mScreenBrightnessTimer[mScreenBrightnessBin].startRunningLocked(elapsedRealtime);
|
||||
}
|
||||
public void noteScreenStateLocked(int state) {
|
||||
if (mScreenState != state) {
|
||||
final int oldState = mScreenState;
|
||||
mScreenState = state;
|
||||
if (DEBUG) Slog.v(TAG, "Screen state: oldState=" + Display.stateToString(oldState)
|
||||
+ ", newState=" + Display.stateToString(state));
|
||||
|
||||
updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(), false,
|
||||
SystemClock.uptimeMillis() * 1000, elapsedRealtime * 1000);
|
||||
if (state == Display.STATE_ON) {
|
||||
// Screen turning on.
|
||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
final long uptime = SystemClock.uptimeMillis();
|
||||
mHistoryCur.states |= HistoryItem.STATE_SCREEN_ON_FLAG;
|
||||
if (DEBUG_HISTORY) Slog.v(TAG, "Screen on to: "
|
||||
+ Integer.toHexString(mHistoryCur.states));
|
||||
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||
mScreenOnTimer.startRunningLocked(elapsedRealtime);
|
||||
if (mScreenBrightnessBin >= 0) {
|
||||
mScreenBrightnessTimer[mScreenBrightnessBin].startRunningLocked(elapsedRealtime);
|
||||
}
|
||||
|
||||
// Fake a wake lock, so we consider the device waked as long
|
||||
// as the screen is on.
|
||||
noteStartWakeLocked(-1, -1, "screen", null, WAKE_TYPE_PARTIAL, false,
|
||||
elapsedRealtime, uptime);
|
||||
updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(), false,
|
||||
SystemClock.uptimeMillis() * 1000, elapsedRealtime * 1000);
|
||||
|
||||
// Update discharge amounts.
|
||||
if (mOnBatteryInternal) {
|
||||
updateDischargeScreenLevelsLocked(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fake a wake lock, so we consider the device waked as long
|
||||
// as the screen is on.
|
||||
noteStartWakeLocked(-1, -1, "screen", null, WAKE_TYPE_PARTIAL, false,
|
||||
elapsedRealtime, uptime);
|
||||
|
||||
public void noteScreenOffLocked() {
|
||||
if (mScreenOn) {
|
||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
final long uptime = SystemClock.uptimeMillis();
|
||||
mHistoryCur.states &= ~HistoryItem.STATE_SCREEN_ON_FLAG;
|
||||
if (DEBUG_HISTORY) Slog.v(TAG, "Screen off to: "
|
||||
+ Integer.toHexString(mHistoryCur.states));
|
||||
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||
mScreenOn = false;
|
||||
mScreenOnTimer.stopRunningLocked(elapsedRealtime);
|
||||
if (mScreenBrightnessBin >= 0) {
|
||||
mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
|
||||
}
|
||||
// Update discharge amounts.
|
||||
if (mOnBatteryInternal) {
|
||||
updateDischargeScreenLevelsLocked(false, true);
|
||||
}
|
||||
} else if (oldState == Display.STATE_ON) {
|
||||
// Screen turning off or dozing.
|
||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
final long uptime = SystemClock.uptimeMillis();
|
||||
mHistoryCur.states &= ~HistoryItem.STATE_SCREEN_ON_FLAG;
|
||||
if (DEBUG_HISTORY) Slog.v(TAG, "Screen off to: "
|
||||
+ Integer.toHexString(mHistoryCur.states));
|
||||
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||
mScreenOnTimer.stopRunningLocked(elapsedRealtime);
|
||||
if (mScreenBrightnessBin >= 0) {
|
||||
mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
|
||||
}
|
||||
|
||||
noteStopWakeLocked(-1, -1, "screen", WAKE_TYPE_PARTIAL,
|
||||
elapsedRealtime, uptime);
|
||||
noteStopWakeLocked(-1, -1, "screen", WAKE_TYPE_PARTIAL,
|
||||
elapsedRealtime, uptime);
|
||||
|
||||
updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(), true,
|
||||
SystemClock.uptimeMillis() * 1000, elapsedRealtime * 1000);
|
||||
updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(), true,
|
||||
SystemClock.uptimeMillis() * 1000, elapsedRealtime * 1000);
|
||||
|
||||
// Update discharge amounts.
|
||||
if (mOnBatteryInternal) {
|
||||
updateDischargeScreenLevelsLocked(true, false);
|
||||
// Update discharge amounts.
|
||||
if (mOnBatteryInternal) {
|
||||
updateDischargeScreenLevelsLocked(true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2730,7 +2735,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
if (DEBUG_HISTORY) Slog.v(TAG, "Screen brightness " + bin + " to: "
|
||||
+ Integer.toHexString(mHistoryCur.states));
|
||||
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||
if (mScreenOn) {
|
||||
if (mScreenState == Display.STATE_ON) {
|
||||
if (mScreenBrightnessBin >= 0) {
|
||||
mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
|
||||
}
|
||||
@@ -2740,10 +2745,6 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
}
|
||||
|
||||
public void noteInputEventAtomic() {
|
||||
mInputEventCounter.stepAtomic();
|
||||
}
|
||||
|
||||
public void noteUserActivityLocked(int uid, int event) {
|
||||
if (mOnBatteryInternal) {
|
||||
uid = mapUid(uid);
|
||||
@@ -2751,6 +2752,19 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
}
|
||||
|
||||
public void noteInteractiveLocked(boolean interactive) {
|
||||
if (mInteractive != interactive) {
|
||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
mInteractive = interactive;
|
||||
if (DEBUG) Slog.v(TAG, "Interactive: " + interactive);
|
||||
if (interactive) {
|
||||
mInteractiveTimer.startRunningLocked(elapsedRealtime);
|
||||
} else {
|
||||
mInteractiveTimer.stopRunningLocked(elapsedRealtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void noteMobileRadioPowerState(int powerState, long timestampNs) {
|
||||
final long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
final long uptime = SystemClock.uptimeMillis();
|
||||
@@ -3449,8 +3463,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
elapsedRealtimeUs, which);
|
||||
}
|
||||
|
||||
@Override public int getInputEventCount(int which) {
|
||||
return mInputEventCounter.getCountLocked(which);
|
||||
@Override public long getInteractiveTime(long elapsedRealtimeUs, int which) {
|
||||
return mInteractiveTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
|
||||
}
|
||||
|
||||
@Override public long getPhoneOnTime(long elapsedRealtimeUs, int which) {
|
||||
@@ -5499,7 +5513,6 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||
mScreenBrightnessTimer[i] = new StopwatchTimer(null, -100-i, null, mOnBatteryTimeBase);
|
||||
}
|
||||
mInputEventCounter = new Counter(mOnBatteryTimeBase);
|
||||
mPhoneOnTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase);
|
||||
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
|
||||
mPhoneSignalStrengthsTimer[i] = new StopwatchTimer(null, -200-i, null,
|
||||
@@ -5530,6 +5543,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
mAudioOnTimer = new StopwatchTimer(null, -6, null, mOnBatteryTimeBase);
|
||||
mVideoOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase);
|
||||
mInteractiveTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase);
|
||||
mOnBattery = mOnBatteryInternal = false;
|
||||
long uptime = SystemClock.uptimeMillis() * 1000;
|
||||
long realtime = SystemClock.elapsedRealtime() * 1000;
|
||||
@@ -5713,7 +5727,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
|
||||
public boolean isScreenOn() {
|
||||
return mScreenOn;
|
||||
return mScreenState == Display.STATE_ON;
|
||||
}
|
||||
|
||||
void initTimes(long uptime, long realtime) {
|
||||
@@ -5753,7 +5767,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mOnBatteryTimeBase.reset(uptime, realtime);
|
||||
mOnBatteryScreenOffTimeBase.reset(uptime, realtime);
|
||||
if ((mHistoryCur.states&HistoryItem.STATE_BATTERY_PLUGGED_FLAG) == 0) {
|
||||
if (mScreenOn) {
|
||||
if (mScreenState == Display.STATE_ON) {
|
||||
mDischargeScreenOnUnplugLevel = mHistoryCur.batteryLevel;
|
||||
mDischargeScreenOffUnplugLevel = 0;
|
||||
} else {
|
||||
@@ -5773,7 +5787,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||
mScreenBrightnessTimer[i].reset(false);
|
||||
}
|
||||
mInputEventCounter.reset(false);
|
||||
mInteractiveTimer.reset(false);
|
||||
mPhoneOnTimer.reset(false);
|
||||
mAudioOnTimer.reset(false);
|
||||
mVideoOnTimer.reset(false);
|
||||
@@ -5874,7 +5888,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
updateKernelWakelocksLocked();
|
||||
updateNetworkActivityLocked(NET_UPDATE_ALL, SystemClock.elapsedRealtime());
|
||||
if (mOnBatteryInternal) {
|
||||
updateDischargeScreenLevelsLocked(mScreenOn, mScreenOn);
|
||||
final boolean screenOn = mScreenState == Display.STATE_ON;
|
||||
updateDischargeScreenLevelsLocked(screenOn, screenOn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5888,6 +5903,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
|
||||
final long uptime = mSecUptime * 1000;
|
||||
final long realtime = mSecRealtime * 1000;
|
||||
final boolean screenOn = mScreenState == Display.STATE_ON;
|
||||
if (onBattery) {
|
||||
// We will reset our status if we are unplugging after the
|
||||
// battery was last full, or the level is at 100, or
|
||||
@@ -5916,7 +5932,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
addHistoryRecordLocked(mSecRealtime, mSecUptime);
|
||||
mDischargeCurrentLevel = mDischargeUnplugLevel = level;
|
||||
if (mScreenOn) {
|
||||
if (screenOn) {
|
||||
mDischargeScreenOnUnplugLevel = level;
|
||||
mDischargeScreenOffUnplugLevel = 0;
|
||||
} else {
|
||||
@@ -5925,7 +5941,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
mDischargeAmountScreenOn = 0;
|
||||
mDischargeAmountScreenOff = 0;
|
||||
updateTimeBasesLocked(true, !mScreenOn, uptime, realtime);
|
||||
updateTimeBasesLocked(true, !screenOn, uptime, realtime);
|
||||
} else {
|
||||
pullPendingStateUpdatesLocked();
|
||||
mHistoryCur.batteryLevel = (byte)level;
|
||||
@@ -5938,8 +5954,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mLowDischargeAmountSinceCharge += mDischargeUnplugLevel-level-1;
|
||||
mHighDischargeAmountSinceCharge += mDischargeUnplugLevel-level;
|
||||
}
|
||||
updateDischargeScreenLevelsLocked(mScreenOn, mScreenOn);
|
||||
updateTimeBasesLocked(false, !mScreenOn, uptime, realtime);
|
||||
updateDischargeScreenLevelsLocked(screenOn, screenOn);
|
||||
updateTimeBasesLocked(false, !screenOn, uptime, realtime);
|
||||
mNumChargeStepDurations = 0;
|
||||
mLastChargeStepLevel = level;
|
||||
mLastChargeStepTime = -1;
|
||||
@@ -6475,7 +6491,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
public int getDischargeAmountScreenOn() {
|
||||
synchronized(this) {
|
||||
int val = mDischargeAmountScreenOn;
|
||||
if (mOnBattery && mScreenOn
|
||||
if (mOnBattery && mScreenState == Display.STATE_ON
|
||||
&& mDischargeCurrentLevel < mDischargeScreenOnUnplugLevel) {
|
||||
val += mDischargeScreenOnUnplugLevel-mDischargeCurrentLevel;
|
||||
}
|
||||
@@ -6486,7 +6502,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
public int getDischargeAmountScreenOnSinceCharge() {
|
||||
synchronized(this) {
|
||||
int val = mDischargeAmountScreenOnSinceCharge;
|
||||
if (mOnBattery && mScreenOn
|
||||
if (mOnBattery && mScreenState == Display.STATE_ON
|
||||
&& mDischargeCurrentLevel < mDischargeScreenOnUnplugLevel) {
|
||||
val += mDischargeScreenOnUnplugLevel-mDischargeCurrentLevel;
|
||||
}
|
||||
@@ -6497,7 +6513,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
public int getDischargeAmountScreenOff() {
|
||||
synchronized(this) {
|
||||
int val = mDischargeAmountScreenOff;
|
||||
if (mOnBattery && !mScreenOn
|
||||
if (mOnBattery && mScreenState != Display.STATE_ON
|
||||
&& mDischargeCurrentLevel < mDischargeScreenOffUnplugLevel) {
|
||||
val += mDischargeScreenOffUnplugLevel-mDischargeCurrentLevel;
|
||||
}
|
||||
@@ -6508,7 +6524,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
public int getDischargeAmountScreenOffSinceCharge() {
|
||||
synchronized(this) {
|
||||
int val = mDischargeAmountScreenOffSinceCharge;
|
||||
if (mOnBattery && !mScreenOn
|
||||
if (mOnBattery && mScreenState != Display.STATE_ON
|
||||
&& mDischargeCurrentLevel < mDischargeScreenOffUnplugLevel) {
|
||||
val += mDischargeScreenOffUnplugLevel-mDischargeCurrentLevel;
|
||||
}
|
||||
@@ -6915,12 +6931,13 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
|
||||
mStartCount++;
|
||||
|
||||
mScreenOn = false;
|
||||
mScreenState = Display.STATE_UNKNOWN;
|
||||
mScreenOnTimer.readSummaryFromParcelLocked(in);
|
||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||
mScreenBrightnessTimer[i].readSummaryFromParcelLocked(in);
|
||||
}
|
||||
mInputEventCounter.readSummaryFromParcelLocked(in);
|
||||
mInteractive = false;
|
||||
mInteractiveTimer.readSummaryFromParcelLocked(in);
|
||||
mPhoneOn = false;
|
||||
mPhoneOnTimer.readSummaryFromParcelLocked(in);
|
||||
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
|
||||
@@ -7175,7 +7192,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||
mScreenBrightnessTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS);
|
||||
}
|
||||
mInputEventCounter.writeSummaryFromParcelLocked(out);
|
||||
mInteractiveTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
|
||||
mPhoneOnTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
|
||||
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
|
||||
mPhoneSignalStrengthsTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS);
|
||||
@@ -7431,13 +7448,12 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mOnBatteryTimeBase.readFromParcel(in);
|
||||
mOnBatteryScreenOffTimeBase.readFromParcel(in);
|
||||
|
||||
mScreenOn = false;
|
||||
mScreenState = Display.STATE_UNKNOWN;
|
||||
mScreenOnTimer = new StopwatchTimer(null, -1, null, mOnBatteryTimeBase, in);
|
||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||
mScreenBrightnessTimer[i] = new StopwatchTimer(null, -100-i, null, mOnBatteryTimeBase,
|
||||
in);
|
||||
}
|
||||
mInputEventCounter = new Counter(mOnBatteryTimeBase, in);
|
||||
mPhoneOn = false;
|
||||
mPhoneOnTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase, in);
|
||||
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
|
||||
@@ -7461,19 +7477,25 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
mMobileRadioActiveUnknownTime = new LongSamplingCounter(mOnBatteryTimeBase, in);
|
||||
mMobileRadioActiveUnknownCount = new LongSamplingCounter(mOnBatteryTimeBase, in);
|
||||
mWifiOn = false;
|
||||
mWifiOnTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase, in);
|
||||
mWifiOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase, in);
|
||||
mGlobalWifiRunning = false;
|
||||
mGlobalWifiRunningTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase, in);
|
||||
mGlobalWifiRunningTimer = new StopwatchTimer(null, -4, null, mOnBatteryTimeBase, in);
|
||||
for (int i=0; i<NUM_WIFI_STATES; i++) {
|
||||
mWifiStateTimer[i] = new StopwatchTimer(null, -600-i,
|
||||
null, mOnBatteryTimeBase, in);
|
||||
}
|
||||
mBluetoothOn = false;
|
||||
mBluetoothOnTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase, in);
|
||||
mBluetoothOnTimer = new StopwatchTimer(null, -5, null, mOnBatteryTimeBase, in);
|
||||
for (int i=0; i< NUM_BLUETOOTH_STATES; i++) {
|
||||
mBluetoothStateTimer[i] = new StopwatchTimer(null, -500-i,
|
||||
null, mOnBatteryTimeBase, in);
|
||||
}
|
||||
mAudioOn = false;
|
||||
mAudioOnTimer = new StopwatchTimer(null, -6, null, mOnBatteryTimeBase);
|
||||
mVideoOn = false;
|
||||
mVideoOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase);
|
||||
mInteractive = false;
|
||||
mInteractiveTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase, in);
|
||||
mDischargeUnplugLevel = in.readInt();
|
||||
mDischargePlugLevel = in.readInt();
|
||||
mDischargeCurrentLevel = in.readInt();
|
||||
@@ -7571,7 +7593,7 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
|
||||
mScreenBrightnessTimer[i].writeToParcel(out, uSecRealtime);
|
||||
}
|
||||
mInputEventCounter.writeToParcel(out);
|
||||
mInteractiveTimer.writeToParcel(out, uSecRealtime);
|
||||
mPhoneOnTimer.writeToParcel(out, uSecRealtime);
|
||||
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
|
||||
mPhoneSignalStrengthsTimer[i].writeToParcel(out, uSecRealtime);
|
||||
@@ -7688,8 +7710,8 @@ public final class BatteryStatsImpl extends BatteryStats {
|
||||
pr.println("*** Screen brightness #" + i + ":");
|
||||
mScreenBrightnessTimer[i].logState(pr, " ");
|
||||
}
|
||||
pr.println("*** Input event counter:");
|
||||
mInputEventCounter.logState(pr, " ");
|
||||
pr.println("*** Interactive timer:");
|
||||
mInteractiveTimer.logState(pr, " ");
|
||||
pr.println("*** Phone timer:");
|
||||
mPhoneOnTimer.logState(pr, " ");
|
||||
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
|
||||
|
||||
@@ -230,10 +230,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public void noteScreenOn() {
|
||||
public void noteScreenState(int state) {
|
||||
enforceCallingPermission();
|
||||
synchronized (mStats) {
|
||||
mStats.noteScreenOnLocked();
|
||||
mStats.noteScreenStateLocked(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,24 +244,19 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public void noteScreenOff() {
|
||||
enforceCallingPermission();
|
||||
synchronized (mStats) {
|
||||
mStats.noteScreenOffLocked();
|
||||
}
|
||||
}
|
||||
|
||||
public void noteInputEvent() {
|
||||
enforceCallingPermission();
|
||||
mStats.noteInputEventAtomic();
|
||||
}
|
||||
|
||||
public void noteUserActivity(int uid, int event) {
|
||||
enforceCallingPermission();
|
||||
synchronized (mStats) {
|
||||
mStats.noteUserActivityLocked(uid, event);
|
||||
}
|
||||
}
|
||||
|
||||
public void noteInteractive(boolean interactive) {
|
||||
enforceCallingPermission();
|
||||
synchronized (mStats) {
|
||||
mStats.noteInteractiveLocked(interactive);
|
||||
}
|
||||
}
|
||||
|
||||
public void noteMobileRadioPowerState(int powerState, long timestampNs) {
|
||||
enforceCallingPermission();
|
||||
|
||||
@@ -393,11 +393,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
|
||||
// Initialize screen state for battery stats.
|
||||
try {
|
||||
if (mPowerState.getScreenState() != Display.STATE_OFF) {
|
||||
mBatteryStats.noteScreenOn();
|
||||
} else {
|
||||
mBatteryStats.noteScreenOff();
|
||||
}
|
||||
mBatteryStats.noteScreenState(mPowerState.getScreenState());
|
||||
mBatteryStats.noteScreenBrightness(mPowerState.getScreenBrightness());
|
||||
} catch (RemoteException ex) {
|
||||
// same process
|
||||
@@ -641,11 +637,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
if (mPowerState.getScreenState() != state) {
|
||||
mPowerState.setScreenState(state);
|
||||
try {
|
||||
if (state != Display.STATE_OFF) {
|
||||
mBatteryStats.noteScreenOn();
|
||||
} else {
|
||||
mBatteryStats.noteScreenOff();
|
||||
}
|
||||
mBatteryStats.noteScreenState(state);
|
||||
} catch (RemoteException ex) {
|
||||
// same process
|
||||
}
|
||||
|
||||
@@ -132,6 +132,11 @@ final class Notifier {
|
||||
mScreenOffIntent = new Intent(Intent.ACTION_SCREEN_OFF);
|
||||
mScreenOffIntent.addFlags(
|
||||
Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
|
||||
// Initialize interactive state for battery stats.
|
||||
try {
|
||||
mBatteryStats.noteInteractive(true);
|
||||
} catch (RemoteException ex) { }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,7 +264,14 @@ final class Notifier {
|
||||
// Going to sleep...
|
||||
mLastGoToSleepReason = reason;
|
||||
}
|
||||
mInputManagerInternal.setInteractive(interactive);
|
||||
}
|
||||
|
||||
mInputManagerInternal.setInteractive(interactive);
|
||||
|
||||
if (interactive) {
|
||||
try {
|
||||
mBatteryStats.noteInteractive(true);
|
||||
} catch (RemoteException ex) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,6 +301,12 @@ final class Notifier {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!interactive) {
|
||||
try {
|
||||
mBatteryStats.noteInteractive(false);
|
||||
} catch (RemoteException ex) { }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user