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

Commit f1939901 authored by Nicolas Prevot's avatar Nicolas Prevot Committed by Nicolas Prévot
Browse files

Making the clipboard work across users.

When copying from the parent: the ClipData can be pasted in the managed profile.
When copying from a managed profile: it can be pasted in the parent,
unless the policies says it's disabled. In which case, the clipboard of the parent becomes empty.
Supporting content uris.

BUG: 15186236

Change-Id: I522564a7c07ff21df137adcda980bb52e5739964
parent 3ea4310a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22731,6 +22731,7 @@ package android.os {
    field public static final java.lang.String DISALLOW_CONFIG_VPN = "no_config_vpn";
    field public static final java.lang.String DISALLOW_CONFIG_WIFI = "no_config_wifi";
    field public static final java.lang.String DISALLOW_CREATE_WINDOWS = "no_create_windows";
    field public static final java.lang.String DISALLOW_CROSS_PROFILE_COPY_PASTE = "no_cross_profile_copy_paste";
    field public static final java.lang.String DISALLOW_DEBUGGING_FEATURES = "no_debugging_features";
    field public static final java.lang.String DISALLOW_FACTORY_RESET = "no_factory_reset";
    field public static final java.lang.String DISALLOW_INSTALL_APPS = "no_install_apps";
+7 −4
Original line number Diff line number Diff line
@@ -1661,8 +1661,10 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            String targetPkg = data.readString();
            Uri uri = Uri.CREATOR.createFromParcel(data);
            int mode = data.readInt();
            int userId = data.readInt();
            grantUriPermissionFromOwner(owner, fromUid, targetPkg, uri, mode, userId);
            int sourceUserId = data.readInt();
            int targetUserId = data.readInt();
            grantUriPermissionFromOwner(owner, fromUid, targetPkg, uri, mode, sourceUserId,
                    targetUserId);
            reply.writeNoException();
            return true;
        }
@@ -4343,7 +4345,7 @@ class ActivityManagerProxy implements IActivityManager
    }

    public void grantUriPermissionFromOwner(IBinder owner, int fromUid, String targetPkg,
            Uri uri, int mode, int userId) throws RemoteException {
            Uri uri, int mode, int sourceUserId, int targetUserId) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
@@ -4352,7 +4354,8 @@ class ActivityManagerProxy implements IActivityManager
        data.writeString(targetPkg);
        uri.writeToParcel(data, 0);
        data.writeInt(mode);
        data.writeInt(userId);
        data.writeInt(sourceUserId);
        data.writeInt(targetUserId);
        mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
+1 −1
Original line number Diff line number Diff line
@@ -332,7 +332,7 @@ public interface IActivityManager extends IInterface {

    public IBinder newUriPermissionOwner(String name) throws RemoteException;
    public void grantUriPermissionFromOwner(IBinder owner, int fromUid, String targetPkg,
            Uri uri, int mode, int userId) throws RemoteException;
            Uri uri, int mode, int sourceUserId, int targetUserId) throws RemoteException;
    public void revokeUriPermissionFromOwner(IBinder owner, Uri uri,
            int mode, int userId) throws RemoteException;

+20 −0
Original line number Diff line number Diff line
@@ -828,6 +828,26 @@ public class ClipData implements Parcelable {
        }
    }

    /**
     * Only fixing the data field of the intents
     * @hide
     */
    public void fixUrisLight(int contentUserHint) {
        final int size = mItems.size();
        for (int i = 0; i < size; i++) {
            final Item item = mItems.get(i);
            if (item.mIntent != null) {
                Uri data = item.mIntent.getData();
                if (data != null) {
                    item.mIntent.setData(maybeAddUserId(data, contentUserHint));
                }
            }
            if (item.mUri != null) {
                item.mUri = maybeAddUserId(item.mUri, contentUserHint);
            }
        }
    }

    @Override
    public String toString() {
        StringBuilder b = new StringBuilder(128);
+12 −0
Original line number Diff line number Diff line
@@ -310,6 +310,18 @@ public class UserManager {
     */
    public static final String DISALLOW_CREATE_WINDOWS = "no_create_windows";

    /**
     * Key for user restrictions. Specifies if what is copied in the clipboard of this profile can
     * be pasted in related profiles. Does not restrict if the clipboard of related profiles can be
     * pasted in this profile.
     * The default value is <code>false</code>.
     * <p/>
     * Type: Boolean
     * @see #setUserRestrictions(Bundle)
     * @see #getUserRestrictions()
     */
    public static final String DISALLOW_CROSS_PROFILE_COPY_PASTE = "no_cross_profile_copy_paste";

    /** @hide */
    public static final int PIN_VERIFICATION_FAILED_INCORRECT = -3;
    /** @hide */
Loading