Skip to content

Commit 187ae21

Browse files
author
Dianne Hackborn
committed
Revert to ICS screen rotation animation.
Change-Id: Ida76f17a00e4c8ab828deae51095107e4eeaa321
1 parent 4f8b71e commit 187ae21

9 files changed

+91
-18
lines changed

core/res/res/anim/screen_rotate_180_enter.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
android:interpolator="@interpolator/decelerate_quint"
2525
android:fillEnabled="true"
2626
android:fillBefore="true" android:fillAfter="true"
27-
android:duration="@android:integer/config_longAnimTime" />
27+
android:duration="@android:integer/config_mediumAnimTime" />
2828
</set>

core/res/res/anim/screen_rotate_180_exit.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
android:interpolator="@interpolator/decelerate_quint"
2525
android:fillEnabled="true"
2626
android:fillBefore="true" android:fillAfter="true"
27-
android:duration="@android:integer/config_longAnimTime" />
27+
android:duration="@android:integer/config_mediumAnimTime" />
28+
<alpha android:fromAlpha="1.0" android:toAlpha="0"
29+
android:interpolator="@interpolator/decelerate_cubic"
30+
android:duration="@android:integer/config_mediumAnimTime"/>
2831
</set>

core/res/res/anim/screen_rotate_180_frame.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
android:interpolator="@interpolator/decelerate_quint"
2525
android:fillEnabled="true"
2626
android:fillBefore="true" android:fillAfter="true"
27-
android:duration="@android:integer/config_longAnimTime" />
27+
android:duration="@android:integer/config_mediumAnimTime" />
2828
</set>

core/res/res/anim/screen_rotate_minus_90_enter.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@
1919

2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
2121
android:shareInterpolator="false">
22+
<!-- Version for two-phase anim
2223
<rotate android:fromDegrees="-90" android:toDegrees="0"
2324
android:pivotX="50%" android:pivotY="50%"
2425
android:interpolator="@interpolator/decelerate_quint"
2526
android:fillEnabled="true"
2627
android:fillBefore="true" android:fillAfter="true"
2728
android:duration="@android:integer/config_longAnimTime" />
29+
-->
30+
<rotate android:fromDegrees="-90" android:toDegrees="0"
31+
android:pivotX="50%" android:pivotY="50%"
32+
android:fillEnabled="true"
33+
android:fillBefore="true" android:fillAfter="true"
34+
android:interpolator="@interpolator/decelerate_quint"
35+
android:duration="@android:integer/config_mediumAnimTime" />
2836
</set>

core/res/res/anim/screen_rotate_minus_90_exit.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,30 @@
1919

2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
2121
android:shareInterpolator="false">
22+
<!-- Version for two-phase animation
2223
<rotate android:fromDegrees="0" android:toDegrees="90"
2324
android:pivotX="50%" android:pivotY="50%"
2425
android:interpolator="@interpolator/decelerate_quint"
2526
android:fillEnabled="true"
2627
android:fillBefore="true" android:fillAfter="true"
2728
android:duration="@android:integer/config_longAnimTime" />
29+
-->
30+
<scale android:fromXScale="100%" android:toXScale="100%p"
31+
android:fromYScale="100%" android:toYScale="100%p"
32+
android:pivotX="50%" android:pivotY="50%"
33+
android:interpolator="@interpolator/decelerate_quint"
34+
android:fillEnabled="true"
35+
android:fillBefore="true" android:fillAfter="true"
36+
android:duration="@android:integer/config_mediumAnimTime" />
37+
<rotate android:fromDegrees="0" android:toDegrees="90"
38+
android:pivotX="50%" android:pivotY="50%"
39+
android:interpolator="@interpolator/decelerate_quint"
40+
android:fillEnabled="true"
41+
android:fillBefore="true" android:fillAfter="true"
42+
android:duration="@android:integer/config_mediumAnimTime" />
43+
<alpha android:fromAlpha="1.0" android:toAlpha="0"
44+
android:interpolator="@interpolator/decelerate_quint"
45+
android:fillEnabled="true"
46+
android:fillBefore="true" android:fillAfter="true"
47+
android:duration="@android:integer/config_mediumAnimTime" />
2848
</set>

core/res/res/anim/screen_rotate_plus_90_enter.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@
1919

2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
2121
android:shareInterpolator="false">
22+
<!-- Version for two-phase animation
2223
<rotate android:fromDegrees="90" android:toDegrees="0"
2324
android:pivotX="50%" android:pivotY="50%"
2425
android:interpolator="@interpolator/decelerate_quint"
2526
android:fillEnabled="true"
2627
android:fillBefore="true" android:fillAfter="true"
2728
android:duration="@android:integer/config_longAnimTime" />
29+
-->
30+
<rotate android:fromDegrees="90" android:toDegrees="0"
31+
android:pivotX="50%" android:pivotY="50%"
32+
android:interpolator="@interpolator/decelerate_quint"
33+
android:fillEnabled="true"
34+
android:fillBefore="true" android:fillAfter="true"
35+
android:duration="@android:integer/config_mediumAnimTime" />
2836
</set>

core/res/res/anim/screen_rotate_plus_90_exit.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,30 @@
1919

2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
2121
android:shareInterpolator="false">
22+
<!-- Version for two-phase animation
2223
<rotate android:fromDegrees="0" android:toDegrees="-90"
2324
android:pivotX="50%" android:pivotY="50%"
2425
android:interpolator="@interpolator/decelerate_quint"
2526
android:fillEnabled="true"
2627
android:fillBefore="true" android:fillAfter="true"
2728
android:duration="@android:integer/config_longAnimTime" />
29+
-->
30+
<scale android:fromXScale="100%" android:toXScale="100%p"
31+
android:fromYScale="100%" android:toYScale="100%p"
32+
android:pivotX="50%" android:pivotY="50%"
33+
android:interpolator="@interpolator/decelerate_quint"
34+
android:fillEnabled="true"
35+
android:fillBefore="true" android:fillAfter="true"
36+
android:duration="@android:integer/config_mediumAnimTime" />
37+
<rotate android:fromDegrees="0" android:toDegrees="-90"
38+
android:pivotX="50%" android:pivotY="50%"
39+
android:interpolator="@interpolator/decelerate_quint"
40+
android:fillEnabled="true"
41+
android:fillBefore="true" android:fillAfter="true"
42+
android:duration="@android:integer/config_mediumAnimTime" />
43+
<alpha android:fromAlpha="1.0" android:toAlpha="0"
44+
android:interpolator="@interpolator/decelerate_quint"
45+
android:fillEnabled="true"
46+
android:fillBefore="true" android:fillAfter="true"
47+
android:duration="@android:integer/config_mediumAnimTime" />
2848
</set>

services/java/com/android/server/wm/ScreenRotationAnimation.java

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ScreenRotationAnimation {
3333
static final String TAG = "ScreenRotationAnimation";
3434
static final boolean DEBUG_STATE = false;
3535
static final boolean DEBUG_TRANSFORMS = false;
36+
static final boolean TWO_PHASE_ANIMATION = false;
3637
static final boolean USE_CUSTOM_BLACK_FRAME = false;
3738

3839
static final int FREEZE_LAYER = WindowManagerService.TYPE_LAYER_MULTIPLIER * 200;
@@ -44,7 +45,6 @@ class ScreenRotationAnimation {
4445
BlackFrame mEnteringBlackFrame;
4546
int mWidth, mHeight;
4647

47-
int mSnapshotDeltaRotation;
4848
int mOriginalRotation;
4949
int mOriginalWidth, mOriginalHeight;
5050
int mCurRotation;
@@ -138,10 +138,9 @@ public void printTo(String prefix, PrintWriter pw) {
138138
if (mEnteringBlackFrame != null) {
139139
mEnteringBlackFrame.printTo(prefix + " ", pw);
140140
}
141-
pw.print(prefix); pw.print(" mSnapshotDeltaRotation="); pw.print(mSnapshotDeltaRotation);
142-
pw.print(" mCurRotation="); pw.println(mCurRotation);
143-
pw.print(prefix); pw.print("mOriginalRotation="); pw.print(mOriginalRotation);
144-
pw.print(" mOriginalWidth="); pw.print(mOriginalWidth);
141+
pw.print(prefix); pw.print("mCurRotation="); pw.print(mCurRotation);
142+
pw.print(" mOriginalRotation="); pw.println(mOriginalRotation);
143+
pw.print(prefix); pw.print("mOriginalWidth="); pw.print(mOriginalWidth);
145144
pw.print(" mOriginalHeight="); pw.println(mOriginalHeight);
146145
pw.print(prefix); pw.print("mStarted="); pw.print(mStarted);
147146
pw.print(" mAnimRunning="); pw.print(mAnimRunning);
@@ -306,8 +305,13 @@ private void setRotation(int rotation) {
306305
public boolean setRotation(int rotation, SurfaceSession session,
307306
long maxAnimationDuration, float animationScale, int finalWidth, int finalHeight) {
308307
setRotation(rotation);
309-
return startAnimation(session, maxAnimationDuration, animationScale,
310-
finalWidth, finalHeight, false);
308+
if (TWO_PHASE_ANIMATION) {
309+
return startAnimation(session, maxAnimationDuration, animationScale,
310+
finalWidth, finalHeight, false);
311+
} else {
312+
// Don't start animation yet.
313+
return false;
314+
}
311315
}
312316

313317
/**
@@ -330,7 +334,8 @@ private boolean startAnimation(SurfaceSession session, long maxAnimationDuration
330334
// Figure out how the screen has moved from the original rotation.
331335
int delta = deltaRotation(mCurRotation, mOriginalRotation);
332336

333-
if (mFinishExitAnimation == null && (!dismissing || delta != Surface.ROTATION_0)) {
337+
if (TWO_PHASE_ANIMATION && mFinishExitAnimation == null
338+
&& (!dismissing || delta != Surface.ROTATION_0)) {
334339
if (DEBUG_STATE) Slog.v(TAG, "Creating start and finish animations");
335340
firstStart = true;
336341
mStartExitAnimation = AnimationUtils.loadAnimation(mContext,
@@ -406,7 +411,7 @@ private boolean startAnimation(SurfaceSession session, long maxAnimationDuration
406411
// means to allow supplying the last and next size. In this definition
407412
// "%p" is the original (let's call it "previous") size, and "%" is the
408413
// screen's current/new size.
409-
if (firstStart) {
414+
if (TWO_PHASE_ANIMATION && firstStart) {
410415
if (DEBUG_STATE) Slog.v(TAG, "Initializing start and finish animations");
411416
mStartEnterAnimation.initialize(finalWidth, finalHeight,
412417
halfWidth, halfHeight);
@@ -433,7 +438,7 @@ private boolean startAnimation(SurfaceSession session, long maxAnimationDuration
433438
mFinishAnimReady = false;
434439
mFinishAnimStartTime = -1;
435440

436-
if (firstStart) {
441+
if (TWO_PHASE_ANIMATION && firstStart) {
437442
mStartExitAnimation.restrictDuration(maxAnimationDuration);
438443
mStartExitAnimation.scaleCurrentDuration(animationScale);
439444
mStartEnterAnimation.restrictDuration(maxAnimationDuration);
@@ -624,6 +629,14 @@ public void kill() {
624629
}
625630

626631
public boolean isAnimating() {
632+
if (TWO_PHASE_ANIMATION) {
633+
return hasAnimations() || mFinishAnimReady;
634+
} else {
635+
return hasAnimations();
636+
}
637+
}
638+
639+
private boolean hasAnimations() {
627640
return mStartEnterAnimation != null || mStartExitAnimation != null
628641
|| mStartFrameAnimation != null
629642
|| mFinishEnterAnimation != null || mFinishExitAnimation != null
@@ -633,7 +646,6 @@ public boolean isAnimating() {
633646
}
634647

635648
private boolean stepAnimation(long now) {
636-
637649
if (mFinishAnimReady && mFinishAnimStartTime < 0) {
638650
if (DEBUG_STATE) Slog.v(TAG, "Step: finish anim now ready");
639651
mFinishAnimStartTime = now;
@@ -794,6 +806,10 @@ private boolean stepAnimation(long now) {
794806
}
795807

796808
void updateSurfaces() {
809+
if (!mStarted) {
810+
return;
811+
}
812+
797813
if (mSurface != null) {
798814
if (!mMoreStartExit && !mMoreFinishExit && !mMoreRotateExit) {
799815
if (DEBUG_STATE) Slog.v(TAG, "Exit animations done, hiding screenshot surface");
@@ -834,7 +850,7 @@ void updateSurfaces() {
834850
}
835851

836852
public boolean stepAnimationLocked(long now) {
837-
if (!isAnimating()) {
853+
if (!hasAnimations()) {
838854
if (DEBUG_STATE) Slog.v(TAG, "Step: no animations running");
839855
mFinishAnimReady = false;
840856
return false;

services/java/com/android/server/wm/WindowAnimator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ private void updateWindowsAppsAndRotationAnimationsLocked() {
158158
}
159159
}
160160

161-
if (mScreenRotationAnimation != null &&
162-
(mScreenRotationAnimation.isAnimating() ||
163-
mScreenRotationAnimation.mFinishAnimReady)) {
161+
if (mScreenRotationAnimation != null && mScreenRotationAnimation.isAnimating()) {
164162
if (mScreenRotationAnimation.stepAnimationLocked(mCurrentTime)) {
165163
mAnimating = true;
166164
} else {

0 commit comments

Comments
 (0)