Merge "Further cleanup for rotation code"

This commit is contained in:
Vadim Caen
2019-08-12 08:55:53 +00:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 46 deletions

View File

@@ -119,14 +119,12 @@ import static com.android.server.wm.WindowManagerDebugConfig.SHOW_STACK_CRAWLS;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.CUSTOM_SCREEN_ROTATION;
import static com.android.server.wm.WindowManagerService.H.REPORT_FOCUS_CHANGE;
import static com.android.server.wm.WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE;
import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS;
import static com.android.server.wm.WindowManagerService.H.UPDATE_DOCKED_STACK_DIVIDER;
import static com.android.server.wm.WindowManagerService.H.WINDOW_HIDE_TIMEOUT;
import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD;
import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION;
import static com.android.server.wm.WindowManagerService.SEAMLESS_ROTATION_TIMEOUT_DURATION;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_REMOVING_FOCUS;
@@ -1534,13 +1532,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
// NOTE: We disable the rotation in the emulator because
// it doesn't support hardware OpenGL emulation yet.
if (CUSTOM_SCREEN_ROTATION && screenRotationAnimation != null
&& screenRotationAnimation.hasScreenshot()) {
if (screenRotationAnimation.setRotation(getPendingTransaction(), rotation,
MAX_ANIMATION_DURATION, mWmService.getTransitionAnimationScaleLocked(),
mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight)) {
mWmService.scheduleAnimationLocked();
}
if (screenRotationAnimation != null && screenRotationAnimation.hasScreenshot()) {
screenRotationAnimation.setRotation(getPendingTransaction(), rotation);
}
forAllWindows(w -> {

View File

@@ -286,20 +286,11 @@ class ScreenRotationAnimation {
setSnapshotTransform(t, mSnapshotInitialMatrix, 1.0f);
}
public boolean setRotation(SurfaceControl.Transaction t, int rotation,
long maxAnimationDuration, float animationScale, int finalWidth, int finalHeight) {
setRotation(t, rotation);
// Don't start animation yet.
return false;
}
/**
* Returns true if animating.
*/
private boolean startAnimation(SurfaceControl.Transaction t, long maxAnimationDuration,
float animationScale, int finalWidth, int finalHeight, boolean dismissing,
int exitAnim, int enterAnim) {
float animationScale, int finalWidth, int finalHeight, int exitAnim, int enterAnim) {
if (mSurfaceControl == null) {
// Can't do animation.
return false;
@@ -420,7 +411,7 @@ class ScreenRotationAnimation {
}
if (!mStarted) {
startAnimation(t, maxAnimationDuration, animationScale, finalWidth, finalHeight,
true, exitAnim, enterAnim);
exitAnim, enterAnim);
}
if (!mStarted) {
return false;

View File

@@ -336,11 +336,6 @@ public class WindowManagerService extends IWindowManager.Stub
/** Amount of time to allow a last ANR message to exist before freeing the memory. */
static final int LAST_ANR_LIFETIME_DURATION_MSECS = 2 * 60 * 60 * 1000; // Two hours
/**
* If true, the window manager will do its own custom freezing and general
* management of the screen during rotation.
*/
static final boolean CUSTOM_SCREEN_ROTATION = true;
// Maximum number of milliseconds to wait for input devices to be enumerated before
// proceding with safe mode detection.
@@ -5395,25 +5390,23 @@ public class WindowManagerService extends IWindowManager.Stub
}
mLatencyTracker.onActionStart(ACTION_ROTATE_SCREEN);
if (CUSTOM_SCREEN_ROTATION) {
mExitAnimId = exitAnim;
mEnterAnimId = enterAnim;
ScreenRotationAnimation screenRotationAnimation =
mAnimator.getScreenRotationAnimationLocked(mFrozenDisplayId);
if (screenRotationAnimation != null) {
screenRotationAnimation.kill();
}
// Check whether the current screen contains any secure content.
boolean isSecure = displayContent.hasSecureWindowOnScreen();
displayContent.updateDisplayInfo();
screenRotationAnimation = new ScreenRotationAnimation(mContext, displayContent,
displayContent.getDisplayRotation().isFixedToUserRotation(), isSecure,
this);
mAnimator.setScreenRotationAnimationLocked(mFrozenDisplayId,
screenRotationAnimation);
mExitAnimId = exitAnim;
mEnterAnimId = enterAnim;
ScreenRotationAnimation screenRotationAnimation =
mAnimator.getScreenRotationAnimationLocked(mFrozenDisplayId);
if (screenRotationAnimation != null) {
screenRotationAnimation.kill();
}
// Check whether the current screen contains any secure content.
boolean isSecure = displayContent.hasSecureWindowOnScreen();
displayContent.updateDisplayInfo();
screenRotationAnimation = new ScreenRotationAnimation(mContext, displayContent,
displayContent.getDisplayRotation().isFixedToUserRotation(), isSecure,
this);
mAnimator.setScreenRotationAnimationLocked(mFrozenDisplayId,
screenRotationAnimation);
}
void stopFreezingDisplayLocked() {
@@ -5466,8 +5459,7 @@ public class WindowManagerService extends IWindowManager.Stub
ScreenRotationAnimation screenRotationAnimation =
mAnimator.getScreenRotationAnimationLocked(displayId);
if (CUSTOM_SCREEN_ROTATION && screenRotationAnimation != null
&& screenRotationAnimation.hasScreenshot()) {
if (screenRotationAnimation != null && screenRotationAnimation.hasScreenshot()) {
if (DEBUG_ORIENTATION) Slog.i(TAG_WM, "**** Dismissing screen rotation animation");
DisplayInfo displayInfo = displayContent.getDisplayInfo();
// Get rotation animation again, with new top window
@@ -5511,7 +5503,7 @@ public class WindowManagerService extends IWindowManager.Stub
mScreenFrozenLock.release();
if (updateRotation && displayContent != null && updateRotation) {
if (updateRotation && displayContent != null) {
if (DEBUG_ORIENTATION) Slog.d(TAG_WM, "Performing post-rotate rotation");
configChanged |= displayContent.updateRotationUnchecked();
}