diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index e22bca7c1283b..d1ed2a852d38b 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -523,9 +523,13 @@
-->
"M8,0C3.6,0,0,3.6,0,8"
-
+
-1
+
+ -1
+
false
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java
index 15b2da02382c9..022faf78b9463 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java
@@ -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);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java
index 038645637f21a..ddd78541d1137 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java
@@ -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 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);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
index eb9206daec135..f243077afc932 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
@@ -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();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java
index 24a5b3a42bb43..e4c78009f4912 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java
@@ -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();