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

Commit ab65a507 authored by Rupesh Bansal's avatar Rupesh Bansal
Browse files

Making ScreenOnUnblocked and ScreenOffUnblocked public

This is needed because we soon plan to introduce the concept of
DisplayStateNotifier, which will need to interact with this class, and
hence would be neater to move it outside of DisplayPowerController
Bug: 259411586
Test: atest com.android.server.display

Change-Id: Ib353f051fcb76111688ff8ca0e65846a98c21041
parent 613dc260
Loading
Loading
Loading
Loading
+8 −22
Original line number Diff line number Diff line
@@ -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) {
+1 −2
Original line number Diff line number Diff line
@@ -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;
+1 −3
Original line number Diff line number Diff line
@@ -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;