From a42f760f264bbbfa8f03a1bd553202631c1fa986 Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Thu, 10 Feb 2022 10:53:26 -0500 Subject: [PATCH] Add null check when checking clipboard actions package If a RemoteAction returned through TextClassifier does not have a ComponentName set, it will cause an NPE. This change adds a null check to forestall that (and just doesn't show a chip if there's no ComponentName). Bug: 218458652 Test: manual (force-set component to null and checked that error occurred before but not after fix) Change-Id: Ia17e2375f8a31b44de51e3cfb0dafc8c1dff1ad2 --- .../systemui/clipboardoverlay/ClipboardOverlayController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java index f6d64643b3cd6..07233888d459f 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java @@ -252,7 +252,8 @@ public class ClipboardOverlayController { resetActionChips(); for (RemoteAction action : actions) { Intent targetIntent = action.getActionIntent().getIntent(); - if (!TextUtils.equals(source, targetIntent.getComponent().getPackageName())) { + ComponentName component = targetIntent.getComponent(); + if (component != null && !TextUtils.equals(source, component.getPackageName())) { OverlayActionChip chip = constructActionChip(action); mActionContainer.addView(chip); mActionChips.add(chip);