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

Commit 0eca3fe5 authored by Gustav Sennton's avatar Gustav Sennton Committed by Android (Google) Code Review
Browse files

Merge "Avoid NPE when adding a smart action with a null icon."

parents 4e0a3ffa c98b163d
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -1692,12 +1692,31 @@ public class Notification implements Parcelable
                return this;
            }

            /**
             * Throws an NPE if we are building a contextual action missing one of the fields
             * necessary to display the action.
             */
            private void checkContextualActionNullFields() {
                if (mSemanticAction != SEMANTIC_ACTION_CONTEXTUAL_SUGGESTION) return;

                if (mIcon == null) {
                    throw new NullPointerException("Contextual Actions must contain a valid icon");
                }

                if (mIntent == null) {
                    throw new NullPointerException(
                            "Contextual Actions must contain a valid PendingIntent");
                }
            }

            /**
             * Combine all of the options that have been set and return a new {@link Action}
             * object.
             * @return the built action
             */
            public Action build() {
                checkContextualActionNullFields();

                ArrayList<RemoteInput> dataOnlyInputs = new ArrayList<>();
                RemoteInput[] previousDataInputs =
                    (RemoteInput[]) mExtras.getParcelableArray(EXTRA_DATA_ONLY_INPUTS);