Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3c74f34 authored by Brian Muramatsu's avatar Brian Muramatsu
Browse files

Make battery shutdown temperature configurable

Bug 7079455

Change-Id: I448f21231bf0548ef975f99482576acb24a1a70e
parent 34a75df6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -471,6 +471,9 @@
         Also, the battery stats are flushed to disk when we hit this level.  -->
    <integer name="config_criticalBatteryWarningLevel">4</integer>

    <!-- Shutdown if the battery temperature exceeds (this value * 0.1) Celsius. -->
    <integer name="config_shutdownBatteryTemperature">680</integer>

    <!-- Display low battery warning when battery level dips to this value -->
    <!-- Display low battery warning when battery level dips to this value -->
    <integer name="config_lowBatteryWarningLevel">15</integer>
+1 −0
Original line number Diff line number Diff line
@@ -1544,6 +1544,7 @@
  <java-symbol type="integer" name="config_screenBrightnessSettingMaximum" />
  <java-symbol type="integer" name="config_screenBrightnessSettingDefault" />
  <java-symbol type="integer" name="config_screenBrightnessDim" />
  <java-symbol type="integer" name="config_shutdownBatteryTemperature" />
  <java-symbol type="integer" name="config_virtualKeyQuietTimeMillis" />
  <java-symbol type="layout" name="am_compat_mode_dialog" />
  <java-symbol type="layout" name="launch_warning" />
+10 −5
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ public class BatteryService extends Binder {

    private int mLowBatteryWarningLevel;
    private int mLowBatteryCloseWarningLevel;
    private int mShutdownBatteryTemperature;

    private int mPlugType;
    private int mLastPlugType = -1; // Extra state so we can detect first run
@@ -138,6 +139,8 @@ public class BatteryService extends Binder {
                com.android.internal.R.integer.config_lowBatteryWarningLevel);
        mLowBatteryCloseWarningLevel = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);
        mShutdownBatteryTemperature = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_shutdownBatteryTemperature);

        mPowerSupplyObserver.startObserving("SUBSYSTEM=power_supply");

@@ -228,9 +231,11 @@ public class BatteryService extends Binder {
    }

    private final void shutdownIfOverTemp() {
        // shut down gracefully if temperature is too high (> 68.0C)
        // wait until the system has booted before attempting to display the shutdown dialog.
        if (mBatteryTemperature > 680 && ActivityManagerNative.isSystemReady()) {
        // shut down gracefully if temperature is too high (> 68.0C by default)
        // wait until the system has booted before attempting to display the
        // shutdown dialog.
        if (mBatteryTemperature > mShutdownBatteryTemperature
                && ActivityManagerNative.isSystemReady()) {
            Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
            intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);