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

Commit 60b21845 authored by Emilio López's avatar Emilio López
Browse files

Fix battery icon flashing quickly on percent change

If you use the "show battery % on statusbar" option, when the percent
changes, the "traditional" battery indicator reappears for a fraction
of a second. Probably this is most noticeable on lower end phones.
This commit prevents that other icon from appearing when the battery
percent on statusbar option is enabled.

Change-Id: Icd593754c5879b84139ffbc85c30f7ecb5e258a4
parent 5885a086
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -584,6 +584,7 @@ public class StatusBarPolicy {
    };

    private boolean mShowCmBattery;
    private boolean mCmBatteryStatus;

    class SettingsObserver extends ContentObserver {
        SettingsObserver(Handler handler) {
@@ -773,8 +774,11 @@ public class StatusBarPolicy {
    private final void updateBattery(Intent intent) {
        final int id = intent.getIntExtra("icon-small", 0);
        int level = intent.getIntExtra("level", 0);
        if(!mShowCmBattery || mCmBatteryStatus != mShowCmBattery) {
                mService.setIcon("battery", id, level);
                mService.setIconVisibility("battery", !mShowCmBattery);
                mCmBatteryStatus = mShowCmBattery;
        }

        boolean plugged = intent.getIntExtra("plugged", 0) != 0;
        level = intent.getIntExtra("level", -1);
@@ -1555,6 +1559,7 @@ public class StatusBarPolicy {

        mShowCmBattery = (Settings.System.getInt(resolver,
                Settings.System.STATUS_BAR_CM_BATTERY, 0) == 1);
        mCmBatteryStatus = !mShowCmBattery;
        mService.setIconVisibility("battery", !mShowCmBattery);
    }
}