summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Gustav Sennton <gsennton@google.com> 2018-11-23 12:26:15 +0000
committer Gustav Sennton <gsennton@google.com> 2018-11-30 00:27:45 +0000
commitc98b163de0a35abb8b5de88b3e18db5ec56def59 (patch)
tree5c2f817dfd16e0ff760def084503f400d7df7f01
parent11cf88e2959b9c38a83d6d53d184a0474e2571f5 (diff)
Avoid NPE when adding a smart action with a null icon.
Bug: 119914388 Test: atest SmartReplyViewTest Change-Id: Idd7adce79b67d684b5d5c2fc0f183c9b36c336fe
-rw-r--r--core/java/android/app/Notification.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 5002a8125d44..16d35802a9f6 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1693,11 +1693,30 @@ public class Notification implements Parcelable
}
/**
+ * 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);