Merge "Add null check before notifying CUJ events" into sc-v2-dev am: 60316d327f am: 12b1a2ef2e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16221675
Change-Id: I545d7f82708ae23f89f93284066290201af28367
diff --git a/core/java/com/android/internal/jank/InteractionJankMonitor.java b/core/java/com/android/internal/jank/InteractionJankMonitor.java
index 0ba5a39..ea38db3 100644
--- a/core/java/com/android/internal/jank/InteractionJankMonitor.java
+++ b/core/java/com/android/internal/jank/InteractionJankMonitor.java
@@ -377,7 +377,13 @@
// Notify the receivers if necessary.
if (session.shouldNotify()) {
- notifyEvents(context, action, session);
+ if (context != null) {
+ notifyEvents(context, action, session);
+ } else {
+ throw new IllegalArgumentException(
+ "Can't notify cuj events due to lack of context: cuj="
+ + session.getName() + ", action=" + action);
+ }
}
}
@@ -739,7 +745,8 @@
* @return builder
*/
public static Builder withView(@CujType int cuj, @NonNull View view) {
- return new Builder(cuj).setView(view);
+ return new Builder(cuj).setView(view)
+ .setContext(view.getContext());
}
private Builder(@CujType int cuj) {