Return non-null empty list if the controller is already invalidated

- In the off chance that the controller is already invalidated (due to
  service reconnection to launcher for example), then any calls through
  the previous binder should just return an empty task list.

Bug: 206648922
Test: Manual (haven't been able to repro)
Change-Id: Iff6193fa89c2baecc527e589f17ae41b82575a48
This commit is contained in:
Winson Chung
2022-01-11 19:57:26 +00:00
parent 5a1d0103e4
commit d0823fc830

View File

@@ -292,7 +292,6 @@ public class RecentTasksController implements TaskStackListenerCallback,
* Invalidates this instance, preventing future calls from updating the controller.
*/
void invalidate() {
Slog.d("b/206648922", "invalidating controller: " + mController);
mController = null;
}
@@ -313,13 +312,16 @@ public class RecentTasksController implements TaskStackListenerCallback,
@Override
public GroupedRecentTaskInfo[] getRecentTasks(int maxNum, int flags, int userId)
throws RemoteException {
if (mController == null) {
// The controller is already invalidated -- just return an empty task list for now
return new GroupedRecentTaskInfo[0];
}
final GroupedRecentTaskInfo[][] out = new GroupedRecentTaskInfo[][]{null};
executeRemoteCallWithTaskPermission(mController, "getRecentTasks",
(controller) -> out[0] = controller.getRecentTasks(maxNum, flags, userId)
.toArray(new GroupedRecentTaskInfo[0]),
true /* blocking */);
Slog.d("b/206648922", "getRecentTasks(" + maxNum + "): " + out[0]
+ " mController=" + mController);
return out[0];
}
}