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

Commit c98b163d authored by Gustav Sennton's avatar Gustav Sennton
Browse files

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

Bug: 119914388
Test: atest SmartReplyViewTest
Change-Id: Idd7adce79b67d684b5d5c2fc0f183c9b36c336fe
parent 11cf88e2
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -1692,12 +1692,31 @@ public class Notification implements Parcelable
                return this;
                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}
             * Combine all of the options that have been set and return a new {@link Action}
             * object.
             * object.
             * @return the built action
             * @return the built action
             */
             */
            public Action build() {
            public Action build() {
                checkContextualActionNullFields();

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