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

Commit ba95ea35 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Add extra logs to track dozing state changes

When starting AOD

Test: manual see logs
Bug: 202630143

Change-Id: Ib78145e068ea40dd727980b4845c8b2d5e250d1f
parent 9c053702
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ public class DozeLog implements Dumpable {
    }

    /**
     * Appends dozing event to the logs
     * Appends dozing event to the logs. Logs current dozing state when entering/exiting AOD.
     * @param dozing true if dozing, else false
     */
    public void traceDozing(boolean dozing) {
@@ -123,6 +123,14 @@ public class DozeLog implements Dumpable {
        mPulsing = false;
    }

    /**
     * Appends dozing event to the logs when dozing has changed in AOD.
     * @param dozing true if we're now dozing, else false
     */
    public void traceDozingChanged(boolean dozing) {
        mLogger.logDozingChanged(dozing);
    }

    /**
     * Appends dozing event to the logs
     * @param suppressed true if dozing is suppressed
+8 −0
Original line number Diff line number Diff line
@@ -66,6 +66,14 @@ class DozeLogger @Inject constructor(
        })
    }

    fun logDozingChanged(isDozing: Boolean) {
        buffer.log(TAG, INFO, {
            bool1 = isDozing
        }, {
            "Dozing changed dozing=$bool1"
        })
    }

    fun logDozingSuppressed(isDozingSuppressed: Boolean) {
        buffer.log(TAG, INFO, {
            bool1 = isDozingSuppressed
+11 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.os.Handler;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Dependency;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
@@ -92,10 +91,14 @@ public class DozeScrimController implements StateListener {
    };

    @Inject
    public DozeScrimController(DozeParameters dozeParameters, DozeLog dozeLog) {
    public DozeScrimController(
            DozeParameters dozeParameters,
            DozeLog dozeLog,
            StatusBarStateController statusBarStateController
    ) {
        mDozeParameters = dozeParameters;
        // Never expected to be destroyed
        Dependency.get(StatusBarStateController.class).addCallback(this);
        statusBarStateController.addCallback(this);
        mDozeLog = dozeLog;
    }

@@ -219,6 +222,10 @@ public class DozeScrimController implements StateListener {

    @Override
    public void onDozingChanged(boolean isDozing) {
        if (mDozing != isDozing) {
            mDozeLog.traceDozingChanged(isDozing);
        }

        setDozing(isDozing);
    }
}
 No newline at end of file
+5 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.plugins.statusbar.StatusBarStateController;

import org.junit.Before;
import org.junit.Test;
@@ -44,12 +45,15 @@ public class DozeScrimControllerTest extends SysuiTestCase {
    private DozeParameters mDozeParameters;
    @Mock
    private DozeLog mDozeLog;
    @Mock
    private StatusBarStateController mStatusBarStateController;
    private DozeScrimController mDozeScrimController;

    @Before
    public void setup() {
        MockitoAnnotations.initMocks(this);
        mDozeScrimController = new DozeScrimController(mDozeParameters, mDozeLog);
        mDozeScrimController = new DozeScrimController(mDozeParameters, mDozeLog,
                mStatusBarStateController);
        mDozeScrimController.setDozing(true);
    }