Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd175fe8 authored by Chad Brubaker's avatar Chad Brubaker
Browse files

Allow Shell to access the clipboard

A lot of CTS tests involve the clipboard and making all of them input
focus is somewhat wasteful and invasive, instead we will adopt the
shell's permissions when relevant.

Test: atest ClipboardManagerTest
Bug: 6229949
Change-Id: I10f07e89b0baead625464c2afd5da1e229a45473
parent 1ec3af05
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4147,6 +4147,11 @@
    <permission android:name="android.permission.BIND_SMS_APP_SERVICE"
        android:protectionLevel="signature" />

    <!-- @hide Permission that allows background clipboard access.
         <p>Not for use by third-party applications. -->
    <permission android:name="android.permission.READ_CLIPBOARD_IN_BACKGROUND"
        android:protectionLevel="signature" />

    <application android:process="system"
                 android:persistent="true"
                 android:hasCode="false"
+1 −0
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@

    <uses-permission android:name="android.permission.CONTROL_KEYGUARD" />
    <uses-permission android:name="android.permission.SUSPEND_APPS" />
    <uses-permission android:name="android.permission.READ_CLIPBOARD_IN_BACKGROUND" />

    <application android:label="@string/app_label"
                 android:defaultToDeviceProtectedStorage="true"
+5 −0
Original line number Diff line number Diff line
@@ -629,6 +629,11 @@ public class ClipboardService extends SystemService {
        if (mAppOps.noteOp(op, callingUid, callingPackage) != AppOpsManager.MODE_ALLOWED) {
            return false;
        }
        // Shell can access the clipboard for testing purposes.
        if (mPm.checkPermission(android.Manifest.permission.READ_CLIPBOARD_IN_BACKGROUND,
                    callingPackage) == PackageManager.PERMISSION_GRANTED) {
            return true;
        }
        // The default IME is always allowed to access the clipboard.
        String defaultIme = Settings.Secure.getStringForUser(getContext().getContentResolver(),
                Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.getUserId(callingUid));