Merge "Making ScreenOnUnblocked and ScreenOffUnblocked public"

This commit is contained in:
Rupesh Bansal
2023-01-03 07:57:38 +00:00
committed by Android (Google) Code Review
3 changed files with 10 additions and 27 deletions

View File

@@ -267,12 +267,10 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
// Must only be accessed on the handler thread.
private DisplayPowerState mPowerState;
// The currently active screen on unblocker. This field is non-null whenever
// we are waiting for a callback to release it and unblock the screen.
private ScreenOnUnblocker mPendingScreenOnUnblocker;
private ScreenOffUnblocker mPendingScreenOffUnblocker;
private WindowManagerPolicy.ScreenOnListener mPendingScreenOnUnblocker;
private WindowManagerPolicy.ScreenOffListener mPendingScreenOffUnblocker;
// True if we were in the process of turning off the screen.
// This allows us to recover more gracefully from situations where we abort
@@ -1758,7 +1756,9 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
private void blockScreenOn() {
if (mPendingScreenOnUnblocker == null) {
Trace.asyncTraceBegin(Trace.TRACE_TAG_POWER, SCREEN_ON_BLOCKED_TRACE_NAME, 0);
mPendingScreenOnUnblocker = new ScreenOnUnblocker();
mPendingScreenOnUnblocker = () -> {
mHandler.obtainMessage(MSG_SCREEN_ON_UNBLOCKED, this).sendToTarget();
};
mScreenOnBlockStartRealTime = SystemClock.elapsedRealtime();
Slog.i(mTag, "Blocking screen on until initial contents have been drawn.");
}
@@ -1776,7 +1776,9 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
private void blockScreenOff() {
if (mPendingScreenOffUnblocker == null) {
Trace.asyncTraceBegin(Trace.TRACE_TAG_POWER, SCREEN_OFF_BLOCKED_TRACE_NAME, 0);
mPendingScreenOffUnblocker = new ScreenOffUnblocker();
mPendingScreenOffUnblocker = () -> {
mHandler.obtainMessage(MSG_SCREEN_ON_UNBLOCKED, this).sendToTarget();
};
mScreenOffBlockStartRealTime = SystemClock.elapsedRealtime();
Slog.i(mTag, "Blocking screen off");
}
@@ -2560,22 +2562,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
}
}
private final class ScreenOnUnblocker implements WindowManagerPolicy.ScreenOnListener {
@Override
public void onScreenOn() {
Message msg = mHandler.obtainMessage(MSG_SCREEN_ON_UNBLOCKED, this);
mHandler.sendMessage(msg);
}
}
private final class ScreenOffUnblocker implements WindowManagerPolicy.ScreenOffListener {
@Override
public void onScreenOff() {
Message msg = mHandler.obtainMessage(MSG_SCREEN_OFF_UNBLOCKED, this);
mHandler.sendMessage(msg);
}
}
@Override
public void setAutoBrightnessLoggingEnabled(boolean enabled) {
if (mAutomaticBrightnessController != null) {

View File

@@ -16,12 +16,11 @@
package com.android.server.display;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;

View File

@@ -16,13 +16,11 @@
package com.android.server.display;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;