Merge "Finish rotation controller if the pending change is gone" into udc-qpr-dev
This commit is contained in:
@@ -33,6 +33,7 @@ import android.view.animation.AnimationUtils;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.function.Consumer;
|
||||
@@ -224,7 +225,15 @@ class AsyncRotationController extends FadeAnimationController implements Consume
|
||||
* operation directly to avoid waiting until timeout.
|
||||
*/
|
||||
void updateTargetWindows() {
|
||||
if (mTransitionOp == OP_LEGACY || !mIsStartTransactionCommitted) return;
|
||||
if (mTransitionOp == OP_LEGACY) return;
|
||||
if (!mIsStartTransactionCommitted) {
|
||||
if (mTimeoutRunnable == null && !mDisplayContent.hasTopFixedRotationLaunchingApp()
|
||||
&& !mDisplayContent.isRotationChanging() && !mDisplayContent.inTransition()) {
|
||||
Slog.d(TAG, "Cancel for no change");
|
||||
mDisplayContent.finishAsyncRotationIfPossible();
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (int i = mTargetWindowTokens.size() - 1; i >= 0; i--) {
|
||||
final Operation op = mTargetWindowTokens.valueAt(i);
|
||||
if (op.mIsCompletionPending || op.mAction == Operation.ACTION_SEAMLESS) {
|
||||
@@ -608,6 +617,16 @@ class AsyncRotationController extends FadeAnimationController implements Consume
|
||||
return op.mAction != Operation.ACTION_SEAMLESS;
|
||||
}
|
||||
|
||||
void dump(PrintWriter pw, String prefix) {
|
||||
pw.println(prefix + "AsyncRotationController");
|
||||
prefix += " ";
|
||||
pw.println(prefix + "mTransitionOp=" + mTransitionOp);
|
||||
pw.println(prefix + "mIsStartTransactionCommitted=" + mIsStartTransactionCommitted);
|
||||
pw.println(prefix + "mIsSyncDrawRequested=" + mIsSyncDrawRequested);
|
||||
pw.println(prefix + "mOriginalRotation=" + mOriginalRotation);
|
||||
pw.println(prefix + "mTargetWindowTokens=" + mTargetWindowTokens);
|
||||
}
|
||||
|
||||
/** The operation to control the rotation appearance associated with window token. */
|
||||
private static class Operation {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@@ -635,5 +654,10 @@ class AsyncRotationController extends FadeAnimationController implements Consume
|
||||
Operation(@Action int action) {
|
||||
mAction = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Operation{a=" + mAction + " pending=" + mIsCompletionPending + '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3454,6 +3454,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
if (mFixedRotationLaunchingApp != null) {
|
||||
setSeamlessTransitionForFixedRotation(controller.getCollectingTransition());
|
||||
}
|
||||
} else if (mAsyncRotationController != null && !isRotationChanging()) {
|
||||
Slog.i(TAG, "Finish AsyncRotation for previous intermediate change");
|
||||
finishAsyncRotationIfPossible();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -3627,6 +3630,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
if (mFixedRotationLaunchingApp != null) {
|
||||
pw.println(" mFixedRotationLaunchingApp=" + mFixedRotationLaunchingApp);
|
||||
}
|
||||
if (mAsyncRotationController != null) {
|
||||
mAsyncRotationController.dump(pw, prefix);
|
||||
}
|
||||
|
||||
pw.println();
|
||||
pw.print(prefix + "mHoldScreenWindow="); pw.print(mHoldScreenWindow);
|
||||
|
||||
@@ -2054,6 +2054,17 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertNotEquals(testPlayer.mLastReady.getChange(dcToken).getEndRotation(),
|
||||
testPlayer.mLastReady.getChange(dcToken).getStartRotation());
|
||||
testPlayer.finish();
|
||||
|
||||
// The AsyncRotationController should only exist if there is an ongoing rotation change.
|
||||
dc.finishAsyncRotationIfPossible();
|
||||
dc.setLastHasContent();
|
||||
doReturn(dr.getRotation() + 1).when(dr).rotationForOrientation(anyInt(), anyInt());
|
||||
dr.updateRotationUnchecked(true /* forceUpdate */);
|
||||
assertNotNull(dc.getAsyncRotationController());
|
||||
doReturn(dr.getRotation() - 1).when(dr).rotationForOrientation(anyInt(), anyInt());
|
||||
dr.updateRotationUnchecked(true /* forceUpdate */);
|
||||
assertNull("Cancel AsyncRotationController for the intermediate rotation changes 0->1->0",
|
||||
dc.getAsyncRotationController());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user