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

Commit d559279b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8012527 from 0eeab2b0 to sc-v2-release

Change-Id: Ibd7100680766677c517ab6a82a152dd93d6845fc
parents 5f61b879 0eeab2b0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4969,7 +4969,8 @@ public final class ActivityThread extends ClientTransactionHandler
                Slog.w(TAG, "Activity top position already set to onTop=" + onTop);
                return;
            }
            throw new IllegalStateException("Activity top position already set to onTop=" + onTop);
            // TODO(b/209744518): Remove this short-term workaround while fixing the binder failure.
            Slog.e(TAG, "Activity top position already set to onTop=" + onTop);
        }

        r.isTopResumedActivity = onTop;
+1 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ public class NotificationSnooze extends LinearLayout
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        logOptionSelection(MetricsEvent.NOTIFICATION_SNOOZE_CLICKED, mDefaultOption);
        dispatchConfigurationChanged(getResources().getConfiguration());
    }

    @Override
+6 −2
Original line number Diff line number Diff line
@@ -411,7 +411,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private NotificationShelf mShelf;
    private int mMaxDisplayedNotifications = -1;
    private float mKeyguardBottomPadding = -1;
    private int mStatusBarHeight;
    @VisibleForTesting int mStatusBarHeight;
    private int mMinInteractionHeight;
    private final Rect mClipRect = new Rect();
    private boolean mIsClipped;
@@ -4851,8 +4851,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

    @ShadeViewRefactor(RefactorComponent.COORDINATOR)
    public int getMinExpansionHeight() {
        // shelf height is defined in dp but status bar height can be defined in px, that makes
        // relation between them variable - sometimes one might be bigger than the other when
        // changing density. That’s why we need to ensure we’re not subtracting negative value below
        return mShelf.getIntrinsicHeight()
                - (mShelf.getIntrinsicHeight() - mStatusBarHeight + mWaterfallTopInset) / 2
                - Math.max(0,
                (mShelf.getIntrinsicHeight() - mStatusBarHeight + mWaterfallTopInset) / 2)
                + mWaterfallTopInset;
    }

+6 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.testing.TestableLooper
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.controls.controller.ControlsControllerImplTest.Companion.eq
import com.android.systemui.keyguard.WakefulnessLifecycle
@@ -82,6 +83,8 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
    private lateinit var statusBarKeyguardViewManager: StatusBarKeyguardViewManager
    @Mock
    private lateinit var configurationController: ConfigurationController
    @Mock
    private lateinit var uniqueObjectHostView: UniqueObjectHostView
    @Captor
    private lateinit var wakefullnessObserver: ArgumentCaptor<(WakefulnessLifecycle.Observer)>
    @Captor
@@ -94,6 +97,8 @@ class MediaHierarchyManagerTest : SysuiTestCase() {

    @Before
    fun setup() {
        context.getOrCreateTestableResources().addOverride(
                R.bool.config_use_split_notification_shade, false)
        mediaFrame = FrameLayout(context)
        `when`(mediaCarouselController.mediaFrame).thenReturn(mediaFrame)
        mediaHiearchyManager = MediaHierarchyManager(
@@ -124,7 +129,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
    private fun setupHost(host: MediaHost, location: Int) {
        `when`(host.location).thenReturn(location)
        `when`(host.currentBounds).thenReturn(Rect())
        `when`(host.hostView).thenReturn(UniqueObjectHostView(context))
        `when`(host.hostView).thenReturn(uniqueObjectHostView)
        `when`(host.visible).thenReturn(true)
        mediaHiearchyManager.register(host)
    }
+38 −14
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.view.View.GONE;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_GENTLE;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;

import static junit.framework.Assert.assertEquals;
@@ -103,6 +104,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Mock private NotificationSwipeHelper mNotificationSwipeHelper;
    @Mock private NotificationStackScrollLayoutController mStackScrollLayoutController;
    @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    @Mock private NotificationShelf mNotificationShelf;

    @Before
    @UiThreadTest
@@ -124,13 +126,13 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mDependency.injectTestDependency(GroupMembershipManager.class, mGroupMembershipManger);
        mDependency.injectTestDependency(GroupExpansionManager.class, mGroupExpansionManager);
        mDependency.injectTestDependency(AmbientState.class, mAmbientState);
        mDependency.injectTestDependency(NotificationShelf.class, mNotificationShelf);
        mDependency.injectTestDependency(
                UnlockedScreenOffAnimationController.class, mUnlockedScreenOffAnimationController);

        NotificationShelfController notificationShelfController =
                mock(NotificationShelfController.class);
        NotificationShelf notificationShelf = mock(NotificationShelf.class);
        when(notificationShelfController.getView()).thenReturn(notificationShelf);
        when(notificationShelfController.getView()).thenReturn(mNotificationShelf);
        when(mNotificationSectionsManager.createSectionsForBuckets()).thenReturn(
                new NotificationSection[]{
                        mNotificationSection
@@ -160,7 +162,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
                        anyBoolean());
        doNothing().when(mGroupExpansionManager).collapseGroups();
        doNothing().when(mExpandHelper).cancelImmediately();
        doNothing().when(notificationShelf).setAnimationsEnabled(anyBoolean());
        doNothing().when(mNotificationShelf).setAnimationsEnabled(anyBoolean());
    }

    @Test
@@ -203,21 +205,43 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

    @Test
    @UiThreadTest
    public void testSetExpandedHeight_blockingHelperManagerReceivedCallbacks() {
        final float[] expectedHeight = {0f};
        final float[] expectedAppear = {0f};
    public void testSetExpandedHeight_listenerReceivedCallbacks() {
        final float expectedHeight = 0f;

        mStackScroller.addOnExpandedHeightChangedListener((height, appear) -> {
            Assert.assertEquals(expectedHeight[0], height, 0);
            Assert.assertEquals(expectedAppear[0], appear, .1);
            Assert.assertEquals(expectedHeight, height, 0);
        });
        expectedHeight[0] = 1f;
        expectedAppear[0] = 1f;
        mStackScroller.setExpandedHeight(expectedHeight[0]);
        mStackScroller.setExpandedHeight(expectedHeight);
    }

        expectedHeight[0] = 100f;
        expectedAppear[0] = 0f;
        mStackScroller.setExpandedHeight(expectedHeight[0]);
    @Test
    public void testAppearFractionCalculation() {
        // appear start position
        when(mNotificationShelf.getIntrinsicHeight()).thenReturn(100);
        // because it's the same as shelf height, appear start position equals shelf height
        mStackScroller.mStatusBarHeight = 100;
        // appear end position
        when(mEmptyShadeView.getHeight()).thenReturn(200);

        assertEquals(0f, mStackScroller.calculateAppearFraction(100));
        assertEquals(1f, mStackScroller.calculateAppearFraction(200));
        assertEquals(0.5f, mStackScroller.calculateAppearFraction(150));
    }

    @Test
    public void testAppearFractionCalculationIsNotNegativeWhenShelfBecomesSmaller() {
        // this situation might occur if status bar height is defined in pixels while shelf height
        // in dp and screen density changes - appear start position
        // (calculated in NSSL#getMinExpansionHeight) that is adjusting for status bar might
        // increase and become bigger that end position, which should be prevented

        // appear start position
        when(mNotificationShelf.getIntrinsicHeight()).thenReturn(80);
        mStackScroller.mStatusBarHeight = 100;
        // appear end position
        when(mEmptyShadeView.getHeight()).thenReturn(90);

        assertThat(mStackScroller.calculateAppearFraction(100)).isAtLeast(0);
    }

    @Test
Loading