Fix invalid divider state while rotating

- Sometimes there is no window attached to the app token during a
rotation. In this case, we also want to return a valid dock side, so
we check for hiddenRequested instead of traversing the windows
of an app window token.
- The logic to notify SystemUI about rotation changes never really
worked. Remove the dock side check as the dock side is guaranteed
to change if we change the screen rotation
- Also clean up visibility methods a bit.

Test: Manually tested the interaction when in docked state landscape,
and going home with locked home rotation like 20 times. Also tested
multi-user interaction with docking.

Change-Id: Ibcd181cadc9bc5a97dbd20e67d15bb1c88de5b97
Fixes: 29569499
This commit is contained in:
Jorim Jaggi
2016-08-25 15:57:41 -07:00
parent 80c031cbd4
commit 160a3c578c
3 changed files with 18 additions and 43 deletions

View File

@@ -637,7 +637,7 @@ class DisplayContent {
*/
TaskStack getDockedStackVisibleForUserLocked() {
final TaskStack stack = mService.mStackIdToStack.get(DOCKED_STACK_ID);
return (stack != null && stack.isVisibleForUserLocked()) ? stack : null;
return (stack != null && stack.isVisibleLocked(true /* ignoreKeyguard */)) ? stack : null;
}
/**

View File

@@ -677,19 +677,6 @@ class Task implements DimLayer.DimLayerUser {
return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showForAllUsers;
}
boolean isVisibleForUser() {
for (int i = mAppTokens.size() - 1; i >= 0; i--) {
final AppWindowToken appToken = mAppTokens.get(i);
for (int j = appToken.allAppWindows.size() - 1; j >= 0; j--) {
WindowState window = appToken.allAppWindows.get(j);
if (!window.isHiddenFromUserLocked()) {
return true;
}
}
}
return false;
}
boolean isVisible() {
for (int i = mAppTokens.size() - 1; i >= 0; i--) {
final AppWindowToken appToken = mAppTokens.get(i);

View File

@@ -398,23 +398,21 @@ public class TaskStack implements DimLayer.DimLayerUser,
return false;
}
final int oldDockSide = mStackId == DOCKED_STACK_ID ? getDockSide() : DOCKED_INVALID;
mTmpRect2.set(mBounds);
mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
if (mStackId == DOCKED_STACK_ID) {
repositionDockedStackAfterRotation(mTmpRect2);
snapDockedStackAfterRotation(mTmpRect2);
final int newDockSide = getDockSide(mTmpRect2);
if (oldDockSide != newDockSide) {
// Update the dock create mode and clear the dock create bounds, these
// might change after a rotation and the original values will be invalid.
mService.setDockedStackCreateStateLocked(
(newDockSide == DOCKED_LEFT || newDockSide == DOCKED_TOP)
? DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT
: DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT,
null);
mDisplayContent.getDockedDividerController().notifyDockSideChanged(newDockSide);
}
// Update the dock create mode and clear the dock create bounds, these
// might change after a rotation and the original values will be invalid.
mService.setDockedStackCreateStateLocked(
(newDockSide == DOCKED_LEFT || newDockSide == DOCKED_TOP)
? DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT
: DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT,
null);
mDisplayContent.getDockedDividerController().notifyDockSideChanged(newDockSide);
}
mBoundsAfterRotation.set(mTmpRect2);
@@ -890,7 +888,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
mAdjustImeAmount = adjustAmount;
mAdjustDividerAmount = adjustDividerAmount;
updateAdjustedBounds();
return isVisibleForUserLocked();
return isVisibleLocked(true /* ignoreKeyguard */);
} else {
return false;
}
@@ -926,7 +924,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
if (minimizeAmount != mMinimizeAmount) {
mMinimizeAmount = minimizeAmount;
updateAdjustedBounds();
return isVisibleForUserLocked();
return isVisibleLocked(true /* ignoreKeyguard*/);
} else {
return false;
}
@@ -943,7 +941,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
void beginImeAdjustAnimation() {
for (int j = mTasks.size() - 1; j >= 0; j--) {
final Task task = mTasks.get(j);
if (task.isVisibleForUser()) {
if (task.isVisible()) {
task.setDragResizing(true, DRAG_RESIZE_MODE_DOCKED_DIVIDER);
task.addWindowsWaitingForDrawnIfResizingChanged();
}
@@ -1233,9 +1231,13 @@ public class TaskStack implements DimLayer.DimLayerUser,
}
boolean isVisibleLocked() {
return isVisibleLocked(false /* ignoreKeyguard */);
}
boolean isVisibleLocked(boolean ignoreKeyguard) {
final boolean keyguardOn = mService.mPolicy.isKeyguardShowingOrOccluded()
&& !mService.mAnimator.mKeyguardGoingAway;
if (keyguardOn && !StackId.isAllowedOverLockscreen(mStackId)) {
if (!ignoreKeyguard && keyguardOn && !StackId.isAllowedOverLockscreen(mStackId)) {
// The keyguard is showing and the stack shouldn't show on top of the keyguard.
return false;
}
@@ -1252,20 +1254,6 @@ public class TaskStack implements DimLayer.DimLayerUser,
return false;
}
/**
* @return true if a the stack is visible for the current in user, ignoring any other visibility
* aspects, and false otherwise
*/
boolean isVisibleForUserLocked() {
for (int i = mTasks.size() - 1; i >= 0; i--) {
final Task task = mTasks.get(i);
if (task.isVisibleForUser()) {
return true;
}
}
return false;
}
boolean isDragResizing() {
return mDragResizing;
}