Set package name explicitly when sending copy intent

We broadcast an intent when starting the copy overlay, which is
received by the screenshot process so it knows to dismiss itself.
This causes a warning since sending non-protected broadcasts is
dangerous. Setting the package name explicitly lets
ActivityManagerService determine that the broadcast is safe since
it is only sent within SystemUI.

Bug: 219958007
Fix: 219958007
Test: manual (observed that error message no longer displayed when
copying something to the clipboard)

Change-Id: I1072bf7ebac9d8c761af01a5d888941f8ef24b79
This commit is contained in:
Miranda Kephart
2022-02-16 12:34:35 -05:00
parent f084f35b7a
commit 78262f7082

View File

@@ -219,7 +219,10 @@ public class ClipboardOverlayController {
SELF_PERMISSION, null);
monitorOutsideTouches();
mContext.sendBroadcast(new Intent(COPY_OVERLAY_ACTION), SELF_PERMISSION);
Intent copyIntent = new Intent(COPY_OVERLAY_ACTION);
// Set package name so the system knows it's safe
copyIntent.setPackage(mContext.getPackageName());
mContext.sendBroadcast(copyIntent, SELF_PERMISSION);
}
void setClipData(ClipData clipData, String clipSource) {