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

Commit 91be2b5c authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Validate custom message nullability

Bug: 267577241
Test: atest MediaRouter2HostTest
Change-Id: Ifb9767a8e1c3d35413ed5568e96e67ecfbde2453
parent 4f827d33
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -345,6 +345,7 @@ public final class RouteListingPreference implements Parcelable {
            mFlags = builder.mFlags;
            mSubText = builder.mSubText;
            mCustomSubtextMessage = builder.mCustomSubtextMessage;
            validateCustomMessageSubtext();
        }

        private Item(Parcel in) {
@@ -354,6 +355,7 @@ public final class RouteListingPreference implements Parcelable {
            mFlags = in.readInt();
            mSubText = in.readInt();
            mCustomSubtextMessage = in.readCharSequence();
            validateCustomMessageSubtext();
        }

        /**
@@ -467,6 +469,16 @@ public final class RouteListingPreference implements Parcelable {
                    mRouteId, mSelectionBehavior, mFlags, mSubText, mCustomSubtextMessage);
        }

        // Internal methods.

        private void validateCustomMessageSubtext() {
            Preconditions.checkArgument(
                    mSubText != SUBTEXT_CUSTOM || mCustomSubtextMessage != null,
                    "The custom subtext message cannot be null if subtext is SUBTEXT_CUSTOM.");
        }

        // Internal classes.

        /** Builder for {@link Item}. */
        public static final class Builder {