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

Commit 7e19e149 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge "[SB][Battery] Log when power save changes come in." into main

parents 92b36418 032b27b1
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import android.os.Handler;
import android.os.PowerManager;
import android.os.PowerSaveState;
import android.util.IndentingPrintWriter;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
@@ -77,8 +76,6 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC

    private static final String ACTION_LEVEL_TEST = "com.android.systemui.BATTERY_LEVEL_TEST";

    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);

    private final EnhancedEstimates mEstimates;
    protected final BroadcastDispatcher mBroadcastDispatcher;
    protected final ArrayList<BatteryController.BatteryStateChangeCallback>
@@ -449,7 +446,6 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
        PowerSaveState state = mPowerManager.getPowerSaveState(PowerManager.ServiceType.AOD);
        mAodPowerSave = state.batterySaverEnabled;

        if (DEBUG) Log.d(TAG, "Power save is " + (mPowerSave ? "on" : "off"));
        firePowerSaveChanged();
    }

@@ -475,6 +471,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
    }

    private void firePowerSaveChanged() {
        mLogger.logPowerSaveChangedCallback(mPowerSave);
        dispatchSafeChange((callback) -> callback.onPowerSaveChanged(mPowerSave));
    }

+9 −0
Original line number Diff line number Diff line
@@ -105,6 +105,15 @@ constructor(@BatteryControllerLog private val logBuffer: LogBuffer) {
        )
    }

    fun logPowerSaveChangedCallback(isPowerSave: Boolean) {
        logBuffer.log(
            TAG,
            LogLevel.DEBUG,
            { bool1 = isPowerSave },
            { "Sending onPowerSaveChanged callback with powerSave=$bool1" }
        )
    }

    private fun Int.report(): String =
        if (this == DEFAULT) {
            "(missing)"