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

Commit 68f90f60 authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

Merge "Fix the problem that system apps cannot drag" am: 0d6c423c am:...

Merge "Fix the problem that system apps cannot drag" am: 0d6c423c am: f2633cb7 am: a78c925c am: 53038bd2 am: a1107255

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2210995



Change-Id: Idbc6e8dab8debf8c9a38ef62b7c946d1ff7a5e27
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents d5d20e06 a1107255
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
        final int callingPid = Binder.getCallingPid();
        // Validate and resolve ClipDescription data before clearing the calling identity
        validateAndResolveDragMimeTypeExtras(data, callingUid, callingPid, mPackageName);
        validateDragFlags(flags, callingUid);
        validateDragFlags(flags);
        final long ident = Binder.clearCallingIdentity();
        try {
            return mDragDropController.performDrag(mPid, mUid, window, flags, surface, touchSource,
@@ -349,11 +349,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
     * Validates the given drag flags.
     */
    @VisibleForTesting
    void validateDragFlags(int flags, int callingUid) {
        if (callingUid == Process.SYSTEM_UID) {
            throw new IllegalStateException("Need to validate before calling identify is cleared");
        }

    void validateDragFlags(int flags) {
        if ((flags & View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION) != 0) {
            if (!mCanStartTasksFromRecents) {
                throw new SecurityException("Requires START_TASKS_FROM_RECENTS permission");
@@ -367,9 +363,6 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
    @VisibleForTesting
    void validateAndResolveDragMimeTypeExtras(ClipData data, int callingUid, int callingPid,
            String callingPackage) {
        if (callingUid == Process.SYSTEM_UID) {
            throw new IllegalStateException("Need to validate before calling identify is cleared");
        }
        final ClipDescription desc = data != null ? data.getDescription() : null;
        if (desc == null) {
            return;
+2 −4
Original line number Diff line number Diff line
@@ -467,8 +467,7 @@ public class DragDropControllerTests extends WindowTestsBase {
            public void onAnimatorScaleChanged(float scale) {}
        });
        try {
            session.validateDragFlags(View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION,
                    TEST_UID);
            session.validateDragFlags(View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION);
            fail("Expected failure without permission");
        } catch (SecurityException e) {
            // Expected failure
@@ -484,8 +483,7 @@ public class DragDropControllerTests extends WindowTestsBase {
            public void onAnimatorScaleChanged(float scale) {}
        });
        try {
            session.validateDragFlags(View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION,
                    TEST_UID);
            session.validateDragFlags(View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION);
            // Expected pass
        } catch (SecurityException e) {
            fail("Expected no failure with permission");