diff options
5 files changed, 58 insertions, 14 deletions
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 16932821c05d..478bf9aa6afb 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -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> 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 a45ef942ed63..0ff6490aa7c9 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; } @@ -686,7 +718,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 038645637f21..ddd78541d113 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<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); 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 56cbf2960909..d6492c610a4f 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; @@ -237,6 +237,8 @@ public class BubblesTest extends SysuiTestCase { private KeyguardStateController mKeyguardStateController; @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; + @Mock + private AuthController mAuthController; private TestableBubblePositioner mPositioner; @@ -260,7 +262,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 9c16e5dc8f27..db8a08cdc5e4 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; @@ -154,6 +155,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase { private BubbleDataRepository mDataRepository; @Mock private NotificationShadeWindowView mNotificationShadeWindowView; + @Mock + private AuthController mAuthController; private SysUiState mSysUiState = new SysUiState(); @@ -223,7 +226,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase { mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController, mColorExtractor, mDumpManager, mKeyguardStateController, - mUnlockedScreenOffAnimationController); + mUnlockedScreenOffAnimationController, mAuthController); mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowController.attach(); |