Merge changes from topic "no-battery"
* changes: BatteryService: don't set battery low or critical states if no battery BatteryStats: Don't collect battery stats if no battery
This commit is contained in:
@@ -11228,7 +11228,9 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
reportChangesToStatsLog(mHaveBatteryLevel ? mHistoryCur : null,
|
||||
status, plugType, level, temp);
|
||||
|
||||
final boolean onBattery = plugType == BATTERY_PLUGGED_NONE;
|
||||
final boolean onBattery =
|
||||
plugType == BATTERY_PLUGGED_NONE &&
|
||||
status != BatteryManager.BATTERY_STATUS_UNKNOWN;
|
||||
final long uptime = mClocks.uptimeMillis();
|
||||
final long elapsedRealtime = mClocks.elapsedRealtime();
|
||||
if (!mHaveBatteryLevel) {
|
||||
@@ -11262,7 +11264,8 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
mRecordingHistory = true;
|
||||
startRecordingHistory(elapsedRealtime, uptime, true);
|
||||
}
|
||||
} else if (level < 96) {
|
||||
} else if (level < 96 &&
|
||||
status != BatteryManager.BATTERY_STATUS_UNKNOWN) {
|
||||
if (!mRecordingHistory) {
|
||||
mRecordingHistory = true;
|
||||
startRecordingHistory(elapsedRealtime, uptime, true);
|
||||
@@ -11400,9 +11403,12 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
addHistoryRecordLocked(elapsedRealtime, uptime);
|
||||
}
|
||||
}
|
||||
if (!onBattery && status == BatteryManager.BATTERY_STATUS_FULL) {
|
||||
// We don't record history while we are plugged in and fully charged.
|
||||
// The next time we are unplugged, history will be cleared.
|
||||
if (!onBattery &&
|
||||
(status == BatteryManager.BATTERY_STATUS_FULL ||
|
||||
status == BatteryManager.BATTERY_STATUS_UNKNOWN)) {
|
||||
// We don't record history while we are plugged in and fully charged
|
||||
// (or when battery is not present). The next time we are
|
||||
// unplugged, history will be cleared.
|
||||
mRecordingHistory = DEBUG;
|
||||
}
|
||||
|
||||
|
||||
@@ -421,7 +421,9 @@ public final class BatteryService extends SystemService {
|
||||
boolean logOutlier = false;
|
||||
long dischargeDuration = 0;
|
||||
|
||||
mBatteryLevelCritical = (mHealthInfo.batteryLevel <= mCriticalBatteryLevel);
|
||||
mBatteryLevelCritical =
|
||||
mHealthInfo.batteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN
|
||||
&& mHealthInfo.batteryLevel <= mCriticalBatteryLevel;
|
||||
if (mHealthInfo.chargerAcOnline) {
|
||||
mPlugType = BatteryManager.BATTERY_PLUGGED_AC;
|
||||
} else if (mHealthInfo.chargerUsbOnline) {
|
||||
@@ -509,6 +511,8 @@ public final class BatteryService extends SystemService {
|
||||
if (!mBatteryLevelLow) {
|
||||
// Should we now switch in to low battery mode?
|
||||
if (mPlugType == BATTERY_PLUGGED_NONE
|
||||
&& mHealthInfo.batteryStatus !=
|
||||
BatteryManager.BATTERY_STATUS_UNKNOWN
|
||||
&& mHealthInfo.batteryLevel <= mLowBatteryWarningLevel) {
|
||||
mBatteryLevelLow = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user