Add clipboard toast suppression permission.

Grant that permission to SystemUI so that the clipboard overlay doesn't
generate a toast.

Test: Manual verification that toast is suppressed only after sysui
      requests the permission.
Test: atest ClipboardManagerTest
Bug: 216143343

Change-Id: Ia527a5d878f026b7939042b4b675037482846fbb
This commit is contained in:
Matt Casey
2022-01-28 16:12:46 -05:00
parent c1e962bc8d
commit 07a3663d96
3 changed files with 9 additions and 0 deletions

View File

@@ -5923,6 +5923,10 @@
<p>Not for use by third-party applications. -->
<permission android:name="android.permission.READ_CLIPBOARD_IN_BACKGROUND"
android:protectionLevel="signature" />
<!-- @hide Permission that suppresses the notification when the clipboard is accessed.
<p>Not for use by third-party applications. -->
<permission android:name="android.permission.SUPPRESS_CLIPBOARD_ACCESS_NOTIFICATION"
android:protectionLevel="signature" />
<!-- @SystemApi Allows modifying accessibility state.
@hide -->

View File

@@ -308,6 +308,7 @@
<!-- To change system language (HDMI CEC) -->
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.SUPPRESS_CLIPBOARD_ACCESS_NOTIFICATION" />
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />

View File

@@ -1090,6 +1090,10 @@ public class ClipboardService extends SystemService {
&& mAutofillInternal.isAugmentedAutofillServiceForUser(uid, userId)) {
return;
}
if (mPm.checkPermission(Manifest.permission.SUPPRESS_CLIPBOARD_ACCESS_NOTIFICATION,
callingPackage) == PackageManager.PERMISSION_GRANTED) {
return;
}
// Don't notify if already notified for this uid and clip.
if (clipboard.mNotifiedUids.get(uid)) {
return;