Merge "Add extra logs to track dozing state changes" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-11-08 23:19:55 +00:00
committed by Android (Google) Code Review
4 changed files with 33 additions and 6 deletions

View File

@@ -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 * @param dozing true if dozing, else false
*/ */
public void traceDozing(boolean dozing) { public void traceDozing(boolean dozing) {
@@ -123,6 +123,14 @@ public class DozeLog implements Dumpable {
mPulsing = false; 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 * Appends dozing event to the logs
* @param suppressed true if dozing is suppressed * @param suppressed true if dozing is suppressed

View File

@@ -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) { fun logDozingSuppressed(isDozingSuppressed: Boolean) {
buffer.log(TAG, INFO, { buffer.log(TAG, INFO, {
bool1 = isDozingSuppressed bool1 = isDozingSuppressed

View File

@@ -21,7 +21,6 @@ import android.os.Handler;
import android.util.Log; import android.util.Log;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Dependency;
import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.doze.DozeHost; import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog; import com.android.systemui.doze.DozeLog;
@@ -92,10 +91,14 @@ public class DozeScrimController implements StateListener {
}; };
@Inject @Inject
public DozeScrimController(DozeParameters dozeParameters, DozeLog dozeLog) { public DozeScrimController(
DozeParameters dozeParameters,
DozeLog dozeLog,
StatusBarStateController statusBarStateController
) {
mDozeParameters = dozeParameters; mDozeParameters = dozeParameters;
//Never expected to be destroyed // Never expected to be destroyed
Dependency.get(StatusBarStateController.class).addCallback(this); statusBarStateController.addCallback(this);
mDozeLog = dozeLog; mDozeLog = dozeLog;
} }
@@ -219,6 +222,10 @@ public class DozeScrimController implements StateListener {
@Override @Override
public void onDozingChanged(boolean isDozing) { public void onDozingChanged(boolean isDozing) {
if (mDozing != isDozing) {
mDozeLog.traceDozingChanged(isDozing);
}
setDozing(isDozing); setDozing(isDozing);
} }
} }

View File

@@ -28,6 +28,7 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestCase;
import com.android.systemui.doze.DozeHost; import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog; import com.android.systemui.doze.DozeLog;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -44,12 +45,15 @@ public class DozeScrimControllerTest extends SysuiTestCase {
private DozeParameters mDozeParameters; private DozeParameters mDozeParameters;
@Mock @Mock
private DozeLog mDozeLog; private DozeLog mDozeLog;
@Mock
private StatusBarStateController mStatusBarStateController;
private DozeScrimController mDozeScrimController; private DozeScrimController mDozeScrimController;
@Before @Before
public void setup() { public void setup() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mDozeScrimController = new DozeScrimController(mDozeParameters, mDozeLog); mDozeScrimController = new DozeScrimController(mDozeParameters, mDozeLog,
mStatusBarStateController);
mDozeScrimController.setDozing(true); mDozeScrimController.setDozing(true);
} }