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

Commit 56bd6c65 authored by Alexander Roederer's avatar Alexander Roederer Committed by Android (Google) Code Review
Browse files

Merge "Cleanup BUILDER_EXTRAS_OVERRIDE" into main

parents b4f5de0f 5ad55fba
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -7155,13 +7155,7 @@ public class Notification implements Parcelable
            // Adds any new extras provided by the user.
            if (mUserExtras != null) {
                final Bundle saveExtras = (Bundle) mUserExtras.clone();
                if (SystemProperties.getBoolean(
                        "persist.sysui.notification.builder_extras_override", false)) {
                mN.extras.putAll(saveExtras);
                } else {
                    saveExtras.putAll(mN.extras);
                    mN.extras = saveExtras;
                }
            }
            if (!Flags.sortSectionByTime()) {
+0 −64
Original line number Diff line number Diff line
@@ -84,7 +84,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemProperties;
import android.platform.test.annotations.Presubmit;
import android.platform.test.flag.junit.SetFlagsRule;
import android.text.Spannable;
@@ -132,9 +131,6 @@ public class NotificationTest {
    @Before
    public void setUp() {
        mContext = InstrumentationRegistry.getContext();
        // TODO(b/169435530): remove this flag set once resolved.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(false));
    }

    @Test
@@ -1703,10 +1699,6 @@ public class NotificationTest {
    // Ensures that extras in a Notification Builder can be updated.
    @Test
    public void testExtras_cachedExtrasOverwrittenByUserProvided() {
        // Sets the flag to new state.
        // TODO(b/169435530): remove this set value once resolved.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(true));
        Bundle extras = new Bundle();
        extras.putCharSequence(EXTRA_TITLE, "test title");
        extras.putCharSequence(EXTRA_SUMMARY_TEXT, "summary text");
@@ -1732,10 +1724,6 @@ public class NotificationTest {
    // Ensures that extras in a Notification Builder can be updated by an extender.
    @Test
    public void testExtras_cachedExtrasOverwrittenByExtender() {
        // Sets the flag to new state.
        // TODO(b/169435530): remove this set value once resolved.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(true));
        Notification.CarExtender extender = new Notification.CarExtender().setColor(1234);

        Notification notification = new Notification.Builder(mContext, "test id")
@@ -1749,58 +1737,6 @@ public class NotificationTest {
        assertThat(recoveredExtender.getColor()).isEqualTo(5678);
    }

    // Validates pre-flag flip behavior, that extras in a Notification Builder cannot be updated.
    // TODO(b/169435530): remove this test once resolved.
    @Test
    public void testExtras_cachedExtrasOverwrittenByUserProvidedOld() {
        // Sets the flag to old state.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(false));

        Bundle extras = new Bundle();
        extras.putCharSequence(EXTRA_TITLE, "test title");
        extras.putCharSequence(EXTRA_SUMMARY_TEXT, "summary text");

        Notification.Builder builder = new Notification.Builder(mContext, "test id")
                .addExtras(extras);

        Notification notification = builder.build();
        assertThat(notification.extras.getCharSequence(EXTRA_TITLE).toString()).isEqualTo(
                "test title");
        assertThat(notification.extras.getCharSequence(EXTRA_SUMMARY_TEXT).toString()).isEqualTo(
                "summary text");

        extras.putCharSequence(EXTRA_TITLE, "new title");
        builder.addExtras(extras);
        notification = builder.build();
        assertThat(notification.extras.getCharSequence(EXTRA_TITLE).toString()).isEqualTo(
                "test title");
        assertThat(notification.extras.getCharSequence(EXTRA_SUMMARY_TEXT).toString()).isEqualTo(
                "summary text");
    }

    // Validates pre-flag flip behavior, that extras in a Notification Builder cannot be updated
    // by an extender.
    // TODO(b/169435530): remove this test once resolved.
    @Test
    public void testExtras_cachedExtrasOverwrittenByExtenderOld() {
        // Sets the flag to old state.
        SystemProperties.set("persist.sysui.notification.builder_extras_override",
                Boolean.toString(false));

        Notification.CarExtender extender = new Notification.CarExtender().setColor(1234);

        Notification notification = new Notification.Builder(mContext, "test id")
                .extend(extender).build();

        extender.setColor(5678);

        Notification.Builder.recoverBuilder(mContext, notification).extend(extender).build();

        Notification.CarExtender recoveredExtender = new Notification.CarExtender(notification);
        assertThat(recoveredExtender.getColor()).isEqualTo(1234);
    }

    @Test
    @CoreCompatChangeRule.EnableCompatChanges({Notification.WEARABLE_EXTENDER_BACKGROUND_BLOCKED})
    public void wearableBackgroundBlockEnabled_wearableBackgroundSet_valueRemainsNull() {