Merge "Prevent flicker on orientation change while starting" into tm-qpr-dev
This commit is contained in:
@@ -4025,7 +4025,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
}
|
}
|
||||||
|
|
||||||
void finishRelaunching() {
|
void finishRelaunching() {
|
||||||
mLetterboxUiController.setRelauchingAfterRequestedOrientationChanged(false);
|
mLetterboxUiController.setRelaunchingAfterRequestedOrientationChanged(false);
|
||||||
mTaskSupervisor.getActivityMetricsLogger().notifyActivityRelaunched(this);
|
mTaskSupervisor.getActivityMetricsLogger().notifyActivityRelaunched(this);
|
||||||
|
|
||||||
if (mPendingRelaunchCount > 0) {
|
if (mPendingRelaunchCount > 0) {
|
||||||
@@ -9420,7 +9420,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
mRelaunchReason = RELAUNCH_REASON_NONE;
|
mRelaunchReason = RELAUNCH_REASON_NONE;
|
||||||
}
|
}
|
||||||
if (isRequestedOrientationChanged) {
|
if (isRequestedOrientationChanged) {
|
||||||
mLetterboxUiController.setRelauchingAfterRequestedOrientationChanged(true);
|
mLetterboxUiController.setRelaunchingAfterRequestedOrientationChanged(true);
|
||||||
}
|
}
|
||||||
if (mState == PAUSING) {
|
if (mState == PAUSING) {
|
||||||
// A little annoying: we are waiting for this activity to finish pausing. Let's not
|
// A little annoying: we are waiting for this activity to finish pausing. Let's not
|
||||||
|
|||||||
@@ -242,7 +242,9 @@ final class LetterboxUiController {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private final Boolean mBooleanPropertyFakeFocus;
|
private final Boolean mBooleanPropertyFakeFocus;
|
||||||
|
|
||||||
private boolean mIsRelauchingAfterRequestedOrientationChanged;
|
private boolean mIsRelaunchingAfterRequestedOrientationChanged;
|
||||||
|
|
||||||
|
private boolean mLastShouldShowLetterboxUi;
|
||||||
|
|
||||||
private boolean mDoubleTapEvent;
|
private boolean mDoubleTapEvent;
|
||||||
|
|
||||||
@@ -395,7 +397,7 @@ final class LetterboxUiController {
|
|||||||
::isPolicyForIgnoringRequestedOrientationEnabled,
|
::isPolicyForIgnoringRequestedOrientationEnabled,
|
||||||
mIsOverrideEnableCompatIgnoreRequestedOrientationEnabled,
|
mIsOverrideEnableCompatIgnoreRequestedOrientationEnabled,
|
||||||
mBooleanPropertyIgnoreRequestedOrientation)) {
|
mBooleanPropertyIgnoreRequestedOrientation)) {
|
||||||
if (mIsRelauchingAfterRequestedOrientationChanged) {
|
if (mIsRelaunchingAfterRequestedOrientationChanged) {
|
||||||
Slog.w(TAG, "Ignoring orientation update to "
|
Slog.w(TAG, "Ignoring orientation update to "
|
||||||
+ screenOrientationToString(requestedOrientation)
|
+ screenOrientationToString(requestedOrientation)
|
||||||
+ " due to relaunching after setRequestedOrientation for "
|
+ " due to relaunching after setRequestedOrientation for "
|
||||||
@@ -484,8 +486,8 @@ final class LetterboxUiController {
|
|||||||
* Sets whether an activity is relaunching after the app has called {@link
|
* Sets whether an activity is relaunching after the app has called {@link
|
||||||
* android.app.Activity#setRequestedOrientation}.
|
* android.app.Activity#setRequestedOrientation}.
|
||||||
*/
|
*/
|
||||||
void setRelauchingAfterRequestedOrientationChanged(boolean isRelaunching) {
|
void setRelaunchingAfterRequestedOrientationChanged(boolean isRelaunching) {
|
||||||
mIsRelauchingAfterRequestedOrientationChanged = isRelaunching;
|
mIsRelaunchingAfterRequestedOrientationChanged = isRelaunching;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1162,12 +1164,28 @@ final class LetterboxUiController {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean shouldShowLetterboxUi(WindowState mainWindow) {
|
boolean shouldShowLetterboxUi(WindowState mainWindow) {
|
||||||
return (mActivityRecord.isInLetterboxAnimation() || isSurfaceVisible(mainWindow))
|
if (mIsRelaunchingAfterRequestedOrientationChanged || !isSurfaceReadyToShow(mainWindow)) {
|
||||||
|
return mLastShouldShowLetterboxUi;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean shouldShowLetterboxUi =
|
||||||
|
(mActivityRecord.isInLetterboxAnimation() || isSurfaceVisible(mainWindow))
|
||||||
&& mainWindow.areAppWindowBoundsLetterboxed()
|
&& mainWindow.areAppWindowBoundsLetterboxed()
|
||||||
// Check for FLAG_SHOW_WALLPAPER explicitly instead of using
|
// Check for FLAG_SHOW_WALLPAPER explicitly instead of using
|
||||||
// WindowContainer#showWallpaper because the later will return true when this
|
// WindowContainer#showWallpaper because the later will return true when this
|
||||||
// activity is using blurred wallpaper for letterbox background.
|
// activity is using blurred wallpaper for letterbox background.
|
||||||
&& (mainWindow.getAttrs().flags & FLAG_SHOW_WALLPAPER) == 0;
|
&& (mainWindow.getAttrs().flags & FLAG_SHOW_WALLPAPER) == 0;
|
||||||
|
|
||||||
|
mLastShouldShowLetterboxUi = shouldShowLetterboxUi;
|
||||||
|
|
||||||
|
return shouldShowLetterboxUi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean isSurfaceReadyToShow(WindowState mainWindow) {
|
||||||
|
return mainWindow.isDrawn() // Regular case
|
||||||
|
// Waiting for relayoutWindow to call preserveSurface
|
||||||
|
|| mainWindow.isDragResizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -1303,6 +1321,10 @@ final class LetterboxUiController {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean getIsRelaunchingAfterRequestedOrientationChanged() {
|
||||||
|
return mIsRelaunchingAfterRequestedOrientationChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void adjustBoundsForTaskbar(final WindowState mainWindow, final Rect bounds) {
|
private void adjustBoundsForTaskbar(final WindowState mainWindow, final Rect bounds) {
|
||||||
// Rounded corners should be displayed above the taskbar. When taskbar is hidden,
|
// Rounded corners should be displayed above the taskbar. When taskbar is hidden,
|
||||||
// an insets frame is equal to a navigation bar which shouldn't affect position of
|
// an insets frame is equal to a navigation bar which shouldn't affect position of
|
||||||
|
|||||||
@@ -5596,8 +5596,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
if (surfaceInsetsChanged) {
|
if (surfaceInsetsChanged) {
|
||||||
mLastSurfaceInsets.set(mAttrs.surfaceInsets);
|
mLastSurfaceInsets.set(mAttrs.surfaceInsets);
|
||||||
}
|
}
|
||||||
if (surfaceSizeChanged && mWinAnimator.getShown() && !canPlayMoveAnimation()
|
final boolean surfaceResizedWithoutMoveAnimation = surfaceSizeChanged
|
||||||
&& okToDisplay() && mSyncState == SYNC_STATE_NONE) {
|
&& mWinAnimator.getShown() && !canPlayMoveAnimation() && okToDisplay()
|
||||||
|
&& mSyncState == SYNC_STATE_NONE;
|
||||||
|
final ActivityRecord activityRecord = getActivityRecord();
|
||||||
|
// If this window belongs to an activity that is relaunching due to an orientation
|
||||||
|
// change then delay the position update until it has redrawn to avoid any flickers.
|
||||||
|
final boolean isLetterboxedAndRelaunching = activityRecord != null
|
||||||
|
&& activityRecord.areBoundsLetterboxed()
|
||||||
|
&& activityRecord.mLetterboxUiController
|
||||||
|
.getIsRelaunchingAfterRequestedOrientationChanged();
|
||||||
|
if (surfaceResizedWithoutMoveAnimation || isLetterboxedAndRelaunching) {
|
||||||
applyWithNextDraw(mSetSurfacePositionConsumer);
|
applyWithNextDraw(mSetSurfacePositionConsumer);
|
||||||
} else {
|
} else {
|
||||||
mSetSurfacePositionConsumer.accept(t);
|
mSetSurfacePositionConsumer.accept(t);
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase {
|
|||||||
mActivity = setUpActivityWithComponent();
|
mActivity = setUpActivityWithComponent();
|
||||||
mController = new LetterboxUiController(mWm, mActivity);
|
mController = new LetterboxUiController(mWm, mActivity);
|
||||||
prepareActivityThatShouldIgnoreRequestedOrientationDuringRelaunch();
|
prepareActivityThatShouldIgnoreRequestedOrientationDuringRelaunch();
|
||||||
mController.setRelauchingAfterRequestedOrientationChanged(false);
|
mController.setRelaunchingAfterRequestedOrientationChanged(false);
|
||||||
|
|
||||||
spyOn(mDisplayContent.mDisplayRotationCompatPolicy);
|
spyOn(mDisplayContent.mDisplayRotationCompatPolicy);
|
||||||
doReturn(true).when(mDisplayContent.mDisplayRotationCompatPolicy)
|
doReturn(true).when(mDisplayContent.mDisplayRotationCompatPolicy)
|
||||||
@@ -864,7 +864,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase {
|
|||||||
private void prepareActivityThatShouldIgnoreRequestedOrientationDuringRelaunch() {
|
private void prepareActivityThatShouldIgnoreRequestedOrientationDuringRelaunch() {
|
||||||
doReturn(true).when(mLetterboxConfiguration)
|
doReturn(true).when(mLetterboxConfiguration)
|
||||||
.isPolicyForIgnoringRequestedOrientationEnabled();
|
.isPolicyForIgnoringRequestedOrientationEnabled();
|
||||||
mController.setRelauchingAfterRequestedOrientationChanged(true);
|
mController.setRelaunchingAfterRequestedOrientationChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivityRecord setUpActivityWithComponent() {
|
private ActivityRecord setUpActivityWithComponent() {
|
||||||
|
|||||||
@@ -782,6 +782,8 @@ public class SizeCompatTests extends WindowTestsBase {
|
|||||||
assertEquals(window, mActivity.findMainWindow());
|
assertEquals(window, mActivity.findMainWindow());
|
||||||
|
|
||||||
spyOn(mActivity.mLetterboxUiController);
|
spyOn(mActivity.mLetterboxUiController);
|
||||||
|
doReturn(true).when(mActivity.mLetterboxUiController)
|
||||||
|
.isSurfaceReadyToShow(any());
|
||||||
doReturn(true).when(mActivity.mLetterboxUiController)
|
doReturn(true).when(mActivity.mLetterboxUiController)
|
||||||
.isSurfaceVisible(any());
|
.isSurfaceVisible(any());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user