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

This commit is contained in:
Beverly Tai
2021-07-02 17:18:11 +00:00
committed by Android (Google) Code Review
5 changed files with 58 additions and 14 deletions

View File

@@ -523,9 +523,13 @@
--> -->
<string name="config_rounded_mask" translatable="false">"M8,0C3.6,0,0,3.6,0,8"</string> <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> <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 --> <!-- Whether or not to add a "people" notifications section -->
<bool name="config_usePeopleFiltering">false</bool> <bool name="config_usePeopleFiltering">false</bool>

View File

@@ -38,8 +38,10 @@ import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Dumpable; import com.android.systemui.Dumpable;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager;
@@ -83,9 +85,11 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
private final LayoutParams mLpChanged; private final LayoutParams mLpChanged;
private final boolean mKeyguardScreenRotation; private final boolean mKeyguardScreenRotation;
private final long mLockScreenDisplayTimeout; 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 KeyguardViewMediator mKeyguardViewMediator;
private final KeyguardBypassController mKeyguardBypassController; private final KeyguardBypassController mKeyguardBypassController;
private final AuthController mAuthController;
private ViewGroup mNotificationShadeView; private ViewGroup mNotificationShadeView;
private LayoutParams mLp; private LayoutParams mLp;
private boolean mHasTopUi; private boolean mHasTopUi;
@@ -112,7 +116,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
SysuiColorExtractor colorExtractor, SysuiColorExtractor colorExtractor,
DumpManager dumpManager, DumpManager dumpManager,
KeyguardStateController keyguardStateController, KeyguardStateController keyguardStateController,
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) { UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
AuthController authController) {
mContext = context; mContext = context;
mWindowManager = windowManager; mWindowManager = windowManager;
mActivityManager = activityManager; mActivityManager = activityManager;
@@ -125,6 +130,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
mColorExtractor = colorExtractor; mColorExtractor = colorExtractor;
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
dumpManager.registerDumpable(getClass().getName(), this); dumpManager.registerDumpable(getClass().getName(), this);
mAuthController = authController;
mLockScreenDisplayTimeout = context.getResources() mLockScreenDisplayTimeout = context.getResources()
.getInteger(R.integer.config_lockScreenDisplayTimeout); .getInteger(R.integer.config_lockScreenDisplayTimeout);
@@ -133,13 +139,25 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
SysuiStatusBarStateController.RANK_STATUS_BAR_WINDOW_CONTROLLER); SysuiStatusBarStateController.RANK_STATUS_BAR_WINDOW_CONTROLLER);
configurationController.addCallback(this); configurationController.addCallback(this);
Display.Mode[] supportedModes = context.getDisplay().getSupportedModes(); float desiredPreferredRefreshRate = context.getResources()
Display.Mode currentMode = context.getDisplay().getMode(); .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. // Running on the highest frame rate available can be expensive.
// Let's specify a preferred refresh rate, and allow higher FPS only when we // Let's specify a preferred refresh rate, and allow higher FPS only when we
// know that we're not falsing (because we unlocked.) // know that we're not falsing (because we unlocked.)
mKeyguardRefreshRate = context.getResources() mKeyguardMaxRefreshRate = context.getResources()
.getInteger(R.integer.config_keyguardRefreshRate); .getInteger(R.integer.config_keyguardMaxRefreshRate);
} }
/** /**
@@ -274,12 +292,26 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
mLpChanged.privateFlags &= ~LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; 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() boolean bypassOnKeyguard = mKeyguardBypassController.getBypassEnabled()
&& state.mStatusBarState == StatusBarState.KEYGUARD && state.mStatusBarState == StatusBarState.KEYGUARD
&& !state.mKeyguardFadingAway && !state.mKeyguardGoingAway; && !state.mKeyguardFadingAway && !state.mKeyguardGoingAway;
if (state.mDozing || bypassOnKeyguard) { if (state.mDozing || bypassOnKeyguard) {
mLpChanged.preferredMaxDisplayRefreshRate = mKeyguardRefreshRate; mLpChanged.preferredMaxDisplayRefreshRate = mKeyguardMaxRefreshRate;
} else { } else {
mLpChanged.preferredMaxDisplayRefreshRate = 0; mLpChanged.preferredMaxDisplayRefreshRate = 0;
} }
@@ -685,7 +717,8 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
@Override @Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println(TAG + ":"); pw.println(TAG + ":");
pw.println(" mKeyguardRefreshRate=" + mKeyguardRefreshRate); pw.println(" mKeyguardMaxRefreshRate=" + mKeyguardMaxRefreshRate);
pw.println(" mKeyguardPreferredRefreshRate=" + mKeyguardPreferredRefreshRate);
pw.println(mCurrentState); pw.println(mCurrentState);
if (mNotificationShadeView != null && mNotificationShadeView.getViewRootImpl() != null) { if (mNotificationShadeView != null && mNotificationShadeView.getViewRootImpl() != null) {
mNotificationShadeView.getViewRootImpl().dump(" ", pw); mNotificationShadeView.getViewRootImpl().dump(" ", pw);

View File

@@ -40,6 +40,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.colorextraction.ColorExtractor;
import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -73,6 +74,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
@Mock private DumpManager mDumpManager; @Mock private DumpManager mDumpManager;
@Mock private KeyguardStateController mKeyguardStateController; @Mock private KeyguardStateController mKeyguardStateController;
@Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
@Mock private AuthController mAuthController;
@Captor private ArgumentCaptor<WindowManager.LayoutParams> mLayoutParameters; @Captor private ArgumentCaptor<WindowManager.LayoutParams> mLayoutParameters;
private NotificationShadeWindowControllerImpl mNotificationShadeWindowController; private NotificationShadeWindowControllerImpl mNotificationShadeWindowController;
@@ -87,7 +89,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController, mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController,
mColorExtractor, mDumpManager, mKeyguardStateController, mColorExtractor, mDumpManager, mKeyguardStateController,
mUnlockedScreenOffAnimationController); mUnlockedScreenOffAnimationController, mAuthController);
mNotificationShadeWindowController.setScrimsVisibilityListener((visibility) -> {}); mNotificationShadeWindowController.setScrimsVisibilityListener((visibility) -> {});
mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);

View File

@@ -39,7 +39,6 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; 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.colorextraction.ColorExtractor;
import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -236,6 +236,8 @@ public class BubblesTest extends SysuiTestCase {
private KeyguardStateController mKeyguardStateController; private KeyguardStateController mKeyguardStateController;
@Mock @Mock
private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
@Mock
private AuthController mAuthController;
private TestableBubblePositioner mPositioner; private TestableBubblePositioner mPositioner;
@@ -259,7 +261,7 @@ public class BubblesTest extends SysuiTestCase {
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController, mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController,
mColorExtractor, mDumpManager, mKeyguardStateController, mColorExtractor, mDumpManager, mKeyguardStateController,
mUnlockedScreenOffAnimationController); mUnlockedScreenOffAnimationController, mAuthController);
mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
mNotificationShadeWindowController.attach(); mNotificationShadeWindowController.attach();

View File

@@ -59,6 +59,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -153,6 +154,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
private BubbleDataRepository mDataRepository; private BubbleDataRepository mDataRepository;
@Mock @Mock
private NotificationShadeWindowView mNotificationShadeWindowView; private NotificationShadeWindowView mNotificationShadeWindowView;
@Mock
private AuthController mAuthController;
private SysUiState mSysUiState = new SysUiState(); private SysUiState mSysUiState = new SysUiState();
@@ -222,7 +225,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController, mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController,
mColorExtractor, mDumpManager, mKeyguardStateController, mColorExtractor, mDumpManager, mKeyguardStateController,
mUnlockedScreenOffAnimationController); mUnlockedScreenOffAnimationController, mAuthController);
mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
mNotificationShadeWindowController.attach(); mNotificationShadeWindowController.attach();