diff options
| author | 2020-05-14 06:15:59 +0000 | |
|---|---|---|
| committer | 2020-05-15 07:24:11 +0000 | |
| commit | fa23f600c6625c5eb16cd583daea0df7ebae9faf (patch) | |
| tree | f99fcf969ac2efe3a507e5cfee078ebea82f5b96 | |
| parent | 54dd86ac12b6d812c792da14160eb2ab7327aa45 (diff) | |
Report resizeTask failure as boolean result
Previously ActivityTaskManagerService#resizeTask throws
IllegalArgumentException when the task windowing mode is not suitable for
resize. However caller cannot ensure the windowing mode before
acquiring window lock.
To descriminate windowing mode mismatch from programming errors
(e.g. Preconditions.check failures), the CL changes the way of reporting
windowing mode mismatch to returning boolean value.
Bug: 156196109
Test: None
Change-Id: I36f473899c4f6d7f5d5d25f081a57fe14ebbb1a8
| -rw-r--r-- | core/java/android/app/IActivityTaskManager.aidl | 11 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityTaskManagerService.java | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl index 3ce768944e48..be1681bc7cc6 100644 --- a/core/java/android/app/IActivityTaskManager.aidl +++ b/core/java/android/app/IActivityTaskManager.aidl @@ -229,7 +229,16 @@ interface IActivityTaskManager { void unregisterTaskStackListener(in ITaskStackListener listener); void setTaskResizeable(int taskId, int resizeableMode); void toggleFreeformWindowingMode(in IBinder token); - void resizeTask(int taskId, in Rect bounds, int resizeMode); + + /** + * Resize the task with given bounds + * + * @param taskId The id of the task to set the bounds for. + * @param bounds The new bounds. + * @param resizeMode Resize mode defined as {@code ActivityTaskManager#RESIZE_MODE_*} constants. + * @return Return true on success. Otherwise false. + */ + boolean resizeTask(int taskId, in Rect bounds, int resizeMode); void moveStackToDisplay(int stackId, int displayId); void removeStack(int stackId); diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 78e4237eb4a7..fdbb2b25bd39 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -3319,7 +3319,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } @Override - public void resizeTask(int taskId, Rect bounds, int resizeMode) { + public boolean resizeTask(int taskId, Rect bounds, int resizeMode) { mAmInternal.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "resizeTask()"); long ident = Binder.clearCallingIdentity(); try { @@ -3328,10 +3328,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { MATCH_TASK_IN_STACKS_ONLY); if (task == null) { Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found"); - return; + return false; } if (!task.getWindowConfiguration().canResizeTask()) { - throw new IllegalArgumentException("resizeTask not allowed on task=" + task); + Slog.w(TAG, "resizeTask not allowed on task=" + task); + return false; } // Reparent the task to the right stack if necessary @@ -3339,7 +3340,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // After reparenting (which only resizes the task to the stack bounds), resize the // task to the actual bounds provided - task.resize(bounds, resizeMode, preserveWindow); + return task.resize(bounds, resizeMode, preserveWindow); } } finally { Binder.restoreCallingIdentity(ident); |