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

Commit f9d779d5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow apps to write to the clipboard without input focus"

parents 3b000ab0 92e0291f
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -95,9 +95,6 @@ public class ClipboardManager extends android.text.ClipboardManager {
     * Sets the current primary clip on the clipboard.  This is the clip that
     * is involved in normal cut and paste operations.
     *
     * <em>If the application is not the default IME or does not have input focus this will have
     * no effect.</em>
     *
     * @param clip The clipped data item to set.
     * @see #getPrimaryClip()
     * @see #clearPrimaryClip()
@@ -115,9 +112,6 @@ public class ClipboardManager extends android.text.ClipboardManager {
    /**
     * Clears any current primary clip on the clipboard.
     *
     * <em>If the application is not the default IME or does not have input focus this will have
     * no effect.</em>
     *
     * @see #setPrimaryClip(ClipData)
     */
    public void clearPrimaryClip() {
+14 −6
Original line number Diff line number Diff line
@@ -639,12 +639,20 @@ public class ClipboardService extends SystemService {
            }
        }

        // Otherwise only focused applications can access the clipboard.
        switch (op) {
            case AppOpsManager.OP_READ_CLIPBOARD:
                // Clipboard can only be read by applications with focus.
                boolean uidFocused = mWm.isUidFocused(callingUid);
                if (!uidFocused) {
                    Slog.e(TAG, "Denying clipboard access to " + callingPackage
                            + ", application is not in focus.");
                }
                return uidFocused;
            case AppOpsManager.OP_WRITE_CLIPBOARD:
                // Writing is allowed without focus.
                return true;
            default:
                throw new IllegalArgumentException("Unknown clipboard appop " + op);
        }
    }
}