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

Commit 4aa9f16e authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Add requested refresh rate on keyguard" into sc-dev

parents bae80e0d a65cb90b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -523,9 +523,13 @@
     -->
    <string name="config_rounded_mask" translatable="false">"M8,0C3.6,0,0,3.6,0,8"</string>

    <!-- Preferred refresh rate at keyguard, if supported by the display -->
    <!-- Preferred refresh rate at keyguard, if supported by the display. Overrides
         keyguardMaxRefreshRate. -->
    <integer name="config_keyguardRefreshRate">-1</integer>

    <!-- Preferred max refresh rate at keyguard, if supported by the display. -->
    <integer name="config_keyguardMaxRefreshRate">-1</integer>

    <!-- Whether or not to add a "people" notifications section -->
    <bool name="config_usePeopleFiltering">false</bool>

+42 −9
Original line number Diff line number Diff line
@@ -38,8 +38,10 @@ import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
@@ -83,9 +85,11 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
    private final LayoutParams mLpChanged;
    private final boolean mKeyguardScreenRotation;
    private final long mLockScreenDisplayTimeout;
    private final float mKeyguardRefreshRate;
    private final float mKeyguardPreferredRefreshRate; // takes precedence over max
    private final float mKeyguardMaxRefreshRate;
    private final KeyguardViewMediator mKeyguardViewMediator;
    private final KeyguardBypassController mKeyguardBypassController;
    private final AuthController mAuthController;
    private ViewGroup mNotificationShadeView;
    private LayoutParams mLp;
    private boolean mHasTopUi;
@@ -112,7 +116,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
            SysuiColorExtractor colorExtractor,
            DumpManager dumpManager,
            KeyguardStateController keyguardStateController,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
            AuthController authController) {
        mContext = context;
        mWindowManager = windowManager;
        mActivityManager = activityManager;
@@ -125,6 +130,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        mColorExtractor = colorExtractor;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
        dumpManager.registerDumpable(getClass().getName(), this);
        mAuthController = authController;

        mLockScreenDisplayTimeout = context.getResources()
                .getInteger(R.integer.config_lockScreenDisplayTimeout);
@@ -133,13 +139,25 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
                        SysuiStatusBarStateController.RANK_STATUS_BAR_WINDOW_CONTROLLER);
        configurationController.addCallback(this);

        Display.Mode[] supportedModes = context.getDisplay().getSupportedModes();
        Display.Mode currentMode = context.getDisplay().getMode();
        float desiredPreferredRefreshRate = context.getResources()
                .getInteger(R.integer.config_keyguardRefreshRate);
        float actualPreferredRefreshRate = -1;
        if (desiredPreferredRefreshRate > -1) {
            for (Display.Mode displayMode : context.getDisplay().getSupportedModes()) {
                if (Math.abs(displayMode.getRefreshRate() - desiredPreferredRefreshRate) <= .1) {
                    actualPreferredRefreshRate = displayMode.getRefreshRate();
                    break;
                }
            }
        }

        mKeyguardPreferredRefreshRate = actualPreferredRefreshRate;

        // Running on the highest frame rate available can be expensive.
        // Let's specify a preferred refresh rate, and allow higher FPS only when we
        // know that we're not falsing (because we unlocked.)
        mKeyguardRefreshRate = context.getResources()
                .getInteger(R.integer.config_keyguardRefreshRate);
        mKeyguardMaxRefreshRate = context.getResources()
                .getInteger(R.integer.config_keyguardMaxRefreshRate);
    }

    /**
@@ -274,12 +292,26 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
            mLpChanged.privateFlags &= ~LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
        }

        if (mKeyguardRefreshRate > 0) {
        if (mKeyguardPreferredRefreshRate > 0) {
            boolean onKeyguard = state.mStatusBarState == StatusBarState.KEYGUARD
                    && !state.mKeyguardFadingAway && !state.mKeyguardGoingAway
                    && !state.mDozing;
            if (onKeyguard
                    && mAuthController.isUdfpsEnrolled(KeyguardUpdateMonitor.getCurrentUser())) {
                mLpChanged.preferredMaxDisplayRefreshRate = mKeyguardPreferredRefreshRate;
                mLpChanged.preferredMinDisplayRefreshRate = mKeyguardPreferredRefreshRate;
            } else {
                mLpChanged.preferredMaxDisplayRefreshRate = 0;
                mLpChanged.preferredMinDisplayRefreshRate = 0;
            }
            Trace.setCounter("display_set_preferred_refresh_rate",
                    (long) mKeyguardPreferredRefreshRate);
        } else if (mKeyguardMaxRefreshRate > 0) {
            boolean bypassOnKeyguard = mKeyguardBypassController.getBypassEnabled()
                    && state.mStatusBarState == StatusBarState.KEYGUARD
                    && !state.mKeyguardFadingAway && !state.mKeyguardGoingAway;
            if (state.mDozing || bypassOnKeyguard) {
                mLpChanged.preferredMaxDisplayRefreshRate = mKeyguardRefreshRate;
                mLpChanged.preferredMaxDisplayRefreshRate = mKeyguardMaxRefreshRate;
            } else {
                mLpChanged.preferredMaxDisplayRefreshRate = 0;
            }
@@ -685,7 +717,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
    @Override
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println(TAG + ":");
        pw.println("  mKeyguardRefreshRate=" + mKeyguardRefreshRate);
        pw.println("  mKeyguardMaxRefreshRate=" + mKeyguardMaxRefreshRate);
        pw.println("  mKeyguardPreferredRefreshRate=" + mKeyguardPreferredRefreshRate);
        pw.println(mCurrentState);
        if (mNotificationShadeView != null && mNotificationShadeView.getViewRootImpl() != null) {
            mNotificationShadeView.getViewRootImpl().dump("  ", pw);
+3 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import androidx.test.filters.SmallTest;

import com.android.internal.colorextraction.ColorExtractor;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -73,6 +74,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
    @Mock private DumpManager mDumpManager;
    @Mock private KeyguardStateController mKeyguardStateController;
    @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    @Mock private AuthController mAuthController;
    @Captor private ArgumentCaptor<WindowManager.LayoutParams> mLayoutParameters;

    private NotificationShadeWindowControllerImpl mNotificationShadeWindowController;
@@ -87,7 +89,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
                mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
                mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController,
                mColorExtractor, mDumpManager, mKeyguardStateController,
                mUnlockedScreenOffAnimationController);
                mUnlockedScreenOffAnimationController, mAuthController);
        mNotificationShadeWindowController.setScrimsVisibilityListener((visibility) -> {});
        mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);

+4 −2
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -73,6 +72,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -236,6 +236,8 @@ public class BubblesTest extends SysuiTestCase {
    private KeyguardStateController mKeyguardStateController;
    @Mock
    private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    @Mock
    private AuthController mAuthController;

    private TestableBubblePositioner mPositioner;

@@ -259,7 +261,7 @@ public class BubblesTest extends SysuiTestCase {
                mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
                mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController,
                mColorExtractor, mDumpManager, mKeyguardStateController,
                mUnlockedScreenOffAnimationController);
                mUnlockedScreenOffAnimationController, mAuthController);
        mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
        mNotificationShadeWindowController.attach();

+4 −1
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -153,6 +154,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
    private BubbleDataRepository mDataRepository;
    @Mock
    private NotificationShadeWindowView mNotificationShadeWindowView;
    @Mock
    private AuthController mAuthController;

    private SysUiState mSysUiState = new SysUiState();

@@ -222,7 +225,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
                mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
                mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController,
                mColorExtractor, mDumpManager, mKeyguardStateController,
                mUnlockedScreenOffAnimationController);
                mUnlockedScreenOffAnimationController, mAuthController);
        mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
        mNotificationShadeWindowController.attach();