Merge "Protect against NPE when updating state" into udc-dev am: ec5540c745
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22972200 Change-Id: Ibb086ab500ecd777ea2ffe54ba87b04e30617c12 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -202,6 +202,7 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setTaskViewVisible(TaskViewTaskController taskView, boolean visible) {
|
void setTaskViewVisible(TaskViewTaskController taskView, boolean visible) {
|
||||||
|
if (mTaskViews.get(taskView) == null) return;
|
||||||
if (mTaskViews.get(taskView).mVisible == visible) return;
|
if (mTaskViews.get(taskView).mVisible == visible) return;
|
||||||
if (taskView.getTaskInfo() == null) {
|
if (taskView.getTaskInfo() == null) {
|
||||||
// Nothing to update, task is not yet available
|
// Nothing to update, task is not yet available
|
||||||
@@ -220,17 +221,19 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
|
|||||||
|
|
||||||
void updateBoundsState(TaskViewTaskController taskView, Rect boundsOnScreen) {
|
void updateBoundsState(TaskViewTaskController taskView, Rect boundsOnScreen) {
|
||||||
TaskViewRequestedState state = mTaskViews.get(taskView);
|
TaskViewRequestedState state = mTaskViews.get(taskView);
|
||||||
|
if (state == null) return;
|
||||||
state.mBounds.set(boundsOnScreen);
|
state.mBounds.set(boundsOnScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateVisibilityState(TaskViewTaskController taskView, boolean visible) {
|
void updateVisibilityState(TaskViewTaskController taskView, boolean visible) {
|
||||||
TaskViewRequestedState state = mTaskViews.get(taskView);
|
TaskViewRequestedState state = mTaskViews.get(taskView);
|
||||||
|
if (state == null) return;
|
||||||
state.mVisible = visible;
|
state.mVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTaskBounds(TaskViewTaskController taskView, Rect boundsOnScreen) {
|
void setTaskBounds(TaskViewTaskController taskView, Rect boundsOnScreen) {
|
||||||
TaskViewRequestedState state = mTaskViews.get(taskView);
|
TaskViewRequestedState state = mTaskViews.get(taskView);
|
||||||
if (Objects.equals(boundsOnScreen, state.mBounds)) {
|
if (state == null || Objects.equals(boundsOnScreen, state.mBounds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.mBounds.set(boundsOnScreen);
|
state.mBounds.set(boundsOnScreen);
|
||||||
|
|||||||
@@ -179,4 +179,23 @@ public class TaskViewTransitionsTest extends ShellTestCase {
|
|||||||
mTaskViewTransitions.findPending(mTaskViewTaskController, TRANSIT_CHANGE);
|
mTaskViewTransitions.findPending(mTaskViewTaskController, TRANSIT_CHANGE);
|
||||||
assertThat(pendingBounds2).isNull();
|
assertThat(pendingBounds2).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetTaskVisibility_taskRemoved_noNPE() {
|
||||||
|
mTaskViewTransitions.removeTaskView(mTaskViewTaskController);
|
||||||
|
|
||||||
|
assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);
|
||||||
|
|
||||||
|
mTaskViewTransitions.setTaskViewVisible(mTaskViewTaskController, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetTaskBounds_taskRemoved_noNPE() {
|
||||||
|
mTaskViewTransitions.removeTaskView(mTaskViewTaskController);
|
||||||
|
|
||||||
|
assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);
|
||||||
|
|
||||||
|
mTaskViewTransitions.setTaskBounds(mTaskViewTaskController,
|
||||||
|
new Rect(0, 0, 100, 100));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user