Skip to content

Commit 1d961d4

Browse files
author
Craig Mautner
committed
Better handle changing app transitions.
When we are in the middle of an app transition and need to change to a new one we were not ending the old one in a clean state. Also, wallpapers were defaulting to the wrong animation in certain situations. Remove ':' style iterators. Fixes bug 6486708. Change-Id: Ied17e8410486020295db380ff68df5dad08bc5cc
1 parent 6385ff5 commit 1d961d4

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,9 @@ public void setAnimation(Animation anim, boolean initialized) {
7979
}
8080

8181
public void setDummyAnimation() {
82-
if (animation == null) {
83-
if (WindowManagerService.localLOGV) Slog.v(
84-
TAG, "Setting dummy animation in " + mAppToken);
85-
animation = sDummyAnimation;
86-
animInitialized = false;
87-
}
82+
if (WindowManagerService.localLOGV) Slog.v(TAG, "Setting dummy animation in " + mAppToken);
83+
animation = sDummyAnimation;
84+
animInitialized = false;
8885
hasTransformation = true;
8986
transformation.clear();
9087
transformation.setAlpha(mAppToken.reportedVisible ? 1 : 0);

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ int adjustWallpaperWindowsLocked() {
16381638
// it is of no interest to us.
16391639
if (w.mAppToken.hidden && w.mAppToken.mAppAnimator.animation == null) {
16401640
if (DEBUG_WALLPAPER) Slog.v(TAG,
1641-
"Skipping not hidden or animating token: " + w);
1641+
"Skipping hidden and not animating token: " + w);
16421642
continue;
16431643
}
16441644
}
@@ -3864,6 +3864,7 @@ public void prepareAppTransition(int transit, boolean alwaysKeepCurrent) {
38643864
if (DEBUG_APP_TRANSITIONS) Slog.v(
38653865
TAG, "Prepare app transition: transit=" + transit
38663866
+ " mNextAppTransition=" + mNextAppTransition
3867+
+ " alwaysKeepCurrent=" + alwaysKeepCurrent
38673868
+ " Callers=" + Debug.getCallers(3));
38683869
if (okToDisplay()) {
38693870
if (mNextAppTransition == WindowManagerPolicy.TRANSIT_UNSET
@@ -3933,6 +3934,15 @@ public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX,
39333934
}
39343935
}
39353936

3937+
private void cancelWindowAnimations(final AppWindowToken wtoken) {
3938+
for (int i = wtoken.windows.size() - 1; i >= 0; i--) {
3939+
final WindowStateAnimator winAnimator = wtoken.windows.get(i).mWinAnimator;
3940+
if (winAnimator.isAnimating()) {
3941+
winAnimator.clearAnimation();
3942+
}
3943+
}
3944+
}
3945+
39363946
public void executeAppTransition() {
39373947
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
39383948
"executeAppTransition()")) {
@@ -3948,6 +3958,12 @@ public void executeAppTransition() {
39483958
}
39493959
if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
39503960
mAppTransitionReady = true;
3961+
for (int i = mOpeningApps.size() - 1; i >= 0; i--) {
3962+
cancelWindowAnimations(mOpeningApps.get(i));
3963+
}
3964+
for (int i = mClosingApps.size() - 1; i >= 0; i--) {
3965+
cancelWindowAnimations(mClosingApps.get(i));
3966+
}
39513967
final long origId = Binder.clearCallingIdentity();
39523968
performLayoutAndPlaceSurfacesLocked();
39533969
Binder.restoreCallingIdentity(origId);
@@ -4295,6 +4311,7 @@ public void setAppVisibility(IBinder token, boolean visible) {
42954311

42964312
if (DEBUG_APP_TRANSITIONS) Slog.v(
42974313
TAG, "Setting dummy animation on: " + wtoken);
4314+
cancelWindowAnimations(wtoken);
42984315
wtoken.mAppAnimator.setDummyAnimation();
42994316
mOpeningApps.remove(wtoken);
43004317
mClosingApps.remove(wtoken);
@@ -5321,7 +5338,8 @@ private void showStrictModeViolation(int arg) {
53215338
// the background..)
53225339
if (on) {
53235340
boolean isVisible = false;
5324-
for (WindowState ws : mWindows) {
5341+
for (int i = mWindows.size() - 1; i >= 0; i--) {
5342+
final WindowState ws = mWindows.get(i);
53255343
if (ws.mSession.mPid == pid && ws.isVisibleLw()) {
53265344
isVisible = true;
53275345
break;
@@ -6439,7 +6457,10 @@ boolean computeScreenConfigurationLocked(Configuration config) {
64396457

64406458
int keyboardPresence = 0;
64416459
int navigationPresence = 0;
6442-
for (InputDevice device : mInputManager.getInputDevices()) {
6460+
final InputDevice[] devices = mInputManager.getInputDevices();
6461+
final int len = devices.length;
6462+
for (int i = 0; i < len; i++) {
6463+
InputDevice device = devices[i];
64436464
if (!device.isVirtual()) {
64446465
final int sources = device.getSources();
64456466
final int presenceFlag = device.isExternal() ?
@@ -7949,7 +7970,7 @@ public int handleAppTransitionReadyLocked() {
79497970
for (i=0; i<NN && goodToGo; i++) {
79507971
AppWindowToken wtoken = mOpeningApps.get(i);
79517972
if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
7952-
"Check opening app" + wtoken + ": allDrawn="
7973+
"Check opening app=" + wtoken + ": allDrawn="
79537974
+ wtoken.allDrawn + " startingDisplayed="
79547975
+ wtoken.startingDisplayed + " startingMoved="
79557976
+ wtoken.startingMoved);
@@ -8059,7 +8080,7 @@ public int handleAppTransitionReadyLocked() {
80598080
}
80608081
if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
80618082
"New transit: " + transit);
8062-
} else if (oldWallpaper != null) {
8083+
} else if ((oldWallpaper != null) && (oldWallpaper != mWallpaperTarget)) {
80638084
// We are transitioning from an activity with
80648085
// a wallpaper to one without.
80658086
transit = WindowManagerPolicy.TRANSIT_WALLPAPER_CLOSE;

0 commit comments

Comments
 (0)