Merge "Add null check before notifying CUJ events" into sc-v2-dev am: 60316d327f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16221675

Change-Id: I406eee540d6fa8e36f5975ef39ee8228e47e2322
This commit is contained in:
Wu Ahan
2021-11-13 04:50:51 +00:00
committed by Automerger Merge Worker

View File

@@ -377,7 +377,13 @@ public class InteractionJankMonitor {
// Notify the receivers if necessary. // Notify the receivers if necessary.
if (session.shouldNotify()) { 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 @@ public class InteractionJankMonitor {
* @return builder * @return builder
*/ */
public static Builder withView(@CujType int cuj, @NonNull View view) { 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) { private Builder(@CujType int cuj) {