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

Commit 3fcdd471 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Fix AOD battery updates

It's not accurate to assume that events are only interesting when
the keyguard is visible. The user might be unlocked watching a
video or executing any other task and will miss a battery update.

Now dumping KeyguardIndicationController internals, to make it
easier to debug future issues.

Change-Id: I20efa011e20e92713a19fac32acea40604133f6d
Fixes: 72211244
Test: adb bugreport
Test: Play video, look at battery on AOD
Test: Lock phone, wait for battery update
parent 18fb2fe4
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -991,6 +991,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                    maxChargingWattage > fastThreshold ? CHARGING_FAST :
                    CHARGING_REGULAR;
        }

        @Override
        public String toString() {
            return "BatteryStatus{status=" + status + ",level=" + level + ",plugged=" + plugged
                    + ",health=" + health + ",maxChargingWattage=" + maxChargingWattage + "}";
        }
    }

    public class StrongAuthTracker extends LockPatternUtils.StrongAuthTracker {
@@ -1624,18 +1630,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            return true;
        }

        // change in battery level while plugged in
        if (nowPluggedIn && old.level != current.level) {
            return true;
        }

        // change in battery level while keyguard visible
        if (mKeyguardIsVisible && old.level != current.level) {
            return true;
        }

        // change where battery needs charging
        if (!nowPluggedIn && current.isBatteryLow() && current.level != old.level) {
        // change in battery level
        if (old.level != current.level) {
            return true;
        }

+19 −4
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.util.wakelock.SettableWakeLock;
import com.android.systemui.util.wakelock.WakeLock;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.text.NumberFormat;

/**
@@ -116,11 +118,9 @@ public class KeyguardIndicationController {
                WakeLock wakeLock) {
        mContext = context;
        mIndicationArea = indicationArea;
        mTextView = (KeyguardIndicationTextView) indicationArea.findViewById(
                R.id.keyguard_indication_text);
        mTextView = indicationArea.findViewById(R.id.keyguard_indication_text);
        mInitialTextColor = mTextView != null ? mTextView.getCurrentTextColor() : Color.WHITE;
        mDisclosure = (KeyguardIndicationTextView) indicationArea.findViewById(
                R.id.keyguard_indication_enterprise_disclosure);
        mDisclosure = indicationArea.findViewById(R.id.keyguard_indication_enterprise_disclosure);
        mLockIcon = lockIcon;
        mWakeLock = new SettableWakeLock(wakeLock);

@@ -416,6 +416,21 @@ public class KeyguardIndicationController {
        updateDisclosure();
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("KeyguardIndicationController:");
        pw.println("  mTransientTextColor: " + Integer.toHexString(mTransientTextColor));
        pw.println("  mInitialTextColor: " + Integer.toHexString(mInitialTextColor));
        pw.println("  mPowerPluggedIn: " + mPowerPluggedIn);
        pw.println("  mPowerCharged: " + mPowerCharged);
        pw.println("  mChargingSpeed: " + mChargingSpeed);
        pw.println("  mChargingWattage: " + mChargingWattage);
        pw.println("  mMessageToShowOnScreenOn: " + mMessageToShowOnScreenOn);
        pw.println("  mDozing: " + mDozing);
        pw.println("  mBatteryLevel: " + mBatteryLevel);
        pw.println("  mTextView.getText(): " + (mTextView == null ? null : mTextView.getText()));
        pw.println("  computePowerIndication(): " + computePowerIndication());
    }

    protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback {
        public static final int HIDE_DELAY_MS = 5000;
        private int mLastSuccessiveErrorMessage = -1;
+4 −0
Original line number Diff line number Diff line
@@ -2663,6 +2663,10 @@ public class StatusBar extends SystemUI implements DemoMode,
            mFingerprintUnlockController.dump(pw);
        }

        if (mKeyguardIndicationController != null) {
            mKeyguardIndicationController.dump(fd, pw, args);
        }

        if (mScrimController != null) {
            mScrimController.dump(fd, pw, args);
        }
+4 −4

File changed.

Contains only whitespace changes.