summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Li <lihongyu@google.com> 2022-09-14 00:34:54 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-09-14 00:34:54 +0000
commit0d6c423cdcb058b154780e5933769e5bec6f7cf8 (patch)
tree6c05df848ea89b2660bf0eaca9fcd9ddc7f3c174
parent4ed8f88e278d137495cd88ff97d6917e7999cf3a (diff)
parent8624560d00c06cf37e1a138d9997479425d4d2b4 (diff)
Merge "Fix the problem that system apps cannot drag"
-rw-r--r--services/core/java/com/android/server/wm/Session.java11
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java6
2 files changed, 4 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 30b50839cd35..c5f21eb0ef5f 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -322,7 +322,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,
@@ -347,11 +347,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");
@@ -365,9 +361,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;
diff --git a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
index 28fc352e2f74..4526d18d63d8 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
@@ -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");