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

Commit 51534dc3 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge changes from topic "am-bdf200cd9fa0482b98c9c5ce996a2490"

* changes:
  Merge "[automerger skipped] Merge "Enforce ComponentName belongs to caller app" into tm-dev am: 483a3cab am: d3b7b975 am: b6874efe -s ours" into tm-qpr-dev-plus-aosp am: 765e935d -s ours
  [automerger skipped] Merge "Enforce ComponentName belongs to caller app" into tm-dev am: 483a3cab am: d3b7b975 am: b6874efe -s ours am: aff2abf7 -s ours
parents 138a3b47 59146f39
Loading
Loading
Loading
Loading
+18 −63
Original line number Diff line number Diff line
@@ -98,7 +98,6 @@ import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.policy.SystemBarUtils;
import com.android.internal.util.LatencyTracker;
import com.android.keyguard.ActiveUnlockConfig;
import com.android.keyguard.KeyguardClockSwitch.ClockSize;
import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardStatusViewController;
import com.android.keyguard.KeyguardUnfoldTransition;
@@ -1416,10 +1415,19 @@ public final class NotificationPanelViewController extends PanelViewController {
    private void updateClockAppearance() {
        int userSwitcherPreferredY = mStatusBarHeaderHeightKeyguard;
        boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
        final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
                .getVisibleNotificationCount() != 0
                || mMediaDataManager.hasActiveMediaOrRecommendation();
        boolean splitShadeWithActiveMedia =
                mSplitShadeEnabled && mMediaDataManager.hasActiveMediaOrRecommendation();
        boolean shouldAnimateClockChange = mScreenOffAnimationController.shouldAnimateClockChange();
        mKeyguardStatusViewController.displayClock(computeDesiredClockSize(),
                shouldAnimateClockChange);
        updateKeyguardStatusViewAlignment(/* animate= */true);
        if ((hasVisibleNotifications && !mSplitShadeEnabled)
                || (splitShadeWithActiveMedia && !mDozing)) {
            mKeyguardStatusViewController.displayClock(SMALL, shouldAnimateClockChange);
        } else {
            mKeyguardStatusViewController.displayClock(LARGE, shouldAnimateClockChange);
        }
        updateKeyguardStatusViewAlignment(true /* animate */);
        int userSwitcherHeight = mKeyguardQsUserSwitchController != null
                ? mKeyguardQsUserSwitchController.getUserIconHeight() : 0;
        if (mKeyguardUserSwitcherController != null) {
@@ -1428,7 +1436,7 @@ public final class NotificationPanelViewController extends PanelViewController {
        float expandedFraction =
                mScreenOffAnimationController.shouldExpandNotifications()
                        ? 1.0f : getExpandedFraction();
        float darkAmount =
        float darkamount =
                mScreenOffAnimationController.shouldExpandNotifications()
                        ? 1.0f : mInterpolatedDarkAmount;

@@ -1446,7 +1454,7 @@ public final class NotificationPanelViewController extends PanelViewController {
                mKeyguardStatusViewController.getLockscreenHeight(),
                userSwitcherHeight,
                userSwitcherPreferredY,
                darkAmount, mOverStretchAmount,
                darkamount, mOverStretchAmount,
                bypassEnabled, getUnlockedStackScrollerPadding(),
                computeQsExpansionFraction(),
                mDisplayTopInset,
@@ -1478,34 +1486,6 @@ public final class NotificationPanelViewController extends PanelViewController {
        updateClock();
    }

    @ClockSize
    private int computeDesiredClockSize() {
        if (mSplitShadeEnabled) {
            return computeDesiredClockSizeForSplitShade();
        }
        return computeDesiredClockSizeForSingleShade();
    }

    @ClockSize
    private int computeDesiredClockSizeForSingleShade() {
        if (hasVisibleNotifications()) {
            return SMALL;
        }
        return LARGE;
    }

    @ClockSize
    private int computeDesiredClockSizeForSplitShade() {
        // Media is not visible to the user on AOD.
        boolean isMediaVisibleToUser =
                mMediaDataManager.hasActiveMediaOrRecommendation() && !isOnAod();
        if (isMediaVisibleToUser) {
            // When media is visible, it overlaps with the large clock. Use small clock instead.
            return SMALL;
        }
        return LARGE;
    }

    private void updateKeyguardStatusViewAlignment(boolean animate) {
        boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered();
        if (mStatusViewCentered != shouldBeCentered) {
@@ -1532,35 +1512,12 @@ public final class NotificationPanelViewController extends PanelViewController {
    }

    private boolean shouldKeyguardStatusViewBeCentered() {
        if (mSplitShadeEnabled) {
            return shouldKeyguardStatusViewBeCenteredInSplitShade();
        }
        return true;
    }

    private boolean shouldKeyguardStatusViewBeCenteredInSplitShade() {
        if (!hasVisibleNotifications()) {
            // No notifications visible. It is safe to have the clock centered as there will be no
            // overlap.
            return true;
        }
        if (hasPulsingNotifications()) {
            // Pulsing notification appears on the right. Move clock left to avoid overlap.
            return false;
        }
        // "Visible" notifications are actually not visible on AOD (unless pulsing), so it is safe
        // to center the clock without overlap.
        return isOnAod();
    }

    private boolean isOnAod() {
        return mDozing && mDozeParameters.getAlwaysOn();
    }

    private boolean hasVisibleNotifications() {
        return mNotificationStackScrollLayoutController
        boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
                .getVisibleNotificationCount() != 0
                || mMediaDataManager.hasActiveMediaOrRecommendation();
        boolean isOnAod = mDozing && mDozeParameters.getAlwaysOn();
        return !mSplitShadeEnabled || !hasVisibleNotifications || isOnAod
                || hasPulsingNotifications();
    }

    /**
@@ -3814,8 +3771,6 @@ public final class NotificationPanelViewController extends PanelViewController {
            mAnimateNextPositionUpdate = false;
        }
        mNotificationStackScrollLayoutController.setPulsing(pulsing, animatePulse);

        updateKeyguardStatusViewAlignment(/* animate= */ true);
    }

    public void setAmbientIndicationTop(int ambientIndicationTop, boolean ambientTextVisible) {
+15 −36
Original line number Diff line number Diff line
@@ -904,7 +904,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {

        setDozing(/* dozing= */ true, /* dozingAlwaysOn= */ true);

        assertKeyguardStatusViewCentered();
        assertThat(isKeyguardStatusViewCentered()).isTrue();
    }

    @Test
@@ -915,7 +915,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {

        setDozing(/* dozing= */ true, /* dozingAlwaysOn= */ false);

        assertKeyguardStatusViewNotCentered();
        assertThat(isKeyguardStatusViewCentered()).isFalse();
    }

    @Test
@@ -926,19 +926,19 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {

        setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true);

        assertKeyguardStatusViewNotCentered();
        assertThat(isKeyguardStatusViewCentered()).isFalse();
    }

    @Test
    public void keyguardStatusView_splitShade_pulsing_isNotCentered() {
    public void keyguardStatusView_splitShade_pulsing_isCentered() {
        when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2);
        when(mNotificationListContainer.hasPulsingNotifications()).thenReturn(true);
        mStatusBarStateController.setState(KEYGUARD);
        enableSplitShade(/* enabled= */ true);

        setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ false);
        setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true);

        assertKeyguardStatusViewNotCentered();
        assertThat(isKeyguardStatusViewCentered()).isFalse();
    }

    @Test
@@ -948,9 +948,9 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
        mStatusBarStateController.setState(KEYGUARD);
        enableSplitShade(/* enabled= */ true);

        setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ false);
        setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true);

        assertKeyguardStatusViewNotCentered();
        assertThat(isKeyguardStatusViewCentered()).isFalse();
    }

    @Test
@@ -963,7 +963,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
        mStatusBarStateController.setState(KEYGUARD);
        setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ false);

        assertKeyguardStatusViewCentered();
        assertThat(isKeyguardStatusViewCentered()).isFalse();
    }

    @Test
@@ -1208,31 +1208,16 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
    }

    @Test
    public void clockSize_mediaShowing_inSplitShade_onAod_isLarge() {
        when(mDozeParameters.getAlwaysOn()).thenReturn(true);
    public void testSwitchesToBigClockInSplitShadeOnAod() {
        mStatusBarStateController.setState(KEYGUARD);
        enableSplitShade(/* enabled= */ true);
        when(mMediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true);
        when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2);
        clearInvocations(mKeyguardStatusViewController);

        mNotificationPanelViewController.setDozing(/* dozing= */ true, /* animate= */ false, null);

        verify(mKeyguardStatusViewController).displayClock(LARGE, /* animate= */ true);
    }

    @Test
    public void clockSize_mediaShowing_inSplitShade_screenOff_notAod_isSmall() {
        when(mDozeParameters.getAlwaysOn()).thenReturn(false);
        mStatusBarStateController.setState(KEYGUARD);
        enableSplitShade(/* enabled= */ true);
        when(mMediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true);
        when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2);
        clearInvocations(mKeyguardStatusViewController);

        mNotificationPanelViewController.setDozing(/* dozing= */ true, /* animate= */ false, null);
        mNotificationPanelViewController.setDozing(true, false, null);

        verify(mKeyguardStatusViewController).displayClock(SMALL, /* animate= */ true);
        verify(mKeyguardStatusViewController).displayClock(LARGE, /* animate */ true);
    }

    @Test
@@ -1563,15 +1548,9 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
        );
    }

    private void assertKeyguardStatusViewCentered() {
        mNotificationPanelViewController.updateResources();
        assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd).isAnyOf(
                ConstraintSet.PARENT_ID, ConstraintSet.UNSET);
    }

    private void assertKeyguardStatusViewNotCentered() {
    private boolean isKeyguardStatusViewCentered() {
        mNotificationPanelViewController.updateResources();
        assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd).isEqualTo(
                R.id.qs_edge_guideline);
        return getConstraintSetLayout(R.id.keyguard_status_view).endToEnd
                == ConstraintSet.PARENT_ID;
    }
}