Merge "Force small clock on small landscape lockscreen (except AOD)" into main
diff --git a/packages/SystemUI/res/values-land/bools.xml b/packages/SystemUI/res/values-land/bools.xml
new file mode 100644
index 0000000..e24792d
--- /dev/null
+++ b/packages/SystemUI/res/values-land/bools.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (c) 2023, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+-->
+<resources>
+ <!-- Only use small clock on lockscreen.
+ True here because only small clock used on small devices in landscape -->
+ <bool name="force_small_clock_on_lockscreen">true</bool>
+</resources>
diff --git a/packages/SystemUI/res/values-sw600dp-land/bools.xml b/packages/SystemUI/res/values-sw600dp-land/bools.xml
new file mode 100644
index 0000000..c4d77e8
--- /dev/null
+++ b/packages/SystemUI/res/values-sw600dp-land/bools.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (c) 2023, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+-->
+<resources>
+ <!-- Only use small clock on lockscreen.
+ False here because large clock is allowed on large devices in landscape -->
+ <bool name="force_small_clock_on_lockscreen">false</bool>
+</resources>
diff --git a/packages/SystemUI/res/values/bools.xml b/packages/SystemUI/res/values/bools.xml
index 91d3a88..3956662 100644
--- a/packages/SystemUI/res/values/bools.xml
+++ b/packages/SystemUI/res/values/bools.xml
@@ -59,4 +59,8 @@
True here so bouncers constraints are updated when rotating on small screens -->
<bool name="update_bouncer_constraints">true</bool>
+
+ <!-- Only use small clock on lockscreen.
+ False here because large clock used by default, unless otherwise specified -->
+ <bool name="force_small_clock_on_lockscreen">false</bool>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index 7f0b899..a5abf58 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -1675,6 +1675,10 @@
@ClockSize
private int computeDesiredClockSize() {
+ if (shouldForceSmallClock()) {
+ return SMALL;
+ }
+
if (mSplitShadeEnabled) {
return computeDesiredClockSizeForSplitShade();
}
@@ -1707,6 +1711,13 @@
return LARGE;
}
+ private boolean shouldForceSmallClock() {
+ return mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)
+ && !isOnAod()
+ // True on small landscape screens
+ && mResources.getBoolean(R.bool.force_small_clock_on_lockscreen);
+ }
+
private void updateKeyguardStatusViewAlignment(boolean animate) {
boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered();
ConstraintLayout layout;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java
index 227f653..8be8178 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java
@@ -16,7 +16,6 @@
package com.android.systemui.shade;
-import static com.android.keyguard.FaceAuthApiRequestReason.NOTIFICATION_PANEL_CLICKED;
import static com.android.keyguard.KeyguardClockSwitch.LARGE;
import static com.android.keyguard.KeyguardClockSwitch.SMALL;
import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_CLOSED;
@@ -835,6 +834,42 @@
}
@Test
+ public void switchesToBigClockInSplitShadeOn_landFlagOn_ForceSmallClock() {
+ when(mScreenOffAnimationController.shouldAnimateClockChange()).thenReturn(false);
+ mStatusBarStateController.setState(KEYGUARD);
+ enableSplitShade(/* enabled= */ false);
+ mNotificationPanelViewController.setDozing(false, false);
+ when(mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)).thenReturn(true);
+ when(mResources.getBoolean(R.bool.force_small_clock_on_lockscreen)).thenReturn(true);
+ when(mMediaDataManager.hasActiveMedia()).thenReturn(false);
+ when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(0);
+ clearInvocations(mKeyguardStatusViewController);
+
+ enableSplitShade(/* enabled= */ true);
+ mNotificationPanelViewController.updateResources();
+
+ verify(mKeyguardStatusViewController).displayClock(SMALL, /* animate */ false);
+ }
+
+ @Test
+ public void switchesToBigClockInSplitShadeOn_landFlagOff_DontForceSmallClock() {
+ when(mScreenOffAnimationController.shouldAnimateClockChange()).thenReturn(false);
+ mStatusBarStateController.setState(KEYGUARD);
+ enableSplitShade(/* enabled= */ false);
+ mNotificationPanelViewController.setDozing(false, false);
+ when(mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)).thenReturn(false);
+ when(mResources.getBoolean(R.bool.force_small_clock_on_lockscreen)).thenReturn(true);
+ when(mMediaDataManager.hasActiveMedia()).thenReturn(false);
+ when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(0);
+ clearInvocations(mKeyguardStatusViewController);
+
+ enableSplitShade(/* enabled= */ true);
+ mNotificationPanelViewController.updateResources();
+
+ verify(mKeyguardStatusViewController).displayClock(LARGE, /* animate */ false);
+ }
+
+ @Test
public void testDisplaysSmallClockOnLockscreenInSplitShadeWhenMediaIsPlaying() {
mStatusBarStateController.setState(KEYGUARD);
enableSplitShade(/* enabled= */ true);