From 8770248f7796a78c93f2a5f13cb9831856978f5b Mon Sep 17 00:00:00 2001 From: Daichi Hirono Date: Wed, 24 Feb 2021 09:43:09 +0900 Subject: [PATCH] Change deleteRootTasks so that it returns false instead of exception Before the CL deleteRootTasks throws a RuntimeException when a specified task has already been GCed. Callers of this API don't have a way of guaranteeing the existance of task in the system server process, so they need to catch the excpetions always, which resulted in hiding other RuntimeException potentially caused by programming errors. Because missing tasks is not a programming error, this CL changes the exception to a false return value. Bug: 179324112 Test: None Change-Id: I335c43954d467a6bc99c2c958c54a76a48fd2ac9 --- .../java/com/android/server/wm/TaskOrganizerController.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/TaskOrganizerController.java b/services/core/java/com/android/server/wm/TaskOrganizerController.java index c0bce6be8c544..1531e56bf4909 100644 --- a/services/core/java/com/android/server/wm/TaskOrganizerController.java +++ b/services/core/java/com/android/server/wm/TaskOrganizerController.java @@ -596,9 +596,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub { try { synchronized (mGlobalLock) { final WindowContainer wc = WindowContainer.fromBinder(token.asBinder()); - if (wc == null) { - throw new IllegalArgumentException("Can't resolve window from token"); - } + if (wc == null) return false; final Task task = wc.asTask(); if (task == null) return false; if (!task.mCreatedByOrganizer) {