diff --git a/api/5.xml b/api/5.xml
index ca2cceb52a7f1..614804708a48a 100644
--- a/api/5.xml
+++ b/api/5.xml
@@ -112806,6 +112806,58 @@
>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
timerPool,
ArrayList unpluggables, Parcel in) {
super(type, unpluggables, in);
@@ -694,6 +701,10 @@ public final class BatteryStatsImpl extends BatteryStats {
mTimerPool = timerPool;
}
+ void setTimeout(long timeout) {
+ mTimeout = timeout;
+ }
+
public void writeToParcel(Parcel out, long batteryRealtime) {
super.writeToParcel(out, batteryRealtime);
out.writeLong(mUpdateTime);
@@ -797,6 +808,9 @@ public final class BatteryStatsImpl extends BatteryStats {
@Override
protected long computeRunTimeLocked(long curBatteryRealtime) {
+ if (mTimeout > 0 && curBatteryRealtime > mUpdateTime + mTimeout) {
+ curBatteryRealtime = mUpdateTime + mTimeout;
+ }
return mTotalTime + (mNesting > 0
? (curBatteryRealtime - mUpdateTime)
/ (mTimerPool != null ? mTimerPool.size() : 1)
@@ -1123,34 +1137,59 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
- public void noteAirplaneModeLocked(boolean isAirplaneMode) {
- final int bin = mPhoneSignalStrengthBin;
- if (bin >= 0) {
- if (!isAirplaneMode) {
- if (!mPhoneSignalStrengthsTimer[bin].isRunningLocked()) {
- mPhoneSignalStrengthsTimer[bin].startRunningLocked(this);
- }
- } else {
- for (int i = 0; i < NUM_SIGNAL_STRENGTH_BINS; i++) {
- while (mPhoneSignalStrengthsTimer[i].isRunningLocked()) {
- mPhoneSignalStrengthsTimer[i].stopRunningLocked(this);
- }
+ /**
+ * Telephony stack updates the phone state.
+ * @param state phone state from ServiceState.getState()
+ */
+ public void notePhoneStateLocked(int state) {
+ int bin = mPhoneSignalStrengthBin;
+ boolean isAirplaneMode = state == ServiceState.STATE_POWER_OFF;
+ // Stop all timers
+ if (isAirplaneMode || state == ServiceState.STATE_OUT_OF_SERVICE) {
+ for (int i = 0; i < NUM_SIGNAL_STRENGTH_BINS; i++) {
+ while (mPhoneSignalStrengthsTimer[i].isRunningLocked()) {
+ mPhoneSignalStrengthsTimer[i].stopRunningLocked(this);
}
}
}
+ // Stop Signal Scanning timer, in case we're going into service
+ while (mPhoneSignalScanningTimer.isRunningLocked()) {
+ mPhoneSignalScanningTimer.stopRunningLocked(this);
+ }
+
+ // If we're back in service or continuing in service, restart the old timer.
+ if (state == ServiceState.STATE_IN_SERVICE) {
+ if (bin == -1) bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ if (!mPhoneSignalStrengthsTimer[bin].isRunningLocked()) {
+ mPhoneSignalStrengthsTimer[bin].startRunningLocked(this);
+ }
+ } else if (state == ServiceState.STATE_OUT_OF_SERVICE) {
+ mPhoneSignalStrengthBin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ if (!mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].isRunningLocked()) {
+ mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].startRunningLocked(this);
+ }
+ if (!mPhoneSignalScanningTimer.isRunningLocked()) {
+ mPhoneSignalScanningTimer.startRunningLocked(this);
+ }
+ }
+ mPhoneServiceState = state;
}
public void notePhoneSignalStrengthLocked(SignalStrength signalStrength) {
// Bin the strength.
int bin;
-
+ if (mPhoneServiceState == ServiceState.STATE_POWER_OFF
+ || mPhoneServiceState == ServiceState.STATE_OUT_OF_SERVICE) {
+ // Ignore any signal strength changes when radio was turned off or out of service.
+ return;
+ }
if (!signalStrength.isGsm()) {
int dBm = signalStrength.getCdmaDbm();
- if (dBm >= -75) bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
- else if (dBm >= -85) bin = SIGNAL_STRENGTH_GREAT;
- else if (dBm >= -95) bin = SIGNAL_STRENGTH_GOOD;
- else if (dBm >= -100) bin = SIGNAL_STRENGTH_MODERATE;
- else bin = SIGNAL_STRENGTH_POOR;
+ if (dBm >= -75) bin = SIGNAL_STRENGTH_GREAT;
+ else if (dBm >= -85) bin = SIGNAL_STRENGTH_GOOD;
+ else if (dBm >= -95) bin = SIGNAL_STRENGTH_MODERATE;
+ else if (dBm >= -100) bin = SIGNAL_STRENGTH_POOR;
+ else bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
} else {
int asu = signalStrength.getGsmSignalStrength();
if (asu < 0 || asu >= 99) bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
@@ -1328,7 +1367,13 @@ public final class BatteryStatsImpl extends BatteryStats {
return mPhoneSignalStrengthsTimer[strengthBin].getTotalTimeLocked(
batteryRealtime, which);
}
-
+
+ @Override public long getPhoneSignalScanningTime(
+ long batteryRealtime, int which) {
+ return mPhoneSignalScanningTimer.getTotalTimeLocked(
+ batteryRealtime, which);
+ }
+
@Override public int getPhoneSignalStrengthCount(int dataType, int which) {
return mPhoneDataConnectionsTimer[dataType].getCountLocked(which);
}
@@ -2653,6 +2698,7 @@ public final class BatteryStatsImpl extends BatteryStats {
for (int i=0; i
400
+
+ 0
+
@@ -164,4 +168,38 @@
false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/res/res/xml/power_profile.xml b/core/res/res/xml/power_profile.xml
index 710b71ea7e75c..ce623e8d4d359 100644
--- a/core/res/res/xml/power_profile.xml
+++ b/core/res/res/xml/power_profile.xml
@@ -29,10 +29,12 @@
- 0.1
- 0.1
- 1
+
+ - 0.5
- 1
- 1
+ 0.2
0.1