Merge "Fix NPE in isTrimmable" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-05-20 05:40:12 +00:00
committed by Android (Google) Code Review
4 changed files with 13 additions and 10 deletions

View File

@@ -1387,9 +1387,7 @@ class RecentTasks {
return false; return false;
} }
/** /** @return whether the given task can be trimmed even if it is outside the visible range. */
* @return whether the given task can be trimmed even if it is outside the visible range.
*/
protected boolean isTrimmable(Task task) { protected boolean isTrimmable(Task task) {
final ActivityStack stack = task.getStack(); final ActivityStack stack = task.getStack();
@@ -1404,9 +1402,13 @@ class RecentTasks {
return false; return false;
} }
final ActivityStack rootHomeTask = stack.getDisplayArea().getRootHomeTask();
// Home stack does not exist. Don't trim the task.
if (rootHomeTask == null) {
return false;
}
// Trim tasks that are behind the home task. // Trim tasks that are behind the home task.
final TaskDisplayArea taskDisplayArea = stack.getDisplayArea(); return task.compareTo(rootHomeTask) < 0;
return task.compareTo(taskDisplayArea.getRootHomeTask()) < 0;
} }
/** Remove the tasks that user may not be able to return. */ /** Remove the tasks that user may not be able to return. */

View File

@@ -406,8 +406,9 @@ public class RecentsAnimationController implements DeathRecipient {
} }
// Save the minimized home height // Save the minimized home height
mMinimizedHomeBounds = mDisplayContent.getDefaultTaskDisplayArea().getRootHomeTask() final ActivityStack rootHomeTask =
.getBounds(); mDisplayContent.getDefaultTaskDisplayArea().getRootHomeTask();
mMinimizedHomeBounds = rootHomeTask != null ? rootHomeTask.getBounds() : null;
mService.mWindowPlacerLocked.performSurfacePlacement(); mService.mWindowPlacerLocked.performSurfacePlacement();

View File

@@ -195,7 +195,7 @@ final class TaskDisplayArea extends DisplayArea<ActivityStack> {
return mChildren.indexOf(stack); return mChildren.indexOf(stack);
} }
ActivityStack getRootHomeTask() { @Nullable ActivityStack getRootHomeTask() {
return mRootHomeTask; return mRootHomeTask;
} }

View File

@@ -1509,7 +1509,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return mActivityRecord != null ? mActivityRecord.getTask() : null; return mActivityRecord != null ? mActivityRecord.getTask() : null;
} }
ActivityStack getRootTask() { @Nullable ActivityStack getRootTask() {
final Task task = getTask(); final Task task = getTask();
if (task != null) { if (task != null) {
return (ActivityStack) task.getRootTask(); return (ActivityStack) task.getRootTask();
@@ -2527,7 +2527,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
final Task task = getTask(); final Task task = getTask();
if (task != null) { if (task != null) {
task.getDimBounds(mTmpRect); task.getDimBounds(mTmpRect);
} else { } else if (getRootTask() != null) {
getRootTask().getDimBounds(mTmpRect); getRootTask().getDimBounds(mTmpRect);
} }
} }