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

Commit 8c2fe3f7 authored by axfordjc's avatar axfordjc
Browse files

Force small clock on small landscape lockscreen (except AOD)

- small clock is now used on lockscreen when: on small landscape screens, AOD is not visible, and flag LOCKSCREEN_ENABLE_LANDSCAPE is enabled.

This is a required feature for landscape lockscreen for small screens

Guarded by flag "lockscreen.enable_landscape" (b/293252410)

Added tests to ensure only small clock is used when the flag is on, screen is small, and screen is landscape.

Bug: 296571001
Bug: 293252410

Test: NotificationPanelViewControllerTest
Change-Id: Ic355ebbb4d175386f525d7b7ef492018199652ef
parent 2fa2650e
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<?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>
+22 −0
Original line number Diff line number Diff line
<?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>
+4 −0
Original line number Diff line number Diff line
@@ -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>
+11 −0
Original line number Diff line number Diff line
@@ -1680,6 +1680,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

    @ClockSize
    private int computeDesiredClockSize() {
        if (shouldForceSmallClock()) {
            return SMALL;
        }

        if (mSplitShadeEnabled) {
            return computeDesiredClockSizeForSplitShade();
        }
@@ -1712,6 +1716,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        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;
+37 −1
Original line number Diff line number Diff line
@@ -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;
@@ -59,6 +58,7 @@ import androidx.test.filters.SmallTest;
import com.android.keyguard.FaceAuthApiRequestReason;
import com.android.systemui.DejankUtils;
import com.android.systemui.R;
import com.android.systemui.flags.Flags;
import com.android.systemui.keyguard.shared.model.WakeSleepReason;
import com.android.systemui.keyguard.shared.model.WakefulnessModel;
import com.android.systemui.keyguard.shared.model.WakefulnessState;
@@ -833,6 +833,42 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo
        verify(mKeyguardStatusViewController).displayClock(LARGE, /* animate */ false);
    }

    @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);