Add SET_CLIP_SOURCE permission.

This adds a permission that allows the holder to provide the source
package when setting the primary clip in clipboard. This will be done
using a new system API.

This is needed to ensure that the clipboard access notifications can be
properly attributed. For example, when a copy is performed through the
share sheet, the data should be attributed to the app that opened the
share sheet, not Android System.

Bug: 180577866
Test: builds
Change-Id: If3193d476fa923b849b505ad8b6dd893a2feae8f
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 51aacc7..1d20051 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -247,6 +247,7 @@
     field public static final String SEND_SMS_NO_CONFIRMATION = "android.permission.SEND_SMS_NO_CONFIRMATION";
     field public static final String SERIAL_PORT = "android.permission.SERIAL_PORT";
     field public static final String SET_ACTIVITY_WATCHER = "android.permission.SET_ACTIVITY_WATCHER";
+    field public static final String SET_CLIP_SOURCE = "android.permission.SET_CLIP_SOURCE";
     field public static final String SET_HARMFUL_APP_WARNINGS = "android.permission.SET_HARMFUL_APP_WARNINGS";
     field public static final String SET_MEDIA_KEY_LISTENER = "android.permission.SET_MEDIA_KEY_LISTENER";
     field public static final String SET_ORIENTATION = "android.permission.SET_ORIENTATION";
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 4bbb69f..19f1f03 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -5566,6 +5566,12 @@
     <permission android:name="android.permission.RENOUNCE_PERMISSIONS"
                 android:protectionLevel="signature|privileged" />
 
+    <!-- @SystemApi Allows the holder to set the source of the data when setting a clip on the
+         clipboard.
+         @hide -->
+    <permission android:name="android.permission.SET_CLIP_SOURCE"
+                android:protectionLevel="signature|recents" />
+
     <!-- Attribution for Geofencing service. -->
     <attribution android:tag="GeofencingService" android:label="@string/geofencing_service"/>
     <!-- Attribution for Country Detector. -->
diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml
index fae89d6..c49fe85 100644
--- a/data/etc/privapp-permissions-platform.xml
+++ b/data/etc/privapp-permissions-platform.xml
@@ -486,6 +486,8 @@
         <permission name="android.permission.READ_PEOPLE_DATA" />
         <!-- Permission required for CTS test - UiTranslationManagerTest -->
         <permission name="android.permission.MANAGE_UI_TRANSLATION" />
+        <!-- Permission required for CTS test - ClipboardManagerTest -->
+        <permission name="android.permission.SET_CLIP_SOURCE" />
     </privapp-permissions>
 
     <privapp-permissions package="com.android.statementservice">
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 0687191..eed1c69 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -421,6 +421,9 @@
     <!-- Permission required for CTS test - CtsGameManagerTestCases -->
     <uses-permission android:name="android.permission.MANAGE_GAME_MODE" />
 
+    <!-- Permission required for CTS test - ClipboardManagerTest -->
+    <uses-permission android:name="android.permission.SET_CLIP_SOURCE" />
+
     <application android:label="@string/app_label"
                 android:theme="@android:style/Theme.DeviceDefault.DayNight"
                 android:defaultToDeviceProtectedStorage="true"