diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-05-21 15:01:03 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-05-22 16:43:17 -0700 |
commit | 293251318168ad2dbfeb3d18176936fe2cc16325 (patch) | |
tree | 3560e1823cc8308ee089b7ec8f0dc6c60a32ae3e | |
parent | 42b30e1b832df5bbf109db2f4f864f8ba4cfd44a (diff) | |
download | frameworks_base-293251318168ad2dbfeb3d18176936fe2cc16325.zip frameworks_base-293251318168ad2dbfeb3d18176936fe2cc16325.tar.gz frameworks_base-293251318168ad2dbfeb3d18176936fe2cc16325.tar.bz2 |
(DO NOT MERGE) Battery monitoring fixes:
- Improve monitoring of level changes to not be confused
when it goes up while draining or down while charging.
- Put back in connectivity service code to tell battery
stats about the interfaces.
- Turn back on reporting of mobile radio active state
from the RIL.
- Fix bug in marshalling/unmarshalling that would cause
the UI to show bad data.
Change-Id: I733ef52702894cca81a0813eccdfc1023e546fce
3 files changed, 21 insertions, 12 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 8428f66..24e55e4 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -328,11 +328,13 @@ public final class BatteryStatsImpl extends BatteryStats { int mLastDischargeStepLevel; long mLastDischargeStepTime; + int mMinDischargeStepLevel; int mNumDischargeStepDurations; final long[] mDischargeStepDurations = new long[MAX_LEVEL_STEPS]; int mLastChargeStepLevel; long mLastChargeStepTime; + int mMaxChargeStepLevel; int mNumChargeStepDurations; final long[] mChargeStepDurations = new long[MAX_LEVEL_STEPS]; @@ -887,6 +889,7 @@ public final class BatteryStatsImpl extends BatteryStats { mLastTime = 0; mUnpluggedTime = in.readLong(); timeBase.add(this); + if (DEBUG) Log.i(TAG, "**** READ TIMER #" + mType + ": mTotalTime=" + mTotalTime); } Timer(int type, TimeBase timeBase) { @@ -917,6 +920,8 @@ public final class BatteryStatsImpl extends BatteryStats { } public void writeToParcel(Parcel out, long elapsedRealtimeUs) { + if (DEBUG) Log.i(TAG, "**** WRITING TIMER #" + mType + ": mTotalTime=" + + computeRunTimeLocked(mTimeBase.getRealtime(elapsedRealtimeUs))); out.writeInt(mCount); out.writeInt(mLoadedCount); out.writeInt(mUnpluggedCount); @@ -5550,6 +5555,7 @@ 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); } + mInteractiveTimer = new StopwatchTimer(null, -9, null, mOnBatteryTimeBase); mLowPowerModeEnabledTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase); mPhoneOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase); for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { @@ -5581,7 +5587,6 @@ public final class BatteryStatsImpl extends BatteryStats { } mAudioOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase); mVideoOnTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase); - mInteractiveTimer = new StopwatchTimer(null, -9, null, mOnBatteryTimeBase); mOnBattery = mOnBatteryInternal = false; long uptime = SystemClock.uptimeMillis() * 1000; long realtime = SystemClock.elapsedRealtime() * 1000; @@ -5958,6 +5963,7 @@ public final class BatteryStatsImpl extends BatteryStats { mNumDischargeStepDurations = 0; } mLastDischargeStepLevel = level; + mMinDischargeStepLevel = level; mLastDischargeStepTime = -1; pullPendingStateUpdatesLocked(); mHistoryCur.batteryLevel = (byte)level; @@ -5996,6 +6002,7 @@ public final class BatteryStatsImpl extends BatteryStats { updateTimeBasesLocked(false, !screenOn, uptime, realtime); mNumChargeStepDurations = 0; mLastChargeStepLevel = level; + mMaxChargeStepLevel = level; mLastChargeStepTime = -1; } if (doWrite || (mLastWriteTime + (60 * 1000)) < mSecRealtime) { @@ -6117,19 +6124,21 @@ public final class BatteryStatsImpl extends BatteryStats { addHistoryRecordLocked(elapsedRealtime, uptime); } if (onBattery) { - if (mLastDischargeStepLevel != level) { + if (mLastDischargeStepLevel != level && mMinDischargeStepLevel > level) { mNumDischargeStepDurations = addLevelSteps(mDischargeStepDurations, mNumDischargeStepDurations, mLastDischargeStepTime, mLastDischargeStepLevel - level, elapsedRealtime); mLastDischargeStepLevel = level; + mMinDischargeStepLevel = level; mLastDischargeStepTime = elapsedRealtime; } } else { - if (mLastChargeStepLevel != level) { + if (mLastChargeStepLevel != level && mMaxChargeStepLevel < level) { mNumChargeStepDurations = addLevelSteps(mChargeStepDurations, mNumChargeStepDurations, mLastChargeStepTime, level - mLastChargeStepLevel, elapsedRealtime); mLastChargeStepLevel = level; + mMaxChargeStepLevel = level; mLastChargeStepTime = elapsedRealtime; } } @@ -7495,6 +7504,8 @@ public final class BatteryStatsImpl extends BatteryStats { mScreenBrightnessTimer[i] = new StopwatchTimer(null, -100-i, null, mOnBatteryTimeBase, in); } + mInteractive = false; + mInteractiveTimer = new StopwatchTimer(null, -9, null, mOnBatteryTimeBase, in); mPhoneOn = false; mLowPowerModeEnabledTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase, in); mPhoneOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase, in); @@ -7536,8 +7547,6 @@ public final class BatteryStatsImpl extends BatteryStats { mAudioOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase); mVideoOn = false; mVideoOnTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase); - mInteractive = false; - mInteractiveTimer = new StopwatchTimer(null, -9, null, mOnBatteryTimeBase, in); mDischargeUnplugLevel = in.readInt(); mDischargePlugLevel = in.readInt(); mDischargeCurrentLevel = in.readInt(); diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 0ad5ce2..7ecf248 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -5750,10 +5750,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { // updateNetworkSettings(); } // notify battery stats service about this network -// try { - // TODO - //BatteryStatsService.getService().noteNetworkInterfaceType(iface, netType); -// } catch (RemoteException e) { } + try { + BatteryStatsService.getService().noteNetworkInterfaceType( + newNetwork.linkProperties.getInterfaceName(), + newNetwork.networkInfo.getType()); + } catch (RemoteException e) { } notifyNetworkCallbacks(newNetwork, ConnectivityManager.CALLBACK_AVAILABLE); } else { if (DBG && newNetwork.networkRequests.size() != 0) { diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index cf91782..137387e 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -240,9 +240,8 @@ public class NetworkManagementService extends INetworkManagementService.Stub mPhoneStateListener = new PhoneStateListener(mDaemonHandler.getLooper()) { public void onDataConnectionRealTimeInfoChanged( DataConnectionRealTimeInfo dcRtInfo) { - // Disabled for now, until we are getting good data. - //notifyInterfaceClassActivity(ConnectivityManager.TYPE_MOBILE, - // dcRtInfo.getDcPowerState(), dcRtInfo.getTime(), true); + notifyInterfaceClassActivity(ConnectivityManager.TYPE_MOBILE, + dcRtInfo.getDcPowerState(), dcRtInfo.getTime(), true); } }; |