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

Commit 12663d30 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Remove black frame when pulsing

Fixes: 73121392
Test: Receive notification on AOD
Change-Id: I04802b3b456e2c484fc5aaab8460a08b82f952e4
parent 4437a22f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public class DozeFactory {
                createDozeTriggers(context, sensorManager, host, alarmManager, config, params,
                        handler, wakeLock, machine),
                createDozeUi(context, host, wakeLock, machine, handler, alarmManager, params),
                new DozeScreenState(wrappedService, handler),
                new DozeScreenState(wrappedService, handler, params),
                createDozeScreenBrightness(context, wrappedService, sensorManager, host, handler),
                new DozeWallpaperState(context)
        });
+5 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.Display;

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

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

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

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

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

    private int mPendingScreenState = Display.STATE_UNKNOWN;

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

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

        if (newState == DozeMachine.State.FINISH) {
            // Make sure not to apply the screen state after DozeService was destroyed.
+9 −1
Original line number 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.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

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

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

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

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

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

    @Test