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

Commit d2d5c500 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove obsolete increased heights" into main

parents 9eac7e0f ecdcc734
Loading
Loading
Loading
Loading
+56 −115
Original line number Diff line number Diff line
@@ -6627,7 +6627,20 @@ public class Notification implements Parcelable
         */
        @Deprecated
        public RemoteViews createContentView() {
            return createContentView(false /* increasedheight */ );
            if (useExistingRemoteView(mN.contentView)) {
                return fullyCustomViewRequiresDecoration(false /* fromStyle */)
                        ? minimallyDecoratedContentView(mN.contentView) : mN.contentView;
            } else if (mStyle != null) {
                final RemoteViews styleView = mStyle.makeContentView();
                if (styleView != null) {
                    return fullyCustomViewRequiresDecoration(true /* fromStyle */)
                            ? minimallyDecoratedContentView(styleView) : styleView;
                }
            }
            StandardTemplateParams p = mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_NORMAL)
                    .fillTextsFrom(this);
            return applyStandardTemplate(getCollapsedBaseLayoutResource(), p, null /* result */);
        }
        // This code is executed on behalf of other apps' notifications, sometimes even by 3p apps,
@@ -6688,33 +6701,6 @@ public class Notification implements Parcelable
            return standard;
        }
        /**
         * Construct a RemoteViews for the smaller content view.
         *
         *   @param increasedHeight true if this layout be created with an increased height. Some
         *   styles may support showing more then just that basic 1U size
         *   and the system may decide to render important notifications
         *   slightly bigger even when collapsed.
         *
         *   @hide
         */
        public RemoteViews createContentView(boolean increasedHeight) {
            if (useExistingRemoteView(mN.contentView)) {
                return fullyCustomViewRequiresDecoration(false /* fromStyle */)
                        ? minimallyDecoratedContentView(mN.contentView) : mN.contentView;
            } else if (mStyle != null) {
                final RemoteViews styleView = mStyle.makeContentView(increasedHeight);
                if (styleView != null) {
                    return fullyCustomViewRequiresDecoration(true /* fromStyle */)
                            ? minimallyDecoratedContentView(styleView) : styleView;
                }
            }
            StandardTemplateParams p = mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_NORMAL)
                    .fillTextsFrom(this);
            return applyStandardTemplate(getCollapsedBaseLayoutResource(), p, null /* result */);
        }
        private boolean useExistingRemoteView(RemoteViews customContent) {
            if (customContent == null) {
                return false;
@@ -6849,41 +6835,6 @@ public class Notification implements Parcelable
            }
        }
        /**
         * Construct a RemoteViews for the final heads-up notification layout.
         *
         * @param increasedHeight true if this layout be created with an increased height. Some
         * styles may support showing more then just that basic 1U size
         * and the system may decide to render important notifications
         * slightly bigger even when collapsed.
         *
         * @hide
         */
        public RemoteViews createHeadsUpContentView(boolean increasedHeight) {
            if (useExistingRemoteView(mN.headsUpContentView)) {
                return fullyCustomViewRequiresDecoration(false /* fromStyle */)
                        ? minimallyDecoratedHeadsUpContentView(mN.headsUpContentView)
                        : mN.headsUpContentView;
            } else if (mStyle != null) {
                final RemoteViews styleView = mStyle.makeHeadsUpContentView(increasedHeight);
                if (styleView != null) {
                    return fullyCustomViewRequiresDecoration(true /* fromStyle */)
                            ? minimallyDecoratedHeadsUpContentView(styleView) : styleView;
                }
            } else if (mActions.size() == 0) {
                return null;
            }
            // We only want at most a single remote input history to be shown here, otherwise
            // the content would become squished.
            StandardTemplateParams p = mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_HEADS_UP)
                    .fillTextsFrom(this)
                    .setMaxRemoteInputHistory(1);
            return applyStandardTemplateWithActions(getHeadsUpBaseLayoutResource(), p,
                    null /* result */);
        }
        /**
         * Construct a RemoteViews for the final compact heads-up notification layout.
         * @hide
@@ -6891,7 +6842,7 @@ public class Notification implements Parcelable
        public RemoteViews createCompactHeadsUpContentView() {
            // Don't show compact heads up for FSI notifications.
            if (mN.fullScreenIntent != null) {
                return createHeadsUpContentView(/* increasedHeight= */ false);
                return createHeadsUpContentView();
            }
            if (mStyle != null) {
@@ -6929,7 +6880,28 @@ public class Notification implements Parcelable
         */
        @Deprecated
        public RemoteViews createHeadsUpContentView() {
            return createHeadsUpContentView(false /* useIncreasedHeight */);
            if (useExistingRemoteView(mN.headsUpContentView)) {
                return fullyCustomViewRequiresDecoration(false /* fromStyle */)
                        ? minimallyDecoratedHeadsUpContentView(mN.headsUpContentView)
                        : mN.headsUpContentView;
            } else if (mStyle != null) {
                final RemoteViews styleView = mStyle.makeHeadsUpContentView();
                if (styleView != null) {
                    return fullyCustomViewRequiresDecoration(true /* fromStyle */)
                            ? minimallyDecoratedHeadsUpContentView(styleView) : styleView;
                }
            } else if (mActions.size() == 0) {
                return null;
            }
            // We only want at most a single remote input history to be shown here, otherwise
            // the content would become squished.
            StandardTemplateParams p = mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_HEADS_UP)
                    .fillTextsFrom(this)
                    .setMaxRemoteInputHistory(1);
            return applyStandardTemplateWithActions(getHeadsUpBaseLayoutResource(), p,
                    null /* result */);
        }
        /**
@@ -8236,10 +8208,9 @@ public class Notification implements Parcelable
         * Construct a Style-specific RemoteViews for the collapsed notification layout.
         * The default implementation has nothing additional to add.
         *
         * @param increasedHeight true if this layout be created with an increased height.
         * @hide
         */
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView() {
            return null;
        }
@@ -8254,10 +8225,9 @@ public class Notification implements Parcelable
        /**
         * Construct a Style-specific RemoteViews for the final HUN layout.
         *
         * @param increasedHeight true if this layout be created with an increased height.
         * @hide
         */
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView() {
            return null;
        }
@@ -8543,9 +8513,9 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView() {
            if (mPictureIcon == null || !mShowBigPictureWhenCollapsed) {
                return super.makeContentView(increasedHeight);
                return super.makeContentView();
            }
            StandardTemplateParams p = mBuilder.mParams.reset()
@@ -8559,9 +8529,9 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView() {
            if (mPictureIcon == null || !mShowBigPictureWhenCollapsed) {
                return super.makeHeadsUpContentView(increasedHeight);
                return super.makeHeadsUpContentView();
            }
            StandardTemplateParams p = mBuilder.mParams.reset()
@@ -8791,35 +8761,6 @@ public class Notification implements Parcelable
            mBigText = extras.getCharSequence(EXTRA_BIG_TEXT);
        }
        /**
         * @param increasedHeight true if this layout be created with an increased height.
         *
         * @hide
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
            if (increasedHeight) {
                ArrayList<Action> originalActions = mBuilder.mActions;
                mBuilder.mActions = new ArrayList<>();
                RemoteViews remoteViews = makeExpandedContentView();
                mBuilder.mActions = originalActions;
                return remoteViews;
            }
            return super.makeContentView(increasedHeight);
        }
        /**
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
            if (increasedHeight && mBuilder.mActions.size() > 0) {
                // TODO(b/163626038): pass VIEW_TYPE_HEADS_UP?
                return makeExpandedContentView();
            }
            return super.makeHeadsUpContentView(increasedHeight);
        }
        /**
         * @hide
         */
@@ -9404,7 +9345,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView() {
            // All messaging templates contain the actions
            ArrayList<Action> originalActions = mBuilder.mActions;
            try {
@@ -9649,7 +9590,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView() {
            return makeMessagingView(StandardTemplateParams.VIEW_TYPE_HEADS_UP);
        }
@@ -10484,7 +10425,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView() {
            return makeMediaContentView(null /* customContent */);
        }
@@ -10500,7 +10441,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView() {
            return makeMediaContentView(null /* customContent */);
        }
@@ -10913,7 +10854,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView() {
            return makeCallLayout(StandardTemplateParams.VIEW_TYPE_NORMAL);
        }
@@ -10921,7 +10862,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView() {
            return makeCallLayout(StandardTemplateParams.VIEW_TYPE_HEADS_UP);
        }
@@ -10932,7 +10873,7 @@ public class Notification implements Parcelable
        @Override
        public RemoteViews makeCompactHeadsUpContentView() {
            // Use existing heads up for call style.
            return makeHeadsUpContentView(false);
            return makeHeadsUpContentView();
        }
        /**
@@ -11701,7 +11642,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView() {
            final StandardTemplateParams p = mBuilder.mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_NORMAL)
                    .hideProgress(true)
@@ -11713,7 +11654,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView() {
            final StandardTemplateParams p = mBuilder.mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_HEADS_UP)
                    .hideProgress(true)
@@ -12192,7 +12133,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView() {
            return makeStandardTemplateWithCustomContent(mBuilder.mN.contentView);
        }
@@ -12208,7 +12149,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView() {
            return makeDecoratedHeadsUpContentView();
        }
@@ -12328,7 +12269,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
        public RemoteViews makeContentView() {
            return makeMediaContentView(mBuilder.mN.contentView);
        }
@@ -12347,7 +12288,7 @@ public class Notification implements Parcelable
         * @hide
         */
        @Override
        public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
        public RemoteViews makeHeadsUpContentView() {
            RemoteViews customContent = mBuilder.mN.headsUpContentView != null
                    ? mBuilder.mN.headsUpContentView
                    : mBuilder.mN.contentView;
+1 −4
Original line number Diff line number Diff line
@@ -26,12 +26,10 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;


import androidx.core.os.CancellationSignal;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.internal.util.NotificationMessagingUtil;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -51,7 +49,6 @@ import java.util.concurrent.atomic.AtomicReference;
@SmallTest
public class HeadsUpViewBinderTest extends SysuiTestCase {
    private HeadsUpViewBinder mViewBinder;
    @Mock private NotificationMessagingUtil mNotificationMessagingUtil;
    @Mock private RowContentBindStage mBindStage;
    private final HeadsUpViewBinderLogger mLogger = spy(
            new HeadsUpViewBinderLogger(logcatLogBuffer()));
@@ -61,7 +58,7 @@ public class HeadsUpViewBinderTest extends SysuiTestCase {
    @Before
    public void setup() {
        MockitoAnnotations.initMocks(this);
        mViewBinder = new HeadsUpViewBinder(mNotificationMessagingUtil, mBindStage, mLogger);
        mViewBinder = new HeadsUpViewBinder(mBindStage, mLogger);
        when(mEntry.getKey()).thenReturn("key");
        when(mEntry.getRow()).thenReturn(mRow);
        when(mBindStage.getStageParams(eq(mEntry))).thenReturn(new RowContentBindParams());
+2 −38
Original line number Diff line number Diff line
@@ -162,42 +162,6 @@ public class NotificationContentInflaterTest extends SysuiTestCase {
                mock(NotificationRowContentBinderLogger.class));
    }

    @Test
    public void testIncreasedHeadsUpBeingUsed() {
        BindParams params = new BindParams(false, false, /* usesIncreasedHeadsUpHeight */ true,
                REDACTION_TYPE_NONE);
        Notification.Builder builder = spy(mBuilder);
        mNotificationInflater.inflateNotificationViews(
                mRow.getEntry(),
                mRow,
                params,
                true /* inflateSynchronously */,
                FLAG_CONTENT_VIEW_ALL,
                builder,
                mContext,
                mContext,
                mSmartReplyStateInflater);
        verify(builder).createHeadsUpContentView(true);
    }

    @Test
    public void testIncreasedHeightBeingUsed() {
        BindParams params = new BindParams(false, /* usesIncreasedHeight */ true, false,
                REDACTION_TYPE_NONE);
        Notification.Builder builder = spy(mBuilder);
        mNotificationInflater.inflateNotificationViews(
                mRow.getEntry(),
                mRow,
                params,
                true /* inflateSynchronously */,
                FLAG_CONTENT_VIEW_ALL,
                builder,
                mContext,
                mContext,
                mSmartReplyStateInflater);
        verify(builder).createContentView(true);
    }

    @Test
    public void testInflationCallsUpdated() throws Exception {
        inflateAndWait(mNotificationInflater, FLAG_CONTENT_VIEW_ALL, mRow);
@@ -238,7 +202,7 @@ public class NotificationContentInflaterTest extends SysuiTestCase {
                mRow.getEntry(),
                mRow,
                FLAG_CONTENT_VIEW_ALL,
                new BindParams(false, false, false, REDACTION_TYPE_NONE),
                new BindParams(false, REDACTION_TYPE_NONE),
                false /* forceInflate */,
                null /* callback */);
        Assert.assertNull(mRow.getEntry().getRunningTask());
@@ -576,7 +540,7 @@ public class NotificationContentInflaterTest extends SysuiTestCase {
                row.getEntry(),
                row,
                contentToInflate,
                new BindParams(false, false, false, redactionType),
                new BindParams(false, redactionType),
                false /* forceInflate */,
                callback /* callback */);
        assertTrue(countDownLatch.await(500, TimeUnit.MILLISECONDS));
+2 −39
Original line number Diff line number Diff line
@@ -143,43 +143,6 @@ class NotificationRowContentBinderImplTest : SysuiTestCase() {
            )
    }

    @Test
    fun testIncreasedHeadsUpBeingUsed() {
        val params =
            BindParams(false, false, /* usesIncreasedHeadsUpHeight */ true, REDACTION_TYPE_NONE)
        val builder = spy(builder)
        notificationInflater.inflateNotificationViews(
            row.entry,
            row,
            params,
            true, /* inflateSynchronously */
            FLAG_CONTENT_VIEW_ALL,
            builder,
            mContext,
            smartReplyStateInflater,
            mock(),
        )
        verify(builder).createHeadsUpContentView(true)
    }

    @Test
    fun testIncreasedHeightBeingUsed() {
        val params = BindParams(false, /* usesIncreasedHeight */ true, false, REDACTION_TYPE_NONE)
        val builder = spy(builder)
        notificationInflater.inflateNotificationViews(
            row.entry,
            row,
            params,
            true, /* inflateSynchronously */
            FLAG_CONTENT_VIEW_ALL,
            builder,
            mContext,
            smartReplyStateInflater,
            mock(),
        )
        verify(builder).createContentView(true)
    }

    @Test
    fun testInflationCallsUpdated() {
        inflateAndWait(notificationInflater, FLAG_CONTENT_VIEW_ALL, row)
@@ -226,7 +189,7 @@ class NotificationRowContentBinderImplTest : SysuiTestCase() {
            row.entry,
            row,
            FLAG_CONTENT_VIEW_ALL,
            BindParams(false, false, false, REDACTION_TYPE_NONE),
            BindParams(false, REDACTION_TYPE_NONE),
            false, /* forceInflate */
            null, /* callback */
        )
@@ -703,7 +666,7 @@ class NotificationRowContentBinderImplTest : SysuiTestCase() {
                row.entry,
                row,
                contentToInflate,
                BindParams(false, false, false, redactionType),
                BindParams(false, redactionType),
                false, /* forceInflate */
                callback, /* callback */
            )
+0 −48
Original line number Diff line number Diff line
@@ -213,54 +213,6 @@ public class RowContentBindStageTest extends SysuiTestCase {
        assertTrue(usedParams.isMinimized);
    }

    @Test
    public void testSetUseIncreasedHeight() {
        // GIVEN a view with all content bound.
        RowContentBindParams params = mRowContentBindStage.getStageParams(mEntry);
        params.requireContentViews(FLAG_CONTENT_VIEW_ALL);
        params.clearDirtyContentViews();

        // WHEN use increased height is set and stage executed.
        params.setUseIncreasedCollapsedHeight(true);
        mRowContentBindStage.executeStage(mEntry, mRow, (en) -> { });

        // THEN binder is called with group view and contracted is bound.
        ArgumentCaptor<BindParams> bindParamsCaptor = ArgumentCaptor.forClass(BindParams.class);
        verify(mBinder).bindContent(
                eq(mEntry),
                any(),
                eq(FLAG_CONTENT_VIEW_CONTRACTED),
                bindParamsCaptor.capture(),
                anyBoolean(),
                any());
        BindParams usedParams = bindParamsCaptor.getValue();
        assertTrue(usedParams.usesIncreasedHeight);
    }

    @Test
    public void testSetUseIncreasedHeadsUpHeight() {
        // GIVEN a view with all content bound.
        RowContentBindParams params = mRowContentBindStage.getStageParams(mEntry);
        params.requireContentViews(FLAG_CONTENT_VIEW_ALL);
        params.clearDirtyContentViews();

        // WHEN use increased heads up height is set and stage executed.
        params.setUseIncreasedHeadsUpHeight(true);
        mRowContentBindStage.executeStage(mEntry, mRow, (en) -> { });

        // THEN binder is called with use group view and heads up is bound.
        ArgumentCaptor<BindParams> bindParamsCaptor = ArgumentCaptor.forClass(BindParams.class);
        verify(mBinder).bindContent(
                eq(mEntry),
                any(),
                eq(FLAG_CONTENT_VIEW_HEADS_UP),
                bindParamsCaptor.capture(),
                anyBoolean(),
                any());
        BindParams usedParams = bindParamsCaptor.getValue();
        assertTrue(usedParams.usesIncreasedHeadsUpHeight);
    }

    @Test
    public void testSetNeedsReinflation() {
        // GIVEN a view with all content bound.
Loading