From c32dc80a907ebe33a946b7bb9e56baa3d7778281 Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Mon, 20 Mar 2023 16:45:11 -0400 Subject: [PATCH] Register clipboard toast callback correctly If something is copied to the clipboard before user setup is complete, we just show a toast instead of the full UI, to prevent the user from being able to access intents they shouldn't be able to. In this case, we have a callback to reset the internal variable when the toast is hidden, but we never actually register the callback. This has very little effect in practice, since a) all of this code is only run if user setup is incomplete (or if the copied data is null, which shouldn't happen) and b) the incorrect state, where we should show the toast and don't, will only occur if we somehow get the second, post-text-classification clipboard update without getting the initial update. That said, this should still be fixed for clarity and correctness. This change registers the callback so that we reset the clipboard toast to null once it's hidden. Bug: 272035606 Test: manual Change-Id: I4bcc3bd85f6242ff4815c21d5a6a7f9d24045cd5 --- .../com/android/systemui/clipboardoverlay/ClipboardToast.java | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardToast.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardToast.java index 0ed7d2711c622..e9daa462c0229 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardToast.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardToast.java @@ -41,6 +41,7 @@ class ClipboardToast extends Toast.Callback { } mCopiedToast = Toast.makeText(mContext, R.string.clipboard_overlay_text_copied, Toast.LENGTH_SHORT); + mCopiedToast.addCallback(this); mCopiedToast.show(); }