Merge "Fix the problem that system apps cannot drag" am: 0d6c423cdc am: f2633cb71c am: a78c925ca8 am: 53038bd27a

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

Change-Id: I7b5d4f6c85df20cfe1fbfcd3d6ac8c2c513857b8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chris Li
2022-09-14 03:05:52 +00:00
committed by Automerger Merge Worker
2 changed files with 4 additions and 13 deletions

View File

@@ -324,7 +324,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
final int callingPid = Binder.getCallingPid(); final int callingPid = Binder.getCallingPid();
// Validate and resolve ClipDescription data before clearing the calling identity // Validate and resolve ClipDescription data before clearing the calling identity
validateAndResolveDragMimeTypeExtras(data, callingUid, callingPid, mPackageName); validateAndResolveDragMimeTypeExtras(data, callingUid, callingPid, mPackageName);
validateDragFlags(flags, callingUid); validateDragFlags(flags);
final long ident = Binder.clearCallingIdentity(); final long ident = Binder.clearCallingIdentity();
try { try {
return mDragDropController.performDrag(mPid, mUid, window, flags, surface, touchSource, 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. * Validates the given drag flags.
*/ */
@VisibleForTesting @VisibleForTesting
void validateDragFlags(int flags, int callingUid) { void validateDragFlags(int flags) {
if (callingUid == Process.SYSTEM_UID) {
throw new IllegalStateException("Need to validate before calling identify is cleared");
}
if ((flags & View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION) != 0) { if ((flags & View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION) != 0) {
if (!mCanStartTasksFromRecents) { if (!mCanStartTasksFromRecents) {
throw new SecurityException("Requires START_TASKS_FROM_RECENTS permission"); throw new SecurityException("Requires START_TASKS_FROM_RECENTS permission");
@@ -367,9 +363,6 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
@VisibleForTesting @VisibleForTesting
void validateAndResolveDragMimeTypeExtras(ClipData data, int callingUid, int callingPid, void validateAndResolveDragMimeTypeExtras(ClipData data, int callingUid, int callingPid,
String callingPackage) { 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; final ClipDescription desc = data != null ? data.getDescription() : null;
if (desc == null) { if (desc == null) {
return; return;

View File

@@ -467,8 +467,7 @@ public class DragDropControllerTests extends WindowTestsBase {
public void onAnimatorScaleChanged(float scale) {} public void onAnimatorScaleChanged(float scale) {}
}); });
try { try {
session.validateDragFlags(View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION, session.validateDragFlags(View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION);
TEST_UID);
fail("Expected failure without permission"); fail("Expected failure without permission");
} catch (SecurityException e) { } catch (SecurityException e) {
// Expected failure // Expected failure
@@ -484,8 +483,7 @@ public class DragDropControllerTests extends WindowTestsBase {
public void onAnimatorScaleChanged(float scale) {} public void onAnimatorScaleChanged(float scale) {}
}); });
try { try {
session.validateDragFlags(View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION, session.validateDragFlags(View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION);
TEST_UID);
// Expected pass // Expected pass
} catch (SecurityException e) { } catch (SecurityException e) {
fail("Expected no failure with permission"); fail("Expected no failure with permission");