Merge "Prevent NPE when checking focused stage before root task is ready" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-09-07 03:35:16 +00:00
committed by Android (Google) Code Review

View File

@@ -113,10 +113,20 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
/** @return {@code true} if this listener contains the currently focused task. */
boolean isFocused() {
if (mRootTaskInfo.isFocused) return true;
for (int i = mChildrenTaskInfo.size() - 1; i >= 0; --i) {
if (mChildrenTaskInfo.valueAt(i).isFocused) return true;
if (mRootTaskInfo == null) {
return false;
}
if (mRootTaskInfo.isFocused) {
return true;
}
for (int i = mChildrenTaskInfo.size() - 1; i >= 0; --i) {
if (mChildrenTaskInfo.valueAt(i).isFocused) {
return true;
}
}
return false;
}