Loading core/java/android/os/BatteryStats.java +4 −1 Original line number Diff line number Diff line Loading @@ -1537,6 +1537,7 @@ public abstract class BatteryStats implements Parcelable { public static final int STATE2_BLUETOOTH_ON_FLAG = 1<<22; public static final int STATE2_CAMERA_FLAG = 1<<21; public static final int STATE2_BLUETOOTH_SCAN_FLAG = 1 << 20; public static final int STATE2_CELLULAR_HIGH_TX_POWER_FLAG = 1 << 19; public static final int MOST_INTERESTING_STATES2 = STATE2_POWER_SAVE_FLAG | STATE2_WIFI_ON_FLAG | STATE2_DEVICE_IDLE_MASK Loading Loading @@ -2353,9 +2354,11 @@ public abstract class BatteryStats implements Parcelable { WIFI_SUPPL_STATE_NAMES, WIFI_SUPPL_STATE_SHORT_NAMES), new BitDescription(HistoryItem.STATE2_CAMERA_FLAG, "camera", "ca"), new BitDescription(HistoryItem.STATE2_BLUETOOTH_SCAN_FLAG, "ble_scan", "bles"), new BitDescription(HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG, "cellular_high_tx_power", "Chtp"), new BitDescription(HistoryItem.STATE2_GPS_SIGNAL_QUALITY_MASK, HistoryItem.STATE2_GPS_SIGNAL_QUALITY_SHIFT, "gps_signal_quality", "Gss", new String[] { "poor", "good"}, new String[] { "poor", "good"}), new String[] { "poor", "good"}, new String[] { "poor", "good"}) }; public static final String[] HISTORY_EVENT_NAMES = new String[] { Loading core/java/com/android/internal/os/BatteryStatsImpl.java +45 −0 Original line number Diff line number Diff line Loading @@ -761,6 +761,8 @@ public class BatteryStatsImpl extends BatteryStats { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) protected StopwatchTimer mBluetoothScanTimer; boolean mIsCellularTxPowerHigh = false; int mMobileRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; long mMobileRadioActiveStartTime; StopwatchTimer mMobileRadioActiveTimer; Loading Loading @@ -11212,6 +11214,9 @@ public class BatteryStatsImpl extends BatteryStats { Slog.d(TAG, "Updating mobile radio stats with " + activityInfo); } // Add modem tx power to history. addModemTxPowerToHistory(activityInfo); // Grab a separate lock to acquire the network stats, which may do I/O. NetworkStats delta = null; synchronized (mModemNetworkLock) { Loading Loading @@ -11385,6 +11390,44 @@ public class BatteryStatsImpl extends BatteryStats { private BluetoothActivityEnergyInfo mLastBluetoothActivityEnergyInfo = new BluetoothActivityEnergyInfo(0, 0, 0, 0, 0, 0); /** * Add modem tx power to history * Device is said to be in high cellular transmit power when it has spent most of the transmit * time at the highest power level. * @param activityInfo */ private void addModemTxPowerToHistory(final ModemActivityInfo activityInfo) { if (activityInfo == null) { return; } int[] txTimeMs = activityInfo.getTxTimeMillis(); if (txTimeMs == null || txTimeMs.length != ModemActivityInfo.TX_POWER_LEVELS) { return; } final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); int levelMaxTimeSpent = 0; for (int i = 1; i < txTimeMs.length; i++) { if (txTimeMs[i] > txTimeMs[levelMaxTimeSpent]) { levelMaxTimeSpent = i; } } if (levelMaxTimeSpent == ModemActivityInfo.TX_POWER_LEVELS - 1) { if (!mIsCellularTxPowerHigh) { mHistoryCur.states2 |= HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG; addHistoryRecordLocked(elapsedRealtime, uptime); mIsCellularTxPowerHigh = true; } return; } if (mIsCellularTxPowerHigh) { mHistoryCur.states2 &= ~HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG; addHistoryRecordLocked(elapsedRealtime, uptime); mIsCellularTxPowerHigh = false; } return; } /** * Distribute Bluetooth energy info and network traffic to apps. * @param info The energy information from the bluetooth controller. Loading Loading @@ -13538,6 +13581,7 @@ public class BatteryStatsImpl extends BatteryStats { mCameraOnTimer.readSummaryFromParcelLocked(in); mBluetoothScanNesting = 0; mBluetoothScanTimer.readSummaryFromParcelLocked(in); mIsCellularTxPowerHigh = false; int NRPMS = in.readInt(); if (NRPMS > 10000) { Loading Loading @@ -14474,6 +14518,7 @@ public class BatteryStatsImpl extends BatteryStats { mCameraOnTimer = new StopwatchTimer(mClocks, null, -13, null, mOnBatteryTimeBase, in); mBluetoothScanNesting = 0; mBluetoothScanTimer = new StopwatchTimer(mClocks, null, -14, null, mOnBatteryTimeBase, in); mIsCellularTxPowerHigh = false; mDischargeUnplugLevel = in.readInt(); mDischargePlugLevel = in.readInt(); mDischargeCurrentLevel = in.readInt(); Loading
core/java/android/os/BatteryStats.java +4 −1 Original line number Diff line number Diff line Loading @@ -1537,6 +1537,7 @@ public abstract class BatteryStats implements Parcelable { public static final int STATE2_BLUETOOTH_ON_FLAG = 1<<22; public static final int STATE2_CAMERA_FLAG = 1<<21; public static final int STATE2_BLUETOOTH_SCAN_FLAG = 1 << 20; public static final int STATE2_CELLULAR_HIGH_TX_POWER_FLAG = 1 << 19; public static final int MOST_INTERESTING_STATES2 = STATE2_POWER_SAVE_FLAG | STATE2_WIFI_ON_FLAG | STATE2_DEVICE_IDLE_MASK Loading Loading @@ -2353,9 +2354,11 @@ public abstract class BatteryStats implements Parcelable { WIFI_SUPPL_STATE_NAMES, WIFI_SUPPL_STATE_SHORT_NAMES), new BitDescription(HistoryItem.STATE2_CAMERA_FLAG, "camera", "ca"), new BitDescription(HistoryItem.STATE2_BLUETOOTH_SCAN_FLAG, "ble_scan", "bles"), new BitDescription(HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG, "cellular_high_tx_power", "Chtp"), new BitDescription(HistoryItem.STATE2_GPS_SIGNAL_QUALITY_MASK, HistoryItem.STATE2_GPS_SIGNAL_QUALITY_SHIFT, "gps_signal_quality", "Gss", new String[] { "poor", "good"}, new String[] { "poor", "good"}), new String[] { "poor", "good"}, new String[] { "poor", "good"}) }; public static final String[] HISTORY_EVENT_NAMES = new String[] { Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +45 −0 Original line number Diff line number Diff line Loading @@ -761,6 +761,8 @@ public class BatteryStatsImpl extends BatteryStats { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) protected StopwatchTimer mBluetoothScanTimer; boolean mIsCellularTxPowerHigh = false; int mMobileRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; long mMobileRadioActiveStartTime; StopwatchTimer mMobileRadioActiveTimer; Loading Loading @@ -11212,6 +11214,9 @@ public class BatteryStatsImpl extends BatteryStats { Slog.d(TAG, "Updating mobile radio stats with " + activityInfo); } // Add modem tx power to history. addModemTxPowerToHistory(activityInfo); // Grab a separate lock to acquire the network stats, which may do I/O. NetworkStats delta = null; synchronized (mModemNetworkLock) { Loading Loading @@ -11385,6 +11390,44 @@ public class BatteryStatsImpl extends BatteryStats { private BluetoothActivityEnergyInfo mLastBluetoothActivityEnergyInfo = new BluetoothActivityEnergyInfo(0, 0, 0, 0, 0, 0); /** * Add modem tx power to history * Device is said to be in high cellular transmit power when it has spent most of the transmit * time at the highest power level. * @param activityInfo */ private void addModemTxPowerToHistory(final ModemActivityInfo activityInfo) { if (activityInfo == null) { return; } int[] txTimeMs = activityInfo.getTxTimeMillis(); if (txTimeMs == null || txTimeMs.length != ModemActivityInfo.TX_POWER_LEVELS) { return; } final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); int levelMaxTimeSpent = 0; for (int i = 1; i < txTimeMs.length; i++) { if (txTimeMs[i] > txTimeMs[levelMaxTimeSpent]) { levelMaxTimeSpent = i; } } if (levelMaxTimeSpent == ModemActivityInfo.TX_POWER_LEVELS - 1) { if (!mIsCellularTxPowerHigh) { mHistoryCur.states2 |= HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG; addHistoryRecordLocked(elapsedRealtime, uptime); mIsCellularTxPowerHigh = true; } return; } if (mIsCellularTxPowerHigh) { mHistoryCur.states2 &= ~HistoryItem.STATE2_CELLULAR_HIGH_TX_POWER_FLAG; addHistoryRecordLocked(elapsedRealtime, uptime); mIsCellularTxPowerHigh = false; } return; } /** * Distribute Bluetooth energy info and network traffic to apps. * @param info The energy information from the bluetooth controller. Loading Loading @@ -13538,6 +13581,7 @@ public class BatteryStatsImpl extends BatteryStats { mCameraOnTimer.readSummaryFromParcelLocked(in); mBluetoothScanNesting = 0; mBluetoothScanTimer.readSummaryFromParcelLocked(in); mIsCellularTxPowerHigh = false; int NRPMS = in.readInt(); if (NRPMS > 10000) { Loading Loading @@ -14474,6 +14518,7 @@ public class BatteryStatsImpl extends BatteryStats { mCameraOnTimer = new StopwatchTimer(mClocks, null, -13, null, mOnBatteryTimeBase, in); mBluetoothScanNesting = 0; mBluetoothScanTimer = new StopwatchTimer(mClocks, null, -14, null, mOnBatteryTimeBase, in); mIsCellularTxPowerHigh = false; mDischargeUnplugLevel = in.readInt(); mDischargePlugLevel = in.readInt(); mDischargeCurrentLevel = in.readInt();