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

Commit 67f77a34 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Remove black frame when pulsing"

parents 4f07fa4e 12663d30
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -64,7 +64,7 @@ public class DozeFactory {
                createDozeTriggers(context, sensorManager, host, alarmManager, config, params,
                createDozeTriggers(context, sensorManager, host, alarmManager, config, params,
                        handler, wakeLock, machine),
                        handler, wakeLock, machine),
                createDozeUi(context, host, wakeLock, machine, handler, alarmManager, params),
                createDozeUi(context, host, wakeLock, machine, handler, alarmManager, params),
                new DozeScreenState(wrappedService, handler),
                new DozeScreenState(wrappedService, handler, params),
                createDozeScreenBrightness(context, wrappedService, sensorManager, host, handler),
                createDozeScreenBrightness(context, wrappedService, sensorManager, host, handler),
                new DozeWallpaperState(context)
                new DozeWallpaperState(context)
        });
        });
+5 −2
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.Display;


import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.internal.util.Preconditions;
import com.android.internal.util.Preconditions;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.Assert;
import com.android.systemui.util.Assert;
import com.android.systemui.util.wakelock.WakeLock;
import com.android.systemui.util.wakelock.WakeLock;


@@ -87,12 +88,11 @@ public class DozeMachine {
            }
            }
        }
        }


        int screenState() {
        int screenState(DozeParameters parameters) {
            switch (this) {
            switch (this) {
                case UNINITIALIZED:
                case UNINITIALIZED:
                case INITIALIZED:
                case INITIALIZED:
                case DOZE:
                case DOZE:
                case DOZE_REQUEST_PULSE:
                case DOZE_AOD_PAUSED:
                case DOZE_AOD_PAUSED:
                    return Display.STATE_OFF;
                    return Display.STATE_OFF;
                case DOZE_PULSING:
                case DOZE_PULSING:
@@ -100,6 +100,9 @@ public class DozeMachine {
                case DOZE_AOD:
                case DOZE_AOD:
                case DOZE_AOD_PAUSING:
                case DOZE_AOD_PAUSING:
                    return Display.STATE_DOZE_SUSPEND;
                    return Display.STATE_DOZE_SUSPEND;
                case DOZE_REQUEST_PULSE:
                    return parameters.getDisplayNeedsBlanking() ? Display.STATE_OFF
                            : Display.STATE_ON;
                default:
                default:
                    return Display.STATE_UNKNOWN;
                    return Display.STATE_UNKNOWN;
            }
            }
+7 −2
Original line number Original line Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.systemui.doze;
import android.os.Handler;
import android.os.Handler;
import android.view.Display;
import android.view.Display;


import com.android.systemui.statusbar.phone.DozeParameters;

/**
/**
 * Controls the screen when dozing.
 * Controls the screen when dozing.
 */
 */
@@ -26,17 +28,20 @@ public class DozeScreenState implements DozeMachine.Part {
    private final DozeMachine.Service mDozeService;
    private final DozeMachine.Service mDozeService;
    private final Handler mHandler;
    private final Handler mHandler;
    private final Runnable mApplyPendingScreenState = this::applyPendingScreenState;
    private final Runnable mApplyPendingScreenState = this::applyPendingScreenState;
    private final DozeParameters mParameters;


    private int mPendingScreenState = Display.STATE_UNKNOWN;
    private int mPendingScreenState = Display.STATE_UNKNOWN;


    public DozeScreenState(DozeMachine.Service service, Handler handler) {
    public DozeScreenState(DozeMachine.Service service, Handler handler,
            DozeParameters parameters) {
        mDozeService = service;
        mDozeService = service;
        mHandler = handler;
        mHandler = handler;
        mParameters = parameters;
    }
    }


    @Override
    @Override
    public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) {
    public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) {
        int screenState = newState.screenState();
        int screenState = newState.screenState(mParameters);


        if (newState == DozeMachine.State.FINISH) {
        if (newState == DozeMachine.State.FINISH) {
            // Make sure not to apply the screen state after DozeService was destroyed.
            // Make sure not to apply the screen state after DozeService was destroyed.
+9 −1
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import static com.android.systemui.utils.os.FakeHandler.Mode.QUEUEING;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;


import android.os.Looper;
import android.os.Looper;
import android.support.test.filters.SmallTest;
import android.support.test.filters.SmallTest;
@@ -35,11 +36,14 @@ import android.support.test.runner.AndroidJUnit4;
import android.view.Display;
import android.view.Display;


import com.android.systemui.SysuiTestCase;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.utils.os.FakeHandler;
import com.android.systemui.utils.os.FakeHandler;


import org.junit.Before;
import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;


@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4.class)
@SmallTest
@SmallTest
@@ -48,12 +52,16 @@ public class DozeScreenStateTest extends SysuiTestCase {
    DozeServiceFake mServiceFake;
    DozeServiceFake mServiceFake;
    DozeScreenState mScreen;
    DozeScreenState mScreen;
    FakeHandler mHandlerFake;
    FakeHandler mHandlerFake;
    @Mock
    DozeParameters mDozeParameters;


    @Before
    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        when(mDozeParameters.getDisplayNeedsBlanking()).thenReturn(true);
        mServiceFake = new DozeServiceFake();
        mServiceFake = new DozeServiceFake();
        mHandlerFake = new FakeHandler(Looper.getMainLooper());
        mHandlerFake = new FakeHandler(Looper.getMainLooper());
        mScreen = new DozeScreenState(mServiceFake, mHandlerFake);
        mScreen = new DozeScreenState(mServiceFake, mHandlerFake, mDozeParameters);
    }
    }


    @Test
    @Test