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

Commit d3e803ae authored by Jean-Baptiste Queru's avatar Jean-Baptiste Queru
Browse files

Revert "Shutdown when capacity is 0% and no charging or when battery is dead"

This reverts commit fd04143a.

This break most automated tests because with this change, if the
device is fully charged, it will simply turn off the screen, regardless
if USB is connected to hsot PC or not; so for our tests, most of them
are always connected to host PC, and fully charged 99% of the time,
as soon as the screen turns off, the front-end test Activity will be
suspended.

Change-Id: I1e6590611af43812f1bac223dd31570d1d90cfc5
parent 12dbee82
Loading
Loading
Loading
Loading
+4 −16
Original line number Diff line number Diff line
@@ -136,13 +136,7 @@ class BatteryService extends Binder {

    final boolean isPowered() {
        // assume we are powered if battery state is unknown so the "stay on while plugged in" option will work.
        // Do not look at the plug status to check if we are powered.
        // Charger can be plugged but not charging because of i.e. USB suspend,
        // battery temperature reasons etc. We are powered only if battery is
        // being charged. This function fill return false if charger is
        // connected and battery is reported full.
        return (mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING ||
                mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN);
        return (mAcOnline || mUsbOnline || mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN);
    }

    final boolean isPowered(int plugTypeSet) {
@@ -154,13 +148,11 @@ class BatteryService extends Binder {
        if (plugTypeSet == 0) {
            return false;
        }

        // we are not powered when plug is connected and not charging
        int plugTypeBit = 0;
        if (mAcOnline && mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) {
        if (mAcOnline) {
            plugTypeBit |= BatteryManager.BATTERY_PLUGGED_AC;
        }
        if (mUsbOnline && mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) {
        if (mUsbOnline) {
            plugTypeBit |= BatteryManager.BATTERY_PLUGGED_USB;
        }
        return (plugTypeSet & plugTypeBit) != 0;
@@ -191,11 +183,7 @@ class BatteryService extends Binder {
    private final void shutdownIfNoPower() {
        // shut down gracefully if our battery is critically low and we are not powered.
        // wait until the system has booted before attempting to display the shutdown dialog.
        // Also shutdown if battery is reported to be 'dead' independent of
        // battery level and power supply.
        if (((mBatteryLevel == 0 && !isPowered()) ||
             mBatteryHealth == BatteryManager.BATTERY_HEALTH_DEAD) &&
            ActivityManagerNative.isSystemReady()) {
        if (mBatteryLevel == 0 && !isPowered() && ActivityManagerNative.isSystemReady()) {
            Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
            intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);