Prevent NPE when checking focused stage before root task is ready
If the root task of the stage is not created, treat the stage as not focused to prevent trowing NPE when traversing the root task and its child. Fix: 199060332 Test: manual check isFocused won't throw before root task is ready Change-Id: I3869f934b641c8ffd77730452d0501d65063785c
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user